Skip to content

Commit 47cce60

Browse files
committedApr 2, 2024·
all: update lint
1 parent 367a857 commit 47cce60

36 files changed

+636
-443
lines changed
 

‎.eslintrc.js

-90
This file was deleted.

‎eslint.config.mjs

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import eslint from '@eslint/js'
2+
import tseslint from 'typescript-eslint'
3+
4+
import nodePlugin from 'eslint-plugin-n'
5+
import sortImports from 'eslint-plugin-sort-imports-es6-autofix'
6+
import unusedImports from 'eslint-plugin-unused-imports'
7+
8+
export default tseslint.config(
9+
eslint.configs.recommended,
10+
...tseslint.configs.recommended,
11+
...tseslint.configs.recommendedTypeChecked,
12+
nodePlugin.configs["flat/recommended-script"],
13+
{
14+
languageOptions: {
15+
parserOptions: {
16+
// Explicitly require all modules being linted to have tsconfig.eslint.json
17+
project: ['./tsconfig.eslint.json'],
18+
tsconfigRootDir: import.meta.dirname,
19+
},
20+
},
21+
plugins: {
22+
unusedImports,
23+
sortImports,
24+
},
25+
rules: {
26+
// Explicit offs
27+
'@typescript-eslint/no-misused-promises': 'off',
28+
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
29+
'@typescript-eslint/require-await': 'off',
30+
'@typescript-eslint/restrict-template-expressions': 'off',
31+
'@typescript-eslint/no-base-to-string': 'off',
32+
'avoidEscape': 'off',
33+
'camelcase': 'off',
34+
'no-async-promise-executor': 'off',
35+
'no-unreachable-loop': 'off',
36+
'no-unused-vars': 'off',
37+
'no-constant-condition': 'off',
38+
39+
// Explicit warns
40+
'unusedImports/no-unused-imports': 'warn',
41+
'sortImports/sort-imports-es6': [1, {
42+
ignoreCase: false,
43+
ignoreMemberSort: false,
44+
memberSyntaxSortOrder: ['none', 'single', 'multiple', 'all']
45+
}],
46+
47+
// Explicit errors
48+
'array-callback-return': 'error',
49+
'block-scoped-var': 'error',
50+
'dot-notation': 'error',
51+
'new-cap': [2, { 'properties': false }], // Used by ethers event filters
52+
'no-empty': [2, { 'allowEmptyCatch': true }],
53+
'no-new': 'error',
54+
'prefer-const': [2, { 'destructuring': 'all' }],
55+
'n/no-new-require': 'error',
56+
'n/no-path-concat': 'error',
57+
// Note: for @typescript-eslint/return-await', you must disable the base rule as it can report incorrect errors
58+
'no-return-await': 'off',
59+
'@typescript-eslint/return-await': 'error',
60+
61+
// Custom - These allow `any`. Remove over time as codebase is cleaned up
62+
'@typescript-eslint/no-explicit-any': 'off',
63+
'@typescript-eslint/no-unsafe-assignment': 'off',
64+
'@typescript-eslint/no-unsafe-argument': 'off',
65+
'@typescript-eslint/no-unsafe-call': 'off',
66+
'@typescript-eslint/no-unsafe-member-access': 'off',
67+
'@typescript-eslint/no-unsafe-return': 'off',
68+
'@typescript-eslint/no-redundant-type-constituents': 'off',
69+
70+
// Custom - Set to 1 or 2 over time as codebase is cleaned up. Possibly add options
71+
'@typescript-eslint/prefer-nullish-coalescing': 'off',
72+
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
73+
'@typescript-eslint/no-unused-vars': 'off',
74+
'@typescript-eslint/no-floating-promises': 'off',
75+
// Could be a 1 but --fix does not correctly indent
76+
'no-else-return': 'off',
77+
// Could be a 1 but erroneously fixes nested items. Nesting is user error but still not worth the hassle
78+
// https://github.com/eslint/eslint/issues/3400
79+
'no-lonely-if': 'off',
80+
// Nice to have but need to clean up first
81+
'@typescript-eslint/no-unnecessary-condition': 0,
82+
// Remove when ethers v6 is used and we do not import entire ethers paths
83+
// Remove when asn1.js is updated to modern package
84+
'n/no-missing-import': [2, { 'allowModules': [ 'ethers', 'asn1.js' ] }],
85+
// Remove when ethers v6 is used and we do not import entire ethers paths
86+
// Remove when plugin supports workspaces
87+
// https://github.com/eslint-community/eslint-plugin-n/issues/209
88+
'n/no-extraneous-import': [2, {
89+
'allowModules': [
90+
'@ethersproject/abstract',
91+
'@ethersproject/abstract-provider',
92+
'@ethersproject/bignumber',
93+
'@ethersproject/networks',
94+
'@ethersproject/properties',
95+
'@ethersproject/web',
96+
'typescript-eslint'
97+
]
98+
}],
99+
// Remove when we have more graceful shutdown logic
100+
'n/no-process-exit': 0,
101+
},
102+
ignores: [
103+
'node_modules',
104+
'build',
105+
'dist'
106+
]
107+
}
108+
)

‎package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
"lint": "pnpm recursive run lint"
1717
},
1818
"devDependencies": {
19-
"@types/jest": "29.5.11",
20-
"@types/node": "20.11.8",
21-
"@typescript-eslint/eslint-plugin": "6.19.1",
22-
"@typescript-eslint/parser": "6.19.1",
23-
"eslint": "8.56.0",
24-
"eslint-plugin-n": "16.6.2",
19+
"@eslint/js": "8.57.0",
20+
"@types/jest": "29.5.12",
21+
"@types/node": "20.12.2",
22+
"eslint": "8.57.0",
23+
"eslint-plugin-n": "17.0.0-6",
2524
"eslint-plugin-sort-imports-es6-autofix": "0.6.0",
26-
"eslint-plugin-unused-imports": "3.0.0",
27-
"typescript": "5.4.3"
25+
"eslint-plugin-unused-imports": "3.1.0",
26+
"typescript": "5.4.3",
27+
"typescript-eslint": "7.5.0"
2828
}
2929
}

