From 39824e3ce8b1804b9944eb0faf71da7cdccf59ea Mon Sep 17 00:00:00 2001 From: Nikaru Date: Wed, 9 Oct 2024 07:26:59 +0000 Subject: [PATCH] feat: add id property to buttons --- .eslintrc.json | 12 ++++++++++-- package.json | 1 + .../BlockchainList/BlockchainList.tsx | 3 ++- .../ConfirmWalletsModal.tsx | 3 +++ .../CustomDestination/CustomDestination.tsx | 10 ++++++++-- .../CustomTokenModal/CustomTokenModal.tsx | 1 + .../FilterSelector/FilterSelector.tsx | 1 + .../FilterSelector/FilterSelectorContent.tsx | 6 +++++- .../components/HeaderButtons/BackButton.tsx | 6 +++++- .../components/HeaderButtons/CancelButton.tsx | 6 +++++- .../HeaderButtons/HeaderButtons.tsx | 17 ++++++++++++++--- .../HeaderButtons/RefreshButton.tsx | 1 + .../components/HeaderButtons/WalletButton.tsx | 6 +++++- .../src/components/NoResult/NoResult.tsx | 1 + .../src/components/Quote/QuoteCostDetails.tsx | 5 ++++- .../HighValueLossWarningModal.tsx | 1 + .../QuoteWarningsAndErrors.tsx | 1 + .../SlippageWariningModal.tsx | 2 ++ .../UnknownPriceWarningModal.tsx | 1 + .../components/SwapDetails/SwapDetails.tsx | 3 +++ .../SwapDetailsAlerts.Warning.tsx | 2 ++ .../SwapDetailsAlerts/SwapDetailsAlerts.tsx | 1 + .../SwapDetailsCompleteModal.tsx | 9 ++++++++- .../SwapDetailsModal.Cancel.tsx | 8 +++++++- .../SwapDetailsModal.Delete.tsx | 8 +++++++- .../src/components/TokenList/TokenList.tsx | 1 + .../WalletStatefulConnect/DerivationPath.tsx | 1 + .../ExperimentalChain.tsx | 1 + .../WalletStatefulConnect/Namespaces.tsx | 1 + .../ActivateTabAlert/ActivateTabAlert.tsx | 1 + .../ActivateTabModal/ActivateTabModal.tsx | 1 + .../src/containers/Settings/Lists.tsx | 12 ++++++------ .../embedded/src/pages/AddCustomTokenPage.tsx | 6 +++++- widget/embedded/src/pages/ConfirmSwapPage.tsx | 2 ++ .../embedded/src/pages/CustomTokensPage.tsx | 4 ++++ widget/embedded/src/pages/HistoryPage.tsx | 3 +++ widget/embedded/src/pages/Home.tsx | 2 ++ widget/embedded/src/pages/LanguagePage.tsx | 2 +- .../src/pages/LiquiditySourcePage.tsx | 19 ++++++++++++++++--- widget/embedded/src/pages/SettingsPage.tsx | 6 +++++- .../components/IconButton/IconButton.types.ts | 1 + widget/ui/src/components/List/List.tsx | 2 +- .../src/components/ListItem/ListItem.types.ts | 2 ++ .../ListItemButton/ListItemButton.tsx | 1 + yarn.lock | 12 ++++++++++++ 45 files changed, 166 insertions(+), 29 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index e0efaeeb18..a65b910337 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -9,7 +9,8 @@ "import", "react", "react-hooks", - "destructuring" + "destructuring", + "jsx-id-attribute-enforcement" ], "extends": [ "eslint:recommended", @@ -107,7 +108,14 @@ "@typescript-eslint/no-unnecessary-type-assertion": "error", "@typescript-eslint/prefer-enum-initializers": "error", "@typescript-eslint/promise-function-async": "error", - "@typescript-eslint/switch-exhaustiveness-check": "error" + "@typescript-eslint/switch-exhaustiveness-check": "error", + "jsx-id-attribute-enforcement/missing-ids": [ + "error", + { + "targetCustom": ["Button", "IconButton"] + } + ] + // "@typescript-eslint/explicit-function-return-type": "error", // "@typescript-eslint/naming-convention": [ // "error", diff --git a/package.json b/package.json index 905268c6c0..b44f7f4b8f 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,7 @@ "eslint-config-prettier": "^8.8.0", "eslint-plugin-destructuring": "^2.2.1", "eslint-plugin-import": "^2.27.5", + "eslint-plugin-jsx-id-attribute-enforcement": "^1.0.2", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-react": "^7.32.2", "eslint-plugin-react-hooks": "^4.6.0", diff --git a/widget/embedded/src/components/BlockchainList/BlockchainList.tsx b/widget/embedded/src/components/BlockchainList/BlockchainList.tsx index 849c9abafd..958ec91658 100644 --- a/widget/embedded/src/components/BlockchainList/BlockchainList.tsx +++ b/widget/embedded/src/components/BlockchainList/BlockchainList.tsx @@ -48,6 +48,7 @@ export function BlockchainList(props: PropTypes) { {blockchains.map((item) => ( onChange(item)} start={} @@ -56,7 +57,7 @@ export function BlockchainList(props: PropTypes) { {item.displayName} } - id={item.chainId as string} + id={item.name} /> ))} diff --git a/widget/embedded/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx b/widget/embedded/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx index adefefe98f..e0c2647c3a 100644 --- a/widget/embedded/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +++ b/widget/embedded/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx @@ -331,6 +331,7 @@ export function ConfirmWalletsModal(props: PropTypes) { footer: ( diff --git a/widget/embedded/src/components/HeaderButtons/BackButton.tsx b/widget/embedded/src/components/HeaderButtons/BackButton.tsx index f674c44dcc..e7e8f007c4 100644 --- a/widget/embedded/src/components/HeaderButtons/BackButton.tsx +++ b/widget/embedded/src/components/HeaderButtons/BackButton.tsx @@ -7,7 +7,11 @@ import { HeaderButton } from './HeaderButtons.styles'; function BackButton(props: PropTypes) { return ( - + ); diff --git a/widget/embedded/src/components/HeaderButtons/CancelButton.tsx b/widget/embedded/src/components/HeaderButtons/CancelButton.tsx index 99d3c8f226..13baf1df16 100644 --- a/widget/embedded/src/components/HeaderButtons/CancelButton.tsx +++ b/widget/embedded/src/components/HeaderButtons/CancelButton.tsx @@ -9,7 +9,11 @@ import { SuffixContainer } from './HeaderButtons.styles'; function CancelButton(props: PropTypes) { return ( - - diff --git a/widget/embedded/src/components/SwapDetailsModal/SwapDetailsModal.Delete.tsx b/widget/embedded/src/components/SwapDetailsModal/SwapDetailsModal.Delete.tsx index 367abe1947..1217f792a0 100644 --- a/widget/embedded/src/components/SwapDetailsModal/SwapDetailsModal.Delete.tsx +++ b/widget/embedded/src/components/SwapDetailsModal/SwapDetailsModal.Delete.tsx @@ -15,6 +15,7 @@ export const DeleteContent = ({ onDelete, onClose }: DeleteContentProps) => { /> - diff --git a/widget/embedded/src/pages/SettingsPage.tsx b/widget/embedded/src/pages/SettingsPage.tsx index 4a20ff023a..42e726f846 100644 --- a/widget/embedded/src/pages/SettingsPage.tsx +++ b/widget/embedded/src/pages/SettingsPage.tsx @@ -47,7 +47,11 @@ export function SettingsPage() { )} action={ - diff --git a/widget/ui/src/components/IconButton/IconButton.types.ts b/widget/ui/src/components/IconButton/IconButton.types.ts index 0bc39f8040..c66c7ca006 100644 --- a/widget/ui/src/components/IconButton/IconButton.types.ts +++ b/widget/ui/src/components/IconButton/IconButton.types.ts @@ -2,6 +2,7 @@ import type { ButtonPropTypes } from '../Button/Button.types.js'; import type { CSSProperties } from 'react'; export type IconButtonPropTypes = { + id?: ButtonPropTypes['id']; size?: ButtonPropTypes['size']; type?: ButtonPropTypes['type']; variant?: ButtonPropTypes['variant']; diff --git a/widget/ui/src/components/List/List.tsx b/widget/ui/src/components/List/List.tsx index 80f99d2db4..dc7d9f67ac 100644 --- a/widget/ui/src/components/List/List.tsx +++ b/widget/ui/src/components/List/List.tsx @@ -20,7 +20,7 @@ function List(props: ListPropTypes) { id, }); } - return ; + return ; })} ); diff --git a/widget/ui/src/components/ListItem/ListItem.types.ts b/widget/ui/src/components/ListItem/ListItem.types.ts index 9dbe704dd0..cf64dc93f7 100644 --- a/widget/ui/src/components/ListItem/ListItem.types.ts +++ b/widget/ui/src/components/ListItem/ListItem.types.ts @@ -1,4 +1,5 @@ export type ListItemPropTypes = { + id?: string; title?: string | React.ReactElement; description?: string | React.ReactElement; start?: React.ReactNode; @@ -8,4 +9,5 @@ export type ListItemPropTypes = { onKeyUp?: React.KeyboardEventHandler; hasDivider?: boolean; tabIndex?: number; + className?: string; }; diff --git a/widget/ui/src/components/ListItemButton/ListItemButton.tsx b/widget/ui/src/components/ListItemButton/ListItemButton.tsx index 0b52595617..018d99413b 100644 --- a/widget/ui/src/components/ListItemButton/ListItemButton.tsx +++ b/widget/ui/src/components/ListItemButton/ListItemButton.tsx @@ -15,6 +15,7 @@ function ListItemButton(props: ListItemButtonProps) { return ( { diff --git a/yarn.lock b/yarn.lock index b2663fb2f1..88b486dc92 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11907,6 +11907,13 @@ eslint-plugin-import@^2.27.5: semver "^6.3.1" tsconfig-paths "^3.14.2" +eslint-plugin-jsx-id-attribute-enforcement@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-id-attribute-enforcement/-/eslint-plugin-jsx-id-attribute-enforcement-1.0.2.tgz#eb72009ef1c2d150bf7466be2b1d0008fe6de61b" + integrity sha512-xWg5lJ+z1/+WByCdtIAepKRx8J8GAeYGw4MmlAkEfdyCpj/UMEb+FVCmEVOJbXdyvTPq8xNfhIW/43eInykHPg== + dependencies: + requireindex "~1.1.0" + eslint-plugin-prettier@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz#651cbb88b1dab98bfd42f017a12fa6b2d993f94b" @@ -17322,6 +17329,11 @@ require-main-filename@^2.0.0: resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== +requireindex@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.1.0.tgz#e5404b81557ef75db6e49c5a72004893fe03e162" + integrity sha512-LBnkqsDE7BZKvqylbmn7lTIVdpx4K/QCduRATpO5R+wtPmky/a8pN1bO2D6wXppn1497AJF9mNjqAXr6bdl9jg== + resize-observer-polyfill@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"