Skip to content

Commit

Permalink
chore: update eslint to v9
Browse files Browse the repository at this point in the history
  • Loading branch information
compojoom committed Nov 6, 2024
1 parent 272f506 commit 056618b
Show file tree
Hide file tree
Showing 40 changed files with 384 additions and 341 deletions.
45 changes: 0 additions & 45 deletions .eslintrc.json

This file was deleted.

77 changes: 77 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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',
},
],
},
},
]
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('SafeTokenWidget', () => {
() =>
({
get: () => fakeSafeAddress,
} as any),
}) as any,
)

jest.spyOn(safePass, 'useGetOwnGlobalCampaignRankQuery').mockReturnValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
20 changes: 10 additions & 10 deletions src/components/settings/FallbackHandler/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('FallbackHandler', () => {
name: 'FallbackHandlerName',
},
},
} as unknown as ReturnType<typeof useSafeInfoHook.default>),
}) as unknown as ReturnType<typeof useSafeInfoHook.default>,
)

const fbHandler = render(<FallbackHandler />, {
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('FallbackHandler', () => {
name: 'FallbackHandlerName',
},
},
} as unknown as ReturnType<typeof useSafeInfoHook.default>),
}) as unknown as ReturnType<typeof useSafeInfoHook.default>,
)

const fbHandler = render(<FallbackHandler />, {
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('FallbackHandler', () => {
value: GOERLI_FALLBACK_HANDLER,
},
},
} as unknown as ReturnType<typeof useSafeInfoHook.default>),
}) as unknown as ReturnType<typeof useSafeInfoHook.default>,
)

const fbHandler = render(<FallbackHandler />, {
Expand All @@ -125,7 +125,7 @@ describe('FallbackHandler', () => {
version: '1.3.0',
chainId: '5',
},
} as unknown as ReturnType<typeof useSafeInfoHook.default>),
}) as unknown as ReturnType<typeof useSafeInfoHook.default>,
)

const fbHandler = render(<FallbackHandler />)
Expand All @@ -150,7 +150,7 @@ describe('FallbackHandler', () => {
version: '1.3.0',
chainId: '5',
},
} as unknown as ReturnType<typeof useSafeInfoHook.default>),
}) as unknown as ReturnType<typeof useSafeInfoHook.default>,
)

const fbHandler = render(<FallbackHandler />)
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('FallbackHandler', () => {
value: '0x123',
},
},
} as unknown as ReturnType<typeof useSafeInfoHook.default>),
}) as unknown as ReturnType<typeof useSafeInfoHook.default>,
)

const fbHandler = render(<FallbackHandler />)
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('FallbackHandler', () => {
value: '0x123',
},
},
} as unknown as ReturnType<typeof useSafeInfoHook.default>),
}) as unknown as ReturnType<typeof useSafeInfoHook.default>,
)

const fbHandler = render(<FallbackHandler />)
Expand All @@ -232,7 +232,7 @@ describe('FallbackHandler', () => {
version: '1.0.0',
chainId: '5',
},
} as unknown as ReturnType<typeof useSafeInfoHook.default>),
}) as unknown as ReturnType<typeof useSafeInfoHook.default>,
)

const fbHandler = render(<FallbackHandler />)
Expand All @@ -251,7 +251,7 @@ describe('FallbackHandler', () => {
value: TWAP_FALLBACK_HANDLER,
},
},
} as unknown as ReturnType<typeof useSafeInfoHook.default>),
}) as unknown as ReturnType<typeof useSafeInfoHook.default>,
)

const { getByText } = render(<FallbackHandler />)
Expand All @@ -274,7 +274,7 @@ describe('FallbackHandler', () => {
value: TWAP_FALLBACK_HANDLER,
},
},
} as unknown as ReturnType<typeof useSafeInfoHook.default>),
}) as unknown as ReturnType<typeof useSafeInfoHook.default>,
)

const { queryByText } = render(<FallbackHandler />)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('useNotificationRegistrations', () => {
() =>
({
label: 'MetaMask',
} as ConnectedWallet),
}) as ConnectedWallet,
)
})

Expand Down Expand Up @@ -75,7 +75,7 @@ describe('useNotificationRegistrations', () => {
() =>
({
uuid: undefined,
} as unknown as ReturnType<typeof preferences.useNotificationPreferences>),
}) as unknown as ReturnType<typeof preferences.useNotificationPreferences>,
)

