From 056618b7c413c2564193a2e3d034cc4de4f15cdf Mon Sep 17 00:00:00 2001 From: Daniel Dimitrov Date: Wed, 6 Nov 2024 08:25:20 +0100 Subject: [PATCH] chore: update eslint to v9 --- .eslintrc.json | 45 --- eslint.config.mjs | 77 ++++ package.json | 18 +- .../__tests__/SafeTokenWidget.test.tsx | 2 +- .../steps/AdvancedOptionsStep/index.tsx | 2 +- .../FallbackHandler/__tests__/index.test.tsx | 20 +- .../useNotificationRegistrations.test.ts | 26 +- .../TxData/Transfer/TransferActions.tsx | 4 +- src/components/tx-flow/SafeTxProvider.tsx | 6 +- .../flows/SignMessage/SignMessage.test.tsx | 10 +- .../tx-flow/flows/SignMessage/SignMessage.tsx | 12 +- .../ReviewSignMessageOnChain.test.tsx | 2 +- .../TokenTransfer/CreateTokenTransfer.tsx | 4 +- .../UpsertRecovery/useRecoveryPeriods.ts | 2 +- .../SignOrExecuteForm/SignOrExecuteForm.tsx | 4 +- .../tx/security/blockaid/useBlockaid.ts | 2 +- .../security/tenderly/__tests__/utils.test.ts | 2 +- .../__tests__/useDeployGasLimit.test.ts | 2 +- src/features/counterfactual/utils.ts | 2 +- .../ExecuteRecoveryButton/index.tsx | 4 +- .../RecoveryCards/RecoveryInProgressCard.tsx | 8 +- .../useIsValidRecoveryExecution.test.ts | 12 +- .../swap/helpers/__tests__/utils.test.ts | 1 - src/features/swap/helpers/fee.ts | 11 +- .../__tests__/WalletConnectContext.test.tsx | 8 +- src/hooks/__tests__/useChainId.test.ts | 2 +- .../__tests__/useLoadSpendingLimits.test.ts | 2 +- .../__tests__/useSafeTokenAllocation.test.ts | 16 +- .../__tests__/useSafeMessageStatus.test.ts | 6 +- .../__tests__/useCategoryFilter.test.ts | 8 +- src/hooks/useTxNotifications.ts | 4 +- src/hooks/useVisibleBalances.ts | 15 +- src/pages/_document.tsx | 1 - .../security/modules/BlockaidModule/index.ts | 2 +- src/store/__tests__/txQueueSlice.test.ts | 2 +- src/utils/__tests__/tokens.test.ts | 4 +- src/utils/__tests__/transactions.test.ts | 4 +- src/utils/transactions.ts | 2 +- tsconfig.json | 3 +- yarn.lock | 368 +++++++++--------- 40 files changed, 384 insertions(+), 341 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 eslint.config.mjs diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 63839322a5..0000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "extends": [ - "next", - "prettier", - "plugin:prettier/recommended", - "plugin:storybook/recommended" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": ["./tsconfig.json"] - }, - "rules": { - "@next/next/no-img-element": "off", - "@next/next/google-font-display": "off", - "@next/next/google-font-preconnect": "off", - "@next/next/no-page-custom-font": "off", - "unused-imports/no-unused-imports-ts": "error", - "@typescript-eslint/consistent-type-imports": "error", - "@typescript-eslint/await-thenable": "error", - "no-constant-condition": "warn", - "no-unused-vars": ["error", { "varsIgnorePattern": "^_" }], - "react-hooks/exhaustive-deps": [ - "warn", - { - "additionalHooks": "useAsync" - } - ], - "no-only-tests/no-only-tests": "error", - "object-shorthand": ["error", "properties"], - "jsx-quotes": ["error", "prefer-double"], - "react/jsx-curly-brace-presence": ["error", { "props": "never", "children": "never" }] - }, - "ignorePatterns": [ - "node_modules/", - ".next/", - ".github/", - "cypress/", - "src/types/contracts/" - ], - "plugins": [ - "unused-imports", - "@typescript-eslint", - "no-only-tests" - ] -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000000..04caa5f0a2 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,77 @@ +import unusedImports from 'eslint-plugin-unused-imports' +import typescriptEslint from '@typescript-eslint/eslint-plugin' +import noOnlyTests from 'eslint-plugin-no-only-tests' +import tsParser from '@typescript-eslint/parser' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import js from '@eslint/js' +import { FlatCompat } from '@eslint/eslintrc' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}) + +export default [ + { + ignores: ['**/node_modules/', '**/.next/', '**/.github/', '**/cypress/', 'src/types/contracts/'], + }, + ...compat.extends('next', 'prettier', 'plugin:prettier/recommended', 'plugin:storybook/recommended'), + { + plugins: { + 'unused-imports': unusedImports, + '@typescript-eslint': typescriptEslint, + 'no-only-tests': noOnlyTests, + }, + + languageOptions: { + parser: tsParser, + ecmaVersion: 5, + sourceType: 'script', + + parserOptions: { + project: ['./tsconfig.json'], + }, + }, + + rules: { + '@next/next/no-img-element': 'off', + '@next/next/google-font-display': 'off', + '@next/next/google-font-preconnect': 'off', + '@next/next/no-page-custom-font': 'off', + 'unused-imports/no-unused-imports': 'error', + '@typescript-eslint/consistent-type-imports': 'error', + '@typescript-eslint/await-thenable': 'error', + 'no-constant-condition': 'warn', + + 'unused-imports/no-unused-vars': [ + 'error', + { + varsIgnorePattern: '^_', + }, + ], + + 'react-hooks/exhaustive-deps': [ + 'warn', + { + additionalHooks: 'useAsync', + }, + ], + + 'no-only-tests/no-only-tests': 'error', + 'object-shorthand': ['error', 'properties'], + 'jsx-quotes': ['error', 'prefer-double'], + + 'react/jsx-curly-brace-presence': [ + 'error', + { + props: 'never', + children: 'never', + }, + ], + }, + }, +] diff --git a/package.json b/package.json index f0ca1ec0b7..4a137ba228 100644 --- a/package.json +++ b/package.json @@ -100,6 +100,8 @@ "devDependencies": { "@chromatic-com/storybook": "^1.3.1", "@cowprotocol/app-data": "^2.1.0", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.14.0", "@faker-js/faker": "^9.0.3", "@mdx-js/loader": "^3.0.1", "@mdx-js/react": "^3.0.1", @@ -140,20 +142,20 @@ "cypress": "^12.15.0", "cypress-file-upload": "^5.0.8", "cypress-visual-regression": "^5.0.2", - "eslint": "^8.57.0", - "eslint-config-next": "15.0.2", - "eslint-config-prettier": "^8.5.0", - "eslint-plugin-no-only-tests": "^3.1.0", - "eslint-plugin-prettier": "^4.0.0", - "eslint-plugin-storybook": "^0.8.0", - "eslint-plugin-unused-imports": "^2.0.0", + "eslint": "^9.14.0", + "eslint-config-next": "^15.0.2", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-no-only-tests": "^3.3.0", + "eslint-plugin-prettier": "^5.2.1", + "eslint-plugin-storybook": "^0.11.0", + "eslint-plugin-unused-imports": "^4.1.4", "fake-indexeddb": "^4.0.2", "gray-matter": "^4.0.3", "husky": "^9.0.11", "jest": "^29.6.2", "jest-environment-jsdom": "^29.6.2", "mockdate": "^3.0.5", - "prettier": "^2.7.0", + "prettier": "^3.3.3", "remark-frontmatter": "^5.0.0", "remark-gfm": "^4.0.0", "remark-heading-id": "^1.0.1", diff --git a/src/components/common/SafeTokenWidget/__tests__/SafeTokenWidget.test.tsx b/src/components/common/SafeTokenWidget/__tests__/SafeTokenWidget.test.tsx index 4f7ac6bfdc..b034f73b56 100644 --- a/src/components/common/SafeTokenWidget/__tests__/SafeTokenWidget.test.tsx +++ b/src/components/common/SafeTokenWidget/__tests__/SafeTokenWidget.test.tsx @@ -20,7 +20,7 @@ describe('SafeTokenWidget', () => { () => ({ get: () => fakeSafeAddress, - } as any), + }) as any, ) jest.spyOn(safePass, 'useGetOwnGlobalCampaignRankQuery').mockReturnValue({ diff --git a/src/components/new-safe/create/steps/AdvancedOptionsStep/index.tsx b/src/components/new-safe/create/steps/AdvancedOptionsStep/index.tsx index 46aa38cba9..30547f34ba 100644 --- a/src/components/new-safe/create/steps/AdvancedOptionsStep/index.tsx +++ b/src/components/new-safe/create/steps/AdvancedOptionsStep/index.tsx @@ -160,7 +160,7 @@ const AdvancedOptionsStep = ({ onSubmit, onBack, data, setStep }: StepRenderProp label="Salt nonce" error={Boolean(formState.errors[AdvancedOptionsFields.saltNonce]) || Boolean(isDeployed)} helperText={ - formState.errors[AdvancedOptionsFields.saltNonce]?.message ?? Boolean(isDeployed) + (formState.errors[AdvancedOptionsFields.saltNonce]?.message ?? Boolean(isDeployed)) ? 'The Safe is already deployed. Use a different salt nonce.' : undefined } diff --git a/src/components/settings/FallbackHandler/__tests__/index.test.tsx b/src/components/settings/FallbackHandler/__tests__/index.test.tsx index 4e5d144a6d..36991a1535 100644 --- a/src/components/settings/FallbackHandler/__tests__/index.test.tsx +++ b/src/components/settings/FallbackHandler/__tests__/index.test.tsx @@ -34,7 +34,7 @@ describe('FallbackHandler', () => { name: 'FallbackHandlerName', }, }, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const fbHandler = render(, { @@ -71,7 +71,7 @@ describe('FallbackHandler', () => { name: 'FallbackHandlerName', }, }, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const fbHandler = render(, { @@ -104,7 +104,7 @@ describe('FallbackHandler', () => { value: GOERLI_FALLBACK_HANDLER, }, }, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const fbHandler = render(, { @@ -125,7 +125,7 @@ describe('FallbackHandler', () => { version: '1.3.0', chainId: '5', }, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const fbHandler = render() @@ -150,7 +150,7 @@ describe('FallbackHandler', () => { version: '1.3.0', chainId: '5', }, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const fbHandler = render() @@ -178,7 +178,7 @@ describe('FallbackHandler', () => { value: '0x123', }, }, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const fbHandler = render() @@ -212,7 +212,7 @@ describe('FallbackHandler', () => { value: '0x123', }, }, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const fbHandler = render() @@ -232,7 +232,7 @@ describe('FallbackHandler', () => { version: '1.0.0', chainId: '5', }, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const fbHandler = render() @@ -251,7 +251,7 @@ describe('FallbackHandler', () => { value: TWAP_FALLBACK_HANDLER, }, }, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const { getByText } = render() @@ -274,7 +274,7 @@ describe('FallbackHandler', () => { value: TWAP_FALLBACK_HANDLER, }, }, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const { queryByText } = render() diff --git a/src/components/settings/PushNotifications/hooks/__tests__/useNotificationRegistrations.test.ts b/src/components/settings/PushNotifications/hooks/__tests__/useNotificationRegistrations.test.ts index c0a6cb1068..5be1b4c375 100644 --- a/src/components/settings/PushNotifications/hooks/__tests__/useNotificationRegistrations.test.ts +++ b/src/components/settings/PushNotifications/hooks/__tests__/useNotificationRegistrations.test.ts @@ -35,7 +35,7 @@ describe('useNotificationRegistrations', () => { () => ({ label: 'MetaMask', - } as ConnectedWallet), + }) as ConnectedWallet, ) }) @@ -75,7 +75,7 @@ describe('useNotificationRegistrations', () => { () => ({ uuid: undefined, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const { result } = renderHook(() => useNotificationRegistrations()) @@ -105,7 +105,7 @@ describe('useNotificationRegistrations', () => { ({ uuid: self.crypto.randomUUID(), createPreferences: createPreferencesMock, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const { result } = renderHook(() => useNotificationRegistrations()) @@ -137,7 +137,7 @@ describe('useNotificationRegistrations', () => { ({ uuid: self.crypto.randomUUID(), createPreferences: createPreferencesMock, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const { result } = renderHook(() => useNotificationRegistrations()) @@ -168,7 +168,7 @@ describe('useNotificationRegistrations', () => { ({ uuid: self.crypto.randomUUID(), createPreferences: createPreferencesMock, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const showNotificationSpy = jest.spyOn(notificationsSlice, 'showNotification') @@ -197,7 +197,7 @@ describe('useNotificationRegistrations', () => { () => ({ uuid: undefined, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const { result } = renderHook(() => useNotificationRegistrations()) @@ -219,7 +219,7 @@ describe('useNotificationRegistrations', () => { ({ uuid, deletePreferences: deletePreferencesMock, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const { result } = renderHook(() => useNotificationRegistrations()) @@ -245,7 +245,7 @@ describe('useNotificationRegistrations', () => { ({ uuid, deletePreferences: deletePreferencesMock, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const { result } = renderHook(() => useNotificationRegistrations()) @@ -271,7 +271,7 @@ describe('useNotificationRegistrations', () => { ({ uuid, deletePreferences: deletePreferencesMock, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const { result } = renderHook(() => useNotificationRegistrations()) @@ -295,7 +295,7 @@ describe('useNotificationRegistrations', () => { () => ({ uuid: undefined, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const { result } = renderHook(() => useNotificationRegistrations()) @@ -317,7 +317,7 @@ describe('useNotificationRegistrations', () => { ({ uuid, deleteAllChainPreferences: deleteAllChainPreferencesMock, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const { result } = renderHook(() => useNotificationRegistrations()) @@ -340,7 +340,7 @@ describe('useNotificationRegistrations', () => { ({ uuid, deleteAllChainPreferences: deleteAllChainPreferencesMock, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const { result } = renderHook(() => useNotificationRegistrations()) @@ -363,7 +363,7 @@ describe('useNotificationRegistrations', () => { ({ uuid, deleteAllChainPreferences: deleteAllChainPreferencesMock, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const { result } = renderHook(() => useNotificationRegistrations()) diff --git a/src/components/transactions/TxDetails/TxData/Transfer/TransferActions.tsx b/src/components/transactions/TxDetails/TxData/Transfer/TransferActions.tsx index 3dac032a8b..dd16a19430 100644 --- a/src/components/transactions/TxDetails/TxData/Transfer/TransferActions.tsx +++ b/src/components/transactions/TxDetails/TxData/Transfer/TransferActions.tsx @@ -68,8 +68,8 @@ const TransferActions = ({ const amount = isNativeTokenTransfer(txInfo.transferInfo) ? safeFormatUnits(txInfo.transferInfo.value, ETHER) : isERC20Transfer(txInfo.transferInfo) - ? safeFormatUnits(txInfo.transferInfo.value, txInfo.transferInfo.decimals) - : undefined + ? safeFormatUnits(txInfo.transferInfo.value, txInfo.transferInfo.decimals) + : undefined const isOutgoingTx = isOutgoingTransfer(txInfo) const canSendAgain = diff --git a/src/components/tx-flow/SafeTxProvider.tsx b/src/components/tx-flow/SafeTxProvider.tsx index f83c86663a..31e2070403 100644 --- a/src/components/tx-flow/SafeTxProvider.tsx +++ b/src/components/tx-flow/SafeTxProvider.tsx @@ -74,8 +74,10 @@ const SafeTxProvider = ({ children }: { children: ReactNode }): ReactElement => const recommendedSafeTxGas = useSafeTxGas(safeTx) // Priority to external nonce, then to the recommended one - const finalNonce = isSigned ? safeTx?.data.nonce : nonce ?? recommendedNonce ?? safeTx?.data.nonce - const finalSafeTxGas = isSigned ? safeTx?.data.safeTxGas : safeTxGas ?? recommendedSafeTxGas ?? safeTx?.data.safeTxGas + const finalNonce = isSigned ? safeTx?.data.nonce : (nonce ?? recommendedNonce ?? safeTx?.data.nonce) + const finalSafeTxGas = isSigned + ? safeTx?.data.safeTxGas + : (safeTxGas ?? recommendedSafeTxGas ?? safeTx?.data.safeTxGas) // Update the tx when the nonce or safeTxGas change useEffect(() => { diff --git a/src/components/tx-flow/flows/SignMessage/SignMessage.test.tsx b/src/components/tx-flow/flows/SignMessage/SignMessage.test.tsx index 0699137ea8..5139f253e6 100644 --- a/src/components/tx-flow/flows/SignMessage/SignMessage.test.tsx +++ b/src/components/tx-flow/flows/SignMessage/SignMessage.test.tsx @@ -394,7 +394,7 @@ describe('SignMessage', () => { () => ({ address: zeroPadValue('0x07', 20), - } as ConnectedWallet), + }) as ConnectedWallet, ) jest.spyOn(useIsSafeOwnerHook, 'default').mockImplementation(() => false) jest.spyOn(useSafeMessage, 'default').mockImplementation(() => [undefined, jest.fn(), undefined]) @@ -423,7 +423,7 @@ describe('SignMessage', () => { () => ({ address: zeroPadValue('0x02', 20), - } as ConnectedWallet), + }) as ConnectedWallet, ) const messageText = 'Hello world!' const messageHash = generateSafeMessageHash( @@ -469,7 +469,7 @@ describe('SignMessage', () => { () => ({ address: zeroPadValue('0x03', 20), - } as ConnectedWallet), + }) as ConnectedWallet, ) jest.spyOn(useSafeMessage, 'default').mockReturnValue([undefined, jest.fn(), undefined]) @@ -511,7 +511,7 @@ describe('SignMessage', () => { () => ({ address: zeroPadValue('0x03', 20), - } as ConnectedWallet), + }) as ConnectedWallet, ) const messageText = 'Hello world!' @@ -575,7 +575,7 @@ describe('SignMessage', () => { () => ({ address: zeroPadValue('0x03', 20), - } as ConnectedWallet), + }) as ConnectedWallet, ) const messageText = 'Hello world!' diff --git a/src/components/tx-flow/flows/SignMessage/SignMessage.tsx b/src/components/tx-flow/flows/SignMessage/SignMessage.tsx index a976e23a7b..127a7a2b80 100644 --- a/src/components/tx-flow/flows/SignMessage/SignMessage.tsx +++ b/src/components/tx-flow/flows/SignMessage/SignMessage.tsx @@ -112,12 +112,12 @@ const MessageDialogError = ({ isOwner, submitError }: { isOwner: boolean; submit !wallet || !onboard ? 'No wallet is connected.' : !isOwner - ? "You are currently not a signer of this Safe Account and won't be able to confirm this message." - : submitError && isWalletRejection(submitError) - ? 'User rejected signing.' - : submitError - ? 'Error confirming the message. Please try again.' - : null + ? "You are currently not a signer of this Safe Account and won't be able to confirm this message." + : submitError && isWalletRejection(submitError) + ? 'User rejected signing.' + : submitError + ? 'Error confirming the message. Please try again.' + : null if (errorMessage) { return {errorMessage} diff --git a/src/components/tx-flow/flows/SignMessageOnChain/ReviewSignMessageOnChain.test.tsx b/src/components/tx-flow/flows/SignMessageOnChain/ReviewSignMessageOnChain.test.tsx index 75c457b0b6..13101e0591 100644 --- a/src/components/tx-flow/flows/SignMessageOnChain/ReviewSignMessageOnChain.test.tsx +++ b/src/components/tx-flow/flows/SignMessageOnChain/ReviewSignMessageOnChain.test.tsx @@ -33,7 +33,7 @@ describe('ReviewSignMessageOnChain', () => { }, version: '1.3.0', } as ReturnType['safe'], - } as ReturnType), + }) as ReturnType, ) await act(async () => { diff --git a/src/components/tx-flow/flows/TokenTransfer/CreateTokenTransfer.tsx b/src/components/tx-flow/flows/TokenTransfer/CreateTokenTransfer.tsx index 4b5c18b3f0..7647ee1033 100644 --- a/src/components/tx-flow/flows/TokenTransfer/CreateTokenTransfer.tsx +++ b/src/components/tx-flow/flows/TokenTransfer/CreateTokenTransfer.tsx @@ -56,8 +56,8 @@ export const CreateTokenTransfer = ({ [TokenTransferFields.type]: disableSpendingLimit ? TokenTransferType.multiSig : isOnlySpendingLimitBeneficiary - ? TokenTransferType.spendingLimit - : params.type, + ? TokenTransferType.spendingLimit + : params.type, [TokenTransferFields.tokenAddress]: isOnlySpendingLimitBeneficiary ? balancesItems[0]?.tokenInfo.address : params.tokenAddress, diff --git a/src/components/tx-flow/flows/UpsertRecovery/useRecoveryPeriods.ts b/src/components/tx-flow/flows/UpsertRecovery/useRecoveryPeriods.ts index dd7fcc026f..87dabc62d5 100644 --- a/src/components/tx-flow/flows/UpsertRecovery/useRecoveryPeriods.ts +++ b/src/components/tx-flow/flows/UpsertRecovery/useRecoveryPeriods.ts @@ -82,7 +82,7 @@ export function useRecoveryPeriods(): { delay: Periods; expiration: Periods } { const isTestChain = chain && [chains.gor, chains.sep].includes(chain.chainId) // TODO: Remove constant before release - // eslint-disable-next-line no-constant-condition + if (isTestChain) { return { delay: TestRecoveryDelayPeriods, diff --git a/src/components/tx/SignOrExecuteForm/SignOrExecuteForm.tsx b/src/components/tx/SignOrExecuteForm/SignOrExecuteForm.tsx index 98bf41fada..7d22be7c59 100644 --- a/src/components/tx/SignOrExecuteForm/SignOrExecuteForm.tsx +++ b/src/components/tx/SignOrExecuteForm/SignOrExecuteForm.tsx @@ -65,8 +65,8 @@ const trackTxEvents = ( const creationEvent = isRoleExecution ? TX_EVENTS.CREATE_VIA_ROLE : isDelegateCreation - ? TX_EVENTS.CREATE_VIA_DELEGATE - : TX_EVENTS.CREATE + ? TX_EVENTS.CREATE_VIA_DELEGATE + : TX_EVENTS.CREATE const executionEvent = isRoleExecution ? TX_EVENTS.EXECUTE_VIA_ROLE : TX_EVENTS.EXECUTE const event = isCreation ? creationEvent : isExecuted ? executionEvent : TX_EVENTS.CONFIRM const txType = getTransactionTrackingType(details) diff --git a/src/components/tx/security/blockaid/useBlockaid.ts b/src/components/tx/security/blockaid/useBlockaid.ts index 5ea657de25..c328e97a92 100644 --- a/src/components/tx/security/blockaid/useBlockaid.ts +++ b/src/components/tx/security/blockaid/useBlockaid.ts @@ -36,7 +36,7 @@ export const useBlockaid = ( threshold: safe.threshold, }) }, - // eslint-disable-next-line react-hooks/exhaustive-deps + [safe.chainId, safe.threshold, safeAddress, data, wallet?.address, isFeatureEnabled], false, ) diff --git a/src/components/tx/security/tenderly/__tests__/utils.test.ts b/src/components/tx/security/tenderly/__tests__/utils.test.ts index 3005c06a73..a18f94562e 100644 --- a/src/components/tx/security/tenderly/__tests__/utils.test.ts +++ b/src/components/tx/security/tenderly/__tests__/utils.test.ts @@ -47,7 +47,7 @@ describe('simulation utils', () => { Promise.resolve({ gasLimit: BigInt(30_000_000), }), - } as any), + }) as any, ) }) describe('getSimulationPayload', () => { diff --git a/src/features/counterfactual/__tests__/useDeployGasLimit.test.ts b/src/features/counterfactual/__tests__/useDeployGasLimit.test.ts index c5ef2d8184..24e4f42fbb 100644 --- a/src/features/counterfactual/__tests__/useDeployGasLimit.test.ts +++ b/src/features/counterfactual/__tests__/useDeployGasLimit.test.ts @@ -87,7 +87,7 @@ describe('useDeployGasLimit hook', () => { getContractManager: () => ({ contractNetworks: {}, - } as any), + }) as any, getContractVersion: () => Promise.resolve('1.3.0'), createSafeDeploymentTransaction: () => Promise.resolve({ diff --git a/src/features/counterfactual/utils.ts b/src/features/counterfactual/utils.ts index e04772b29b..37ad4c3fbd 100644 --- a/src/features/counterfactual/utils.ts +++ b/src/features/counterfactual/utils.ts @@ -122,7 +122,7 @@ export const getCounterfactualBalance = async ( } else { const cachedBalance = getNativeBalance() const useCache = cachedBalance !== undefined && cachedBalance > 0n && !ignoreCache - balance = useCache ? cachedBalance : (await getWeb3ReadOnly()?.getBalance(safeAddress)) ?? 0n + balance = useCache ? cachedBalance : ((await getWeb3ReadOnly()?.getBalance(safeAddress)) ?? 0n) setNativeBalance(balance) } diff --git a/src/features/recovery/components/ExecuteRecoveryButton/index.tsx b/src/features/recovery/components/ExecuteRecoveryButton/index.tsx index c71ef9ffc7..3a5da0627e 100644 --- a/src/features/recovery/components/ExecuteRecoveryButton/index.tsx +++ b/src/features/recovery/components/ExecuteRecoveryButton/index.tsx @@ -40,8 +40,8 @@ export function ExecuteRecoveryButton({ ? isWrongChain ? `Switch your wallet network to ${chain?.chainName} to execute this transaction` : isNext - ? 'You can execute the recovery after the specified review window' - : 'Previous recovery proposals must be executed or cancelled first' + ? 'You can execute the recovery after the specified review window' + : 'Previous recovery proposals must be executed or cancelled first' : null } > diff --git a/src/features/recovery/components/RecoveryCards/RecoveryInProgressCard.tsx b/src/features/recovery/components/RecoveryCards/RecoveryInProgressCard.tsx index d4d81ebafb..bc66ec1110 100644 --- a/src/features/recovery/components/RecoveryCards/RecoveryInProgressCard.tsx +++ b/src/features/recovery/components/RecoveryCards/RecoveryInProgressCard.tsx @@ -42,13 +42,13 @@ export function RecoveryInProgressCard({ orientation = 'vertical', onClose, reco const title = isExecutable ? 'Account can be recovered' : isExpired - ? 'Account recovery expired' - : 'Account recovery in progress' + ? 'Account recovery expired' + : 'Account recovery in progress' const desc = isExecutable ? 'The review window has passed and it is now possible to execute the recovery proposal.' : isExpired - ? 'The pending recovery proposal has expired and needs to be cancelled before a new one can be created.' - : 'The recovery process has started. This Account will be ready to recover in:' + ? 'The pending recovery proposal has expired and needs to be cancelled before a new one can be created.' + : 'The recovery process has started. This Account will be ready to recover in:' const link = ( diff --git a/src/features/recovery/hooks/__tests__/useIsValidRecoveryExecution.test.ts b/src/features/recovery/hooks/__tests__/useIsValidRecoveryExecution.test.ts index 9e4ce24268..2dfe538418 100644 --- a/src/features/recovery/hooks/__tests__/useIsValidRecoveryExecution.test.ts +++ b/src/features/recovery/hooks/__tests__/useIsValidRecoveryExecution.test.ts @@ -134,7 +134,7 @@ describe('useIsValidRecoveryExecution', () => { mockUseIsRecoverer.mockReturnValue(true) mockGetPatchedSignerOrProvider.mockReturnValue({ - getSigner: () => ({} as any), + getSigner: () => ({}) as any, } as any) const isValid = faker.datatype.boolean() @@ -167,7 +167,7 @@ describe('useIsValidRecoveryExecution', () => { mockUseIsRecoverer.mockReturnValue(true) mockGetPatchedSignerOrProvider.mockReturnValue({ - getSigner: () => ({} as any), + getSigner: () => ({}) as any, } as any) const error = new Error('Some error') @@ -275,7 +275,7 @@ describe('useIsValidRecoveryExecution', () => { mockUseRecoveryTxState.mockReturnValue({ isExecutable: true } as any) mockGetPatchedSignerOrProvider.mockReturnValue({ - getSigner: () => ({} as any), + getSigner: () => ({}) as any, } as any) mockGetModuleInstance.mockReturnValue({ @@ -312,7 +312,7 @@ describe('useIsValidRecoveryExecution', () => { mockUseRecoveryTxState.mockReturnValue({ isExecutable: true } as any) mockGetPatchedSignerOrProvider.mockReturnValue({ - getSigner: () => ({} as any), + getSigner: () => ({}) as any, } as any) const error = new Error('Some error') @@ -429,7 +429,7 @@ describe('useIsValidRecoveryExecution', () => { mockUseRecoveryTxState.mockReturnValue({ isExpired: true } as any) mockGetPatchedSignerOrProvider.mockReturnValue({ - getSigner: () => ({} as any), + getSigner: () => ({}) as any, } as any) mockGetModuleInstance.mockReturnValue({ @@ -466,7 +466,7 @@ describe('useIsValidRecoveryExecution', () => { mockUseRecoveryTxState.mockReturnValue({ isExpired: true } as any) mockGetPatchedSignerOrProvider.mockReturnValue({ - getSigner: () => ({} as any), + getSigner: () => ({}) as any, } as any) const error = new Error('Some error') diff --git a/src/features/swap/helpers/__tests__/utils.test.ts b/src/features/swap/helpers/__tests__/utils.test.ts index 506a96ce80..65bd524c7e 100644 --- a/src/features/swap/helpers/__tests__/utils.test.ts +++ b/src/features/swap/helpers/__tests__/utils.test.ts @@ -171,7 +171,6 @@ describe('Swap helpers', () => { expect(result).toEqual('0') }) - // eslint-disable-next-line no-only-tests/no-only-tests it('returns the surplus amount for buy orders', () => { const mockOrder = { executedSellAmount: '10000000000000000000', //10 diff --git a/src/features/swap/helpers/fee.ts b/src/features/swap/helpers/fee.ts index 0a7cc79d32..d412e308bd 100644 --- a/src/features/swap/helpers/fee.ts +++ b/src/features/swap/helpers/fee.ts @@ -20,10 +20,13 @@ const FEE_TIERS = { } const getLowerCaseStableCoinAddresses = () => { - const lowerCaseStableCoinAddresses = Object.keys(stableCoinAddresses).reduce((result, key) => { - result[key.toLowerCase()] = stableCoinAddresses[key] - return result - }, {} as typeof stableCoinAddresses) + const lowerCaseStableCoinAddresses = Object.keys(stableCoinAddresses).reduce( + (result, key) => { + result[key.toLowerCase()] = stableCoinAddresses[key] + return result + }, + {} as typeof stableCoinAddresses, + ) return lowerCaseStableCoinAddresses } diff --git a/src/features/walletconnect/__tests__/WalletConnectContext.test.tsx b/src/features/walletconnect/__tests__/WalletConnectContext.test.tsx index b9a504ab8a..d2929f24ca 100644 --- a/src/features/walletconnect/__tests__/WalletConnectContext.test.tsx +++ b/src/features/walletconnect/__tests__/WalletConnectContext.test.tsx @@ -246,7 +246,7 @@ describe('WalletConnectProvider', () => { () => ({ request: mockRequest, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) render( @@ -305,7 +305,7 @@ describe('WalletConnectProvider', () => { () => ({ request: mockRequest, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) render( @@ -372,7 +372,7 @@ describe('WalletConnectProvider', () => { () => ({ request: mockRequest, - } as unknown as ReturnType), + }) as unknown as ReturnType, ) render( @@ -443,7 +443,7 @@ describe('WalletConnectProvider', () => { () => ({ request: () => Promise.reject(new Error('Test request failed')), - } as unknown as ReturnType), + }) as unknown as ReturnType, ) const onRequestSpy = jest.spyOn(WalletConnectWallet.prototype, 'onRequest') diff --git a/src/hooks/__tests__/useChainId.test.ts b/src/hooks/__tests__/useChainId.test.ts index b93c047509..6a0a737a2b 100644 --- a/src/hooks/__tests__/useChainId.test.ts +++ b/src/hooks/__tests__/useChainId.test.ts @@ -84,7 +84,7 @@ describe('useChainId hook', () => { () => ({ chainId: '1337', - } as ConnectedWallet), + }) as ConnectedWallet, ) jest.spyOn(useChains, 'default').mockImplementation(() => ({ diff --git a/src/hooks/__tests__/useLoadSpendingLimits.test.ts b/src/hooks/__tests__/useLoadSpendingLimits.test.ts index d84275eab3..3dfaea11ab 100644 --- a/src/hooks/__tests__/useLoadSpendingLimits.test.ts +++ b/src/hooks/__tests__/useLoadSpendingLimits.test.ts @@ -178,7 +178,7 @@ describe('getTokenAllowanceForDelegate', () => { }, _isProvider: true, resolveName: (name: string) => name, - } as any), + }) as any, ) const mockContract = { getTokenAllowance: getTokenAllowanceMock } as unknown as AllowanceModule diff --git a/src/hooks/__tests__/useSafeTokenAllocation.test.ts b/src/hooks/__tests__/useSafeTokenAllocation.test.ts index 6b66b3c44d..f86cdd9896 100644 --- a/src/hooks/__tests__/useSafeTokenAllocation.test.ts +++ b/src/hooks/__tests__/useSafeTokenAllocation.test.ts @@ -82,7 +82,7 @@ describe('Allocations', () => { address: toBeHex('0x2', 20), chainId: '1', }, - } as any), + }) as any, ) }) @@ -96,7 +96,7 @@ describe('Allocations', () => { address: undefined, chainId: '1', }, - } as any), + }) as any, ) const { result } = renderHook(() => useSafeTokenAllocation()) @@ -170,7 +170,7 @@ describe('Allocations', () => { } return Promise.resolve('0x') }, - } as any), + }) as any, ) const { result } = renderHook(() => useSafeTokenAllocation()) @@ -229,7 +229,7 @@ describe('Allocations', () => { } return Promise.resolve('0x') }, - } as any), + }) as any, ) const { result } = renderHook(() => useSafeTokenAllocation()) @@ -268,7 +268,7 @@ describe('Allocations', () => { address: undefined, chainId: '1', }, - } as any), + }) as any, ) const { result } = renderHook(() => useSafeVotingPower([{} as Vesting])) @@ -295,7 +295,7 @@ describe('Allocations', () => { } return Promise.resolve('0x') }, - } as any), + }) as any, ) const { result } = renderHook(() => useSafeVotingPower()) @@ -321,7 +321,7 @@ describe('Allocations', () => { } return Promise.resolve('0x') }, - } as any), + }) as any, ) const mockAllocation: Vesting[] = [ @@ -366,7 +366,7 @@ describe('Allocations', () => { } return Promise.resolve('0x') }, - } as any), + }) as any, ) const mockAllocation: Vesting[] = [ diff --git a/src/hooks/messages/__tests__/useSafeMessageStatus.test.ts b/src/hooks/messages/__tests__/useSafeMessageStatus.test.ts index 1af158baa5..bc0a390e07 100644 --- a/src/hooks/messages/__tests__/useSafeMessageStatus.test.ts +++ b/src/hooks/messages/__tests__/useSafeMessageStatus.test.ts @@ -18,7 +18,7 @@ describe('useSafeMessageStatus', () => { it('should return "Awaiting confirmations" if the message is not pending, the wallet has signed it but it is not fully signed', () => { jest.spyOn(useIsSafeMessagePendingHook, 'default').mockImplementation(() => false) - jest.spyOn(useWalletHook, 'default').mockImplementation(() => ({ address: '0x123' } as ConnectedWallet)) + jest.spyOn(useWalletHook, 'default').mockImplementation(() => ({ address: '0x123' }) as ConnectedWallet) const message = { confirmations: [{ owner: { value: '0x123' } }], @@ -31,7 +31,7 @@ describe('useSafeMessageStatus', () => { it('should return the message status if the message is not pending and the wallet has not signed the message', () => { jest.spyOn(useIsSafeMessagePendingHook, 'default').mockImplementation(() => false) - jest.spyOn(useWalletHook, 'default').mockImplementation(() => ({ address: '0x123' } as ConnectedWallet)) + jest.spyOn(useWalletHook, 'default').mockImplementation(() => ({ address: '0x123' }) as ConnectedWallet) const message = { confirmations: [{ owner: { value: '0x456' } }] as SafeMessage['confirmations'], @@ -44,7 +44,7 @@ describe('useSafeMessageStatus', () => { it('should return the message status if the message is not pending and it is fully signed', () => { jest.spyOn(useIsSafeMessagePendingHook, 'default').mockImplementation(() => false) - jest.spyOn(useWalletHook, 'default').mockImplementation(() => ({ address: '0x123' } as ConnectedWallet)) + jest.spyOn(useWalletHook, 'default').mockImplementation(() => ({ address: '0x123' }) as ConnectedWallet) const message = { confirmations: [{ owner: { value: '0x123' } }] as SafeMessage['confirmations'], diff --git a/src/hooks/safe-apps/__tests__/useCategoryFilter.test.ts b/src/hooks/safe-apps/__tests__/useCategoryFilter.test.ts index 09864d9829..96b0d5e4c4 100644 --- a/src/hooks/safe-apps/__tests__/useCategoryFilter.test.ts +++ b/src/hooks/safe-apps/__tests__/useCategoryFilter.test.ts @@ -11,7 +11,7 @@ describe('useCategoryFilter', () => { }) it('should not set categories if there are none in the URL', () => { - jest.spyOn(nextRouter, 'useRouter').mockImplementation(() => ({ isReady: true, query: {} } as any)) + jest.spyOn(nextRouter, 'useRouter').mockImplementation(() => ({ isReady: true, query: {} }) as any) const mockSetter = jest.fn() @@ -25,7 +25,7 @@ describe('useCategoryFilter', () => { it('should not set categories if they are already set', () => { jest .spyOn(nextRouter, 'useRouter') - .mockImplementation(() => ({ isReady: true, query: { categories: 'Aggregator' } } as any)) + .mockImplementation(() => ({ isReady: true, query: { categories: 'Aggregator' } }) as any) const mockSetter = jest.fn() @@ -43,7 +43,7 @@ describe('useCategoryFilter', () => { it('should not set categories that do not exist', () => { jest .spyOn(nextRouter, 'useRouter') - .mockImplementation(() => ({ isReady: true, query: { categories: 'RandomCategory' } } as any)) + .mockImplementation(() => ({ isReady: true, query: { categories: 'RandomCategory' } }) as any) const mockSetter = jest.fn() @@ -61,7 +61,7 @@ describe('useCategoryFilter', () => { it('should set categories from the URL', () => { jest .spyOn(nextRouter, 'useRouter') - .mockImplementation(() => ({ isReady: true, query: { categories: 'DeFi' } } as any)) + .mockImplementation(() => ({ isReady: true, query: { categories: 'DeFi' } }) as any) const mockSetter = jest.fn() diff --git a/src/hooks/useTxNotifications.ts b/src/hooks/useTxNotifications.ts index c778e43d00..b1feb2202a 100644 --- a/src/hooks/useTxNotifications.ts +++ b/src/hooks/useTxNotifications.ts @@ -86,8 +86,8 @@ const useTxNotifications = (): void => { link: txId ? getTxLink(txId, chain, safeAddress) : txHash - ? getExplorerLink(txHash, chain.blockExplorerUriTemplate) - : undefined, + ? getExplorerLink(txHash, chain.blockExplorerUriTemplate) + : undefined, }), ) }), diff --git a/src/hooks/useVisibleBalances.ts b/src/hooks/useVisibleBalances.ts index f6b81f0dc5..0cf20252af 100644 --- a/src/hooks/useVisibleBalances.ts +++ b/src/hooks/useVisibleBalances.ts @@ -26,12 +26,15 @@ const filterHiddenTokens = (items: SafeBalanceResponse['items'], hiddenAssets: s const getVisibleFiatTotal = (balances: SafeBalanceResponse, hiddenAssets: string[]): string => { return safeFormatUnits( balances.items - .reduce((acc, balanceItem) => { - if (hiddenAssets.includes(balanceItem.tokenInfo.address)) { - return acc - BigInt(safeParseUnits(truncateNumber(balanceItem.fiatBalance), PRECISION) ?? 0) - } - return acc - }, BigInt(balances.fiatTotal === '' ? 0 : safeParseUnits(truncateNumber(balances.fiatTotal), PRECISION) ?? 0)) + .reduce( + (acc, balanceItem) => { + if (hiddenAssets.includes(balanceItem.tokenInfo.address)) { + return acc - BigInt(safeParseUnits(truncateNumber(balanceItem.fiatBalance), PRECISION) ?? 0) + } + return acc + }, + BigInt(balances.fiatTotal === '' ? 0 : (safeParseUnits(truncateNumber(balances.fiatTotal), PRECISION) ?? 0)), + ) .toString(), PRECISION, ) diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index 3e37351be6..9c1323045c 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -48,7 +48,6 @@ const getInitialProps = async (ctx: DocumentContext) => {