Skip to content

Commit a99b106

Browse files
authored
chore: migrate more linting rules from ESLint to oxlint (#8353)
1 parent c44b5b2 commit a99b106

52 files changed

Lines changed: 581 additions & 810 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eslint.config.mjs

Lines changed: 4 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -1,209 +1,5 @@
1-
import { FlatCompat } from '@eslint/eslintrc';
2-
import js from '@eslint/js';
3-
import typescriptEslint from '@typescript-eslint/eslint-plugin';
4-
import tsParser from '@typescript-eslint/parser';
5-
import importPlugin from 'eslint-plugin-import';
6-
import jest from 'eslint-plugin-jest';
7-
import oxlint from 'eslint-plugin-oxlint';
8-
import globals from 'globals';
9-
import path from 'node:path';
10-
import { fileURLToPath } from 'node:url';
1+
// Root ESLint config — all packages use @hyperlane-xyz/eslint-config directly.
2+
// This file exists only for editor tooling that auto-discovers a root config.
3+
import { defaultConfig } from '@hyperlane-xyz/eslint-config';
114

12-
const __filename = fileURLToPath(import.meta.url);
13-
const __dirname = path.dirname(__filename);
14-
export const compat = new FlatCompat({
15-
baseDirectory: __dirname,
16-
recommendedConfig: js.configs.recommended,
17-
allConfig: js.configs.all,
18-
});
19-
20-
export default [
21-
{
22-
ignores: [
23-
'**/node_modules',
24-
'**/dist',
25-
'**/bundle',
26-
'**/coverage',
27-
'**/*.cjs',
28-
'**/*.cts',
29-
'**/*.mjs',
30-
'jest.config.js',
31-
],
32-
},
33-
...compat.extends(
34-
'eslint:recommended',
35-
'plugin:import/recommended',
36-
'plugin:import/typescript',
37-
'plugin:@typescript-eslint/recommended',
38-
'prettier',
39-
),
40-
{
41-
plugins: {
42-
import: importPlugin,
43-
'@typescript-eslint': typescriptEslint,
44-
jest,
45-
},
46-
47-
languageOptions: {
48-
globals: {
49-
...globals.node,
50-
...globals.browser,
51-
},
52-
53-
parser: tsParser,
54-
ecmaVersion: 12,
55-
sourceType: 'module',
56-
57-
parserOptions: {
58-
project: './tsconfig.json',
59-
},
60-
},
61-
62-
settings: {
63-
'import/resolver': {
64-
typescript: true,
65-
node: true,
66-
},
67-
},
68-
69-
rules: {
70-
'guard-for-in': ['error'],
71-
'import/no-cycle': ['error'],
72-
'import/no-self-import': ['error'],
73-
'import/no-named-as-default-member': ['off'],
74-
'no-console': ['error'],
75-
'no-eval': ['error'],
76-
'no-extra-boolean-cast': ['error'],
77-
'no-ex-assign': ['error'],
78-
'no-constant-condition': ['off'],
79-
'no-return-await': ['error'],
80-
81-
'no-restricted-imports': [
82-
'error',
83-
{
84-
name: 'console',
85-
message: 'Please use a logger and/or the utils package assert',
86-
},
87-
],
88-
89-
'@typescript-eslint/ban-ts-comment': ['off'],
90-
'@typescript-eslint/explicit-module-boundary-types': ['off'],
91-
'@typescript-eslint/no-explicit-any': ['off'],
92-
'@typescript-eslint/no-floating-promises': ['error'],
93-
'@typescript-eslint/no-non-null-assertion': ['off'],
94-
'@typescript-eslint/no-require-imports': ['warn'],
95-
'@typescript-eslint/no-unused-expressions': ['off'],
96-
'@typescript-eslint/no-empty-object-type': ['off'],
97-
'@typescript-eslint/no-unused-vars': [
98-
'error',
99-
{
100-
argsIgnorePattern: '^_',
101-
varsIgnorePattern: '^_',
102-
caughtErrorsIgnorePattern: '^_',
103-
},
104-
],
105-
106-
'jest/no-disabled-tests': 'warn',
107-
'jest/no-focused-tests': 'error',
108-
'jest/no-identical-title': 'error',
109-
'jest/prefer-to-have-length': 'warn',
110-
'jest/valid-expect': 'error',
111-
},
112-
},
113-
114-
{
115-
files: ['**/*.ts', '**/*.js', '**/*.mjs'],
116-
ignores: ['**/aws/**/*', '**/test/**/*', '**/*.test.ts'],
117-
rules: {
118-
'no-restricted-imports': [
119-
'error',
120-
{
121-
paths: [
122-
{
123-
name: 'fs',
124-
message:
125-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
126-
},
127-
{
128-
name: 'path',
129-
message:
130-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
131-
},
132-
{
133-
name: 'child_process',
134-
message:
135-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
136-
},
137-
{
138-
name: 'os',
139-
message:
140-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
141-
},
142-
{
143-
name: 'process',
144-
message:
145-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
146-
},
147-
{
148-
name: 'http',
149-
message:
150-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
151-
},
152-
{
153-
name: 'https',
154-
message:
155-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
156-
},
157-
{
158-
name: 'net',
159-
message:
160-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
161-
},
162-
{
163-
name: 'dgram',
164-
message:
165-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
166-
},
167-
{
168-
name: 'dns',
169-
message:
170-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
171-
},
172-
{
173-
name: 'crypto',
174-
message:
175-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
176-
},
177-
{
178-
name: 'tls',
179-
message:
180-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
181-
},
182-
{
183-
name: 'cluster',
184-
message:
185-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
186-
},
187-
{
188-
name: 'stream',
189-
message:
190-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
191-
},
192-
{
193-
name: 'vm',
194-
message:
195-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
196-
},
197-
{
198-
name: 'readline',
199-
message:
200-
'Avoid Node.js built-in modules in cross-platform code. Use environment-agnostic alternatives.',
201-
},
202-
],
203-
},
204-
],
205-
},
206-
},
207-
// Disable ESLint rules that oxlint handles
208-
...oxlint.configs['flat/recommended'],
209-
];
5+
export default defaultConfig;

oxlint.json

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"$schema": "./node_modules/oxlint/configuration_schema.json",
33
"plugins": ["import", "typescript", "unicorn", "jest"],
4+
"options": {
5+
"typeAware": true
6+
},
47
"categories": {
58
"correctness": "error"
69
},
@@ -69,7 +72,32 @@
6972
"jest/valid-title": "off",
7073
"jest/valid-describe-callback": "warn",
7174
"jest/no-conditional-expect": "warn",
72-
"jest/no-export": "warn"
75+
"jest/no-export": "warn",
76+
77+
"@typescript-eslint/no-floating-promises": "error",
78+
"@typescript-eslint/await-thenable": "error",
79+
"@typescript-eslint/no-for-in-array": "error",
80+
"@typescript-eslint/no-implied-eval": "error",
81+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
82+
"@typescript-eslint/restrict-plus-operands": "error",
83+
"@typescript-eslint/restrict-template-expressions": "error",
84+
"@typescript-eslint/unbound-method": "error",
85+
"@typescript-eslint/no-base-to-string": "error",
86+
"@typescript-eslint/only-throw-error": "error",
87+
"@typescript-eslint/prefer-promise-reject-errors": "error",
88+
"@typescript-eslint/no-duplicate-type-constituents": "error",
89+
"@typescript-eslint/no-redundant-type-constituents": "error",
90+
"@typescript-eslint/consistent-type-imports": "off",
91+
"@typescript-eslint/require-await": "off",
92+
"@typescript-eslint/no-misused-promises": "off",
93+
"@typescript-eslint/no-unsafe-argument": "off",
94+
"@typescript-eslint/no-unsafe-assignment": "off",
95+
"@typescript-eslint/no-unsafe-call": "off",
96+
"@typescript-eslint/no-unsafe-enum-comparison": "off",
97+
"@typescript-eslint/no-unsafe-member-access": "off",
98+
"@typescript-eslint/no-unsafe-return": "off",
99+
"@typescript-eslint/require-array-sort-compare": "off",
100+
"@typescript-eslint/no-misused-spread": "off"
73101
},
74102
"globals": {
75103
"AudioWorkletGlobalScope": "readonly",
@@ -107,6 +135,12 @@
107135
"no-console": "off"
108136
}
109137
},
138+
{
139+
"files": ["**/scripts/**", "typescript/infra/src/**/*.ts"],
140+
"rules": {
141+
"@typescript-eslint/no-floating-promises": "off"
142+
}
143+
},
110144
{
111145
"files": [
112146
"typescript/sdk/src/**/*.ts",
@@ -194,6 +228,85 @@
194228
"import/no-nodejs-modules": "off",
195229
"no-restricted-imports": "off"
196230
}
231+
},
232+
{
233+
"files": [
234+
"typescript/aleo-sdk/src/**/*.ts",
235+
"typescript/ccip-server/src/**/*.ts",
236+
"typescript/cli/src/**/*.ts",
237+
"typescript/cosmos-sdk/src/**/*.ts",
238+
"typescript/github-proxy/**/*.ts",
239+
"typescript/helloworld/src/**/*.ts",
240+
"typescript/http-registry-server/**/*.ts",
241+
"typescript/infra/**/*.ts",
242+
"typescript/radix-sdk/src/**/*.ts",
243+
"typescript/rebalancer/src/**/*.ts",
244+
"typescript/rebalancer-sim/src/**/*.ts",
245+
"typescript/sdk/src/**/*.ts",
246+
"typescript/svm-sdk/src/**/*.ts",
247+
"typescript/tron-sdk/src/**/*.ts",
248+
"typescript/utils/src/**/*.ts",
249+
"typescript/widgets/src/**/*.{ts,tsx}",
250+
"starknet/**/*.ts"
251+
],
252+
"rules": {
253+
"@typescript-eslint/await-thenable": "off",
254+
"@typescript-eslint/no-base-to-string": "off",
255+
"@typescript-eslint/no-duplicate-type-constituents": "off",
256+
"@typescript-eslint/no-redundant-type-constituents": "off",
257+
"@typescript-eslint/no-unnecessary-type-assertion": "off",
258+
"@typescript-eslint/restrict-template-expressions": "off",
259+
"@typescript-eslint/unbound-method": "off"
260+
}
261+
},
262+
{
263+
"files": ["typescript/relayer/src/**/*.ts"],
264+
"rules": {
265+
"@typescript-eslint/no-base-to-string": "off",
266+
"@typescript-eslint/restrict-template-expressions": "off"
267+
}
268+
},
269+
{
270+
"files": [
271+
"typescript/cli/**/*.ts",
272+
"typescript/svm-sdk/src/**/*.ts",
273+
"typescript/cosmos-sdk/src/**/*.ts",
274+
"typescript/aleo-sdk/src/**/*.ts"
275+
],
276+
"rules": {
277+
"@typescript-eslint/consistent-type-imports": [
278+
"error",
279+
{
280+
"prefer": "type-imports",
281+
"fixStyle": "inline-type-imports"
282+
}
283+
]
284+
}
285+
},
286+
{
287+
"files": ["typescript/widgets/src/**/*.{ts,tsx}"],
288+
"plugins": ["react"],
289+
"rules": {
290+
"react/rules-of-hooks": "error",
291+
"react/jsx-key": "error",
292+
"react/jsx-no-duplicate-props": "error",
293+
"react/jsx-no-undef": "error",
294+
"react/no-children-prop": "error",
295+
"react/no-danger-with-children": "error",
296+
"react/no-direct-mutation-state": "error",
297+
"react/no-find-dom-node": "error",
298+
"react/no-is-mounted": "error",
299+
"react/no-render-return-value": "error",
300+
"react/no-string-refs": "error",
301+
"react/no-unescaped-entities": "error",
302+
"react/no-unknown-property": "error",
303+
"react/require-render-return": "error",
304+
"react/exhaustive-deps": "warn",
305+
"react/display-name": "warn",
306+
"react/jsx-no-target-blank": "warn",
307+
"react/jsx-no-comment-textnodes": "warn",
308+
"react/react-in-jsx-scope": "off"
309+
}
197310
}
198311
]
199312
}

package.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,13 @@
2626
"@changesets/cli": "^2.26.2"
2727
},
2828
"devDependencies": {
29-
"@eslint/eslintrc": "^3.2.0",
30-
"@eslint/js": "catalog:",
31-
"@typescript-eslint/eslint-plugin": "catalog:",
32-
"@typescript-eslint/parser": "catalog:",
29+
"@hyperlane-xyz/eslint-config": "workspace:*",
3330
"eslint": "catalog:",
34-
"eslint-config-prettier": "catalog:",
35-
"eslint-import-resolver-typescript": "catalog:",
36-
"eslint-plugin-import": "catalog:",
37-
"eslint-plugin-jest": "^28.2.0",
38-
"eslint-plugin-oxlint": "catalog:",
39-
"globals": "catalog:",
4031
"husky": "^8.0.0",
4132
"lint-staged": "^15.5.2",
4233
"oxfmt": "catalog:",
4334
"oxlint": "catalog:",
35+
"oxlint-tsgolint": "catalog:",
4436
"prettier": "catalog:",
4537
"prettier-plugin-solidity": "catalog:",
4638
"tsx": "catalog:",

0 commit comments

Comments
 (0)