const { result } = renderHook(() => useNotificationRegistrations())
Expand Down Expand Up @@ -105,7 +105,7 @@ describe('useNotificationRegistrations', () => {
({
uuid: self.crypto.randomUUID(),
createPreferences: createPreferencesMock,
} as unknown as ReturnType<typeof preferences.useNotificationPreferences>),
}) as unknown as ReturnType<typeof preferences.useNotificationPreferences>,
)

const { result } = renderHook(() => useNotificationRegistrations())
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('useNotificationRegistrations', () => {
({
uuid: self.crypto.randomUUID(),
createPreferences: createPreferencesMock,
} as unknown as ReturnType<typeof preferences.useNotificationPreferences>),
}) as unknown as ReturnType<typeof preferences.useNotificationPreferences>,
)

const { result } = renderHook(() => useNotificationRegistrations())
Expand Down Expand Up @@ -168,7 +168,7 @@ describe('useNotificationRegistrations', () => {
({
uuid: self.crypto.randomUUID(),
createPreferences: createPreferencesMock,
} as unknown as ReturnType<typeof preferences.useNotificationPreferences>),
}) as unknown as ReturnType<typeof preferences.useNotificationPreferences>,
)

const showNotificationSpy = jest.spyOn(notificationsSlice, 'showNotification')
Expand Down Expand Up @@ -197,7 +197,7 @@ describe('useNotificationRegistrations', () => {
() =>
({
uuid: undefined,
} as unknown as ReturnType<typeof preferences.useNotificationPreferences>),
}) as unknown as ReturnType<typeof preferences.useNotificationPreferences>,
)

const { result } = renderHook(() => useNotificationRegistrations())
Expand All @@ -219,7 +219,7 @@ describe('useNotificationRegistrations', () => {
({
uuid,
deletePreferences: deletePreferencesMock,
} as unknown as ReturnType<typeof preferences.useNotificationPreferences>),
}) as unknown as ReturnType<typeof preferences.useNotificationPreferences>,
)

const { result } = renderHook(() => useNotificationRegistrations())
Expand All @@ -245,7 +245,7 @@ describe('useNotificationRegistrations', () => {
({
uuid,
deletePreferences: deletePreferencesMock,
} as unknown as ReturnType<typeof preferences.useNotificationPreferences>),
}) as unknown as ReturnType<typeof preferences.useNotificationPreferences>,
)

const { result } = renderHook(() => useNotificationRegistrations())
Expand All @@ -271,7 +271,7 @@ describe('useNotificationRegistrations', () => {
({
uuid,
deletePreferences: deletePreferencesMock,
} as unknown as ReturnType<typeof preferences.useNotificationPreferences>),
}) as unknown as ReturnType<typeof preferences.useNotificationPreferences>,
)

const { result } = renderHook(() => useNotificationRegistrations())
Expand All @@ -295,7 +295,7 @@ describe('useNotificationRegistrations', () => {
() =>
({
uuid: undefined,
} as unknown as ReturnType<typeof preferences.useNotificationPreferences>),
}) as unknown as ReturnType<typeof preferences.useNotificationPreferences>,
)

const { result } = renderHook(() => useNotificationRegistrations())
Expand All @@ -317,7 +317,7 @@ describe('useNotificationRegistrations', () => {
({
uuid,
deleteAllChainPreferences: deleteAllChainPreferencesMock,
} as unknown as ReturnType<typeof preferences.useNotificationPreferences>),
}) as unknown as ReturnType<typeof preferences.useNotificationPreferences>,
)

const { result } = renderHook(() => useNotificationRegistrations())
Expand All @@ -340,7 +340,7 @@ describe('useNotificationRegistrations', () => {
({
uuid,
deleteAllChainPreferences: deleteAllChainPreferencesMock,
} as unknown as ReturnType<typeof preferences.useNotificationPreferences>),
}) as unknown as ReturnType<typeof preferences.useNotificationPreferences>,
)

const { result } = renderHook(() => useNotificationRegistrations())
Expand All @@ -363,7 +363,7 @@ describe('useNotificationRegistrations', () => {
({
uuid,
deleteAllChainPreferences: deleteAllChainPreferencesMock,
} as unknown as ReturnType<typeof preferences.useNotificationPreferences>),
}) as unknown as ReturnType<typeof preferences.useNotificationPreferences>,
)

const { result } = renderHook(() => useNotificationRegistrations())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Loading

0 comments on commit 056618b

Please sign in to comment.