Skip to content

Commit 4517fcc

Browse files
committed
chore: fix upgraded test tooling
1 parent 5cb68b8 commit 4517fcc

2 files changed

Lines changed: 74 additions & 1 deletion

File tree

eslint.config.mjs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { FlatCompat } from '@eslint/eslintrc';
2+
import js from '@eslint/js';
3+
import tsEslintPlugin from '@typescript-eslint/eslint-plugin';
4+
import { createRequire } from 'node:module';
5+
import path from 'node:path';
6+
import { fileURLToPath } from 'node:url';
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
const require = createRequire(import.meta.url);
11+
12+
const compat = new FlatCompat({
13+
baseDirectory: __dirname,
14+
recommendedConfig: js.configs.recommended,
15+
allConfig: js.configs.all,
16+
});
17+
18+
const supportedTsRules = new Set(
19+
Object.keys(tsEslintPlugin.rules).map(ruleName => `@typescript-eslint/${ruleName}`),
20+
);
21+
22+
function normalizeConfig(config) {
23+
const next = { ...config };
24+
25+
if (next.rules) {
26+
next.rules = Object.fromEntries(
27+
Object.entries(next.rules).filter(([ruleName]) => {
28+
if (ruleName.startsWith('@babel/')) {
29+
return false;
30+
}
31+
return !ruleName.startsWith('@typescript-eslint/') || supportedTsRules.has(ruleName);
32+
}),
33+
);
34+
}
35+
36+
return next;
37+
}
38+
39+
export default [
40+
{
41+
ignores: [
42+
'node_modules/',
43+
'coverage/',
44+
'es/',
45+
'lib/',
46+
'dist/',
47+
'docs-dist/',
48+
'.dumi/',
49+
'.doc/',
50+
'.vercel/',
51+
'.eslintrc.js',
52+
],
53+
},
54+
...compat.config(require('./.eslintrc.js')).map(normalizeConfig),
55+
{
56+
rules: {
57+
'@typescript-eslint/no-empty-object-type': 'off',
58+
'@typescript-eslint/no-unsafe-function-type': 'off',
59+
'@typescript-eslint/no-unused-vars': 'off',
60+
'@typescript-eslint/no-useless-constructor': 'off',
61+
'@typescript-eslint/consistent-indexed-object-style': 'off',
62+
},
63+
},
64+
];

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,16 @@
5959
"react": "^19.2.7",
6060
"react-dom": "^19.2.7",
6161
"rc-test": "^7.1.3",
62-
"typescript": "^6.0.3"
62+
"typescript": "^6.0.3",
63+
"@eslint/eslintrc": "^3.3.5",
64+
"@eslint/js": "^9.39.4",
65+
"@typescript-eslint/eslint-plugin": "^8.62.1",
66+
"@typescript-eslint/parser": "^8.62.1",
67+
"eslint-plugin-import": "^2.32.0",
68+
"eslint-plugin-jest": "^29.15.4",
69+
"eslint-plugin-jsx-a11y": "^6.10.2",
70+
"eslint-plugin-react": "^7.37.5",
71+
"eslint-plugin-react-hooks": "^7.1.1"
6372
},
6473
"engines": {
6574
"node": ">=8.x"

0 commit comments

Comments
 (0)