‎packages/api/.eslintrc.mjs

-15
This file was deleted.

‎packages/api/eslint.config.mjs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import baseConfig from '../../eslint.config.mjs'
2+
import tseslint from 'typescript-eslint'
3+
4+
export default tseslint.config(
5+
...baseConfig,
6+
{
7+
// Ignore TS rules in JS files
8+
files: ['src/**/*.js'],
9+
rules: {
10+
'@typescript-eslint/no-var-requires': 'off'
11+
}
12+
}
13+
)

‎packages/api/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"start": "node dist/index.js",
1414
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
1515
"build": "tsc",
16-
"lint": "eslint . --ext .ts --fix"
16+
"lint": "eslint . --config ./eslint.config.mjs --fix"
1717
},
1818
"dependencies": {
1919
"@hop-protocol/sdk": "workspace:*",

‎packages/api/src/tsconfig.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
}

‎packages/api/tsconfig.eslint.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./src/tsconfig.json"
3+
}

‎packages/hop-node-core/.eslintrc.mjs

-5
This file was deleted.
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import baseConfig from '../../eslint.config.mjs'
2+
import tseslint from 'typescript-eslint'
3+
4+
export default tseslint.config(
5+
...baseConfig
6+
)

‎packages/hop-node-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"clean": "rm -rf node_modules dist ./tsconfig.tsbuildinfo",
8787
"test": "tsc -b ./test/tsconfig.json && node --experimental-vm-modules node_modules/jest/bin/jest.js",
8888
"build": "tsc -b ./src/tsconfig.json",
89-
"lint": "eslint . --ext .ts --fix"
89+
"lint": "eslint . --config ./eslint.config.mjs"
9090
},
9191
"//": "@maticnetwork/maticjs-ethers requires 3.5.0 of @maticnetwork/maticjs but 3.7.7 is needed for zkEVM compatibility as well as general compatibility",
9292
"dependencies": {

‎packages/hop-node-core/test/getBumpedBN.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { getBumpedBN } from '#utils/getBumpedBN.js'
21
import { BigNumber } from 'ethers'
2+
import { getBumpedBN } from '#utils/getBumpedBN.js'
33

44
test('getBumpedBN', () => {
55
expect(getBumpedBN(BigNumber.from('20'), 1.5).toString()).toBe(BigNumber.from('30').toString())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./src/tsconfig.json"
3+
}

‎packages/hop-node/.eslintrc.mjs

-5
This file was deleted.

‎packages/hop-node/eslint.config.mjs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import baseConfig from '../../eslint.config.mjs'
2+
import tseslint from 'typescript-eslint'
3+
4+
export default tseslint.config(
5+
...baseConfig
6+
)

‎packages/hop-node/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"start": "node ./dist/cli/cli.js",
3030
"dev": "pnpm start",
3131
"build": "tsc -p tsconfig.json",
32-
"lint": "eslint . --ext .ts --fix"
32+
"lint": "eslint . --config ./eslint.config.mjs"
3333
},
3434
"dependencies": {
3535
"@arbitrum/sdk": "2.0.18",

‎packages/hop-node/src/tsconfig.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../tsconfig.base.json",
3+
}
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./src/tsconfig.json"
3+
}

‎packages/sdk-core/.eslintrc.mjs

-5
This file was deleted.

‎packages/sdk-core/eslint.config.mjs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import baseConfig from '../../eslint.config.mjs'
2+
import tseslint from 'typescript-eslint'
3+
4+
export default tseslint.config(
5+
...baseConfig
6+
)

‎packages/sdk-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"build:all": "pnpm build:cjs && pnpm build:esm",
2121
"clean:docs": "rm -rf docs",
2222
"clean:docs-ui": "rm -rf docs-ui",
23-
"lint": "eslint . --ext .ts --fix",
23+
"lint": "eslint . --config ./eslint.config.mjs --fix",
2424
"version": "echo \"export default '$(cat package.json | jq -r '.version')'\" > src/version.ts",
2525
"bump": "pnpm version prerelease --preid=beta",
2626
"release": "pnpm build && pnpm lint && pnpm test && pnpm bump",

‎packages/sdk-core/src/tsconfig.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
}
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./src/tsconfig.json"
3+
}

‎packages/sdk/.eslintrc.js

-5
This file was deleted.

‎packages/sdk/eslint.config.mjs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import baseConfig from '../../eslint.config.mjs'
2+
import tseslint from 'typescript-eslint'
3+
4+
export default tseslint.config(
5+
...baseConfig
6+
)

‎packages/sdk/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"build:browser": "esbuild dist/cjs/index.js --bundle --minify --platform=browser --outfile=hop.js",
2121
"clean:docs": "rm -rf docs",
2222
"clean:docs-ui": "rm -rf docs-ui",
23-
"lint": "eslint . --ext .ts --fix",
23+
"lint": "eslint . --config ./eslint.config.mjs --fix",
2424
"version": "echo \"export default '$(cat package.json | jq -r '.version')'\" > src/version.ts",
2525
"bump": "pnpm version prerelease --preid=beta",
2626
"release": "pnpm build && pnpm lint && pnpm test && pnpm bump",

0 commit comments

Comments
 (0)
Please sign in to comment.