Skip to content

Commit a4031d8

Browse files
committed
fix: align TypeScript and ESLint compatibility
1 parent 4fac652 commit a4031d8

3 files changed

Lines changed: 27 additions & 27 deletions

File tree

eslint.config.mjs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ const compat = new FlatCompat({
1515
allConfig: js.configs.all,
1616
});
1717

18-
const recommendedTsRules = new Set(Object.keys(tsEslintPlugin.configs.recommended.rules || {}));
18+
const recommendedTsRules = new Set(
19+
Object.keys(tsEslintPlugin.configs.recommended.rules || {}),
20+
);
1921
const noopRule = {
2022
meta: { type: 'problem', docs: {}, schema: [] },
2123
create: () => ({}),
@@ -25,16 +27,8 @@ function normalizeConfig(config) {
2527
const next = { ...config };
2628

2729
if (next.plugins?.['@typescript-eslint']) {
28-
next.plugins = {
29-
...next.plugins,
30-
'@typescript-eslint': {
31-
...next.plugins['@typescript-eslint'],
32-
rules: {
33-
...next.plugins['@typescript-eslint'].rules,
34-
'ban-types': noopRule,
35-
},
36-
},
37-
};
30+
next.plugins = { ...next.plugins };
31+
delete next.plugins['@typescript-eslint'];
3832
}
3933

4034
if (next.rules) {
@@ -43,7 +37,10 @@ function normalizeConfig(config) {
4337
if (!ruleName.startsWith('@typescript-eslint/')) {
4438
return true;
4539
}
46-
return recommendedTsRules.has(ruleName) || ruleName === '@typescript-eslint/ban-types';
40+
return (
41+
recommendedTsRules.has(ruleName) ||
42+
ruleName === '@typescript-eslint/ban-types'
43+
);
4744
}),
4845
);
4946
}
@@ -67,6 +64,18 @@ export default [
6764
'src/index.d.ts',
6865
],
6966
},
67+
{
68+
plugins: {
69+
'@typescript-eslint': {
70+
...tsEslintPlugin,
71+
rules: {
72+
...tsEslintPlugin.rules,
73+
'ban-types': noopRule,
74+
'consistent-type-exports': noopRule,
75+
},
76+
},
77+
},
78+
},
7079
...compat.config(require('./.eslintrc.js')).map(normalizeConfig),
7180
{
7281
rules: {

global.d.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,5 @@ declare const vi: {
4444
restoreAllMocks: () => void;
4545
};
4646

47-
declare const describe: any;
48-
declare const it: any;
49-
declare const test: any;
50-
declare const beforeEach: any;
51-
declare const afterEach: any;
52-
declare const beforeAll: any;
53-
declare const afterAll: any;
54-
declare const expect: any;
5547

5648
declare module 'moment/locale/zh-cn';

tsconfig.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
{
22
"compilerOptions": {
33
"target": "esnext",
4-
"moduleResolution": "node",
5-
"baseUrl": "./",
4+
"moduleResolution": "bundler",
65
"jsx": "react",
76
"declaration": true,
87
"skipLibCheck": true,
98
"esModuleInterop": true,
109
"paths": {
1110
"@/*": [
12-
"src/*"
11+
"./src/*"
1312
],
1413
"@@/*": [
15-
".dumi/tmp/*"
14+
"./.dumi/tmp/*"
1615
],
1716
"@rc-component/image": [
18-
"src/index.ts"
17+
"./src/index.ts"
1918
]
2019
},
21-
"ignoreDeprecations": "6.0",
2220
"noImplicitAny": false,
2321
"strictNullChecks": false,
2422
"strictPropertyInitialization": false,
2523
"strictFunctionTypes": false,
2624
"strict": false,
2725
"noImplicitThis": false,
28-
"strictBindCallApply": false
26+
"strictBindCallApply": false,
27+
"module": "ESNext"
2928
},
3029
"include": [
3130
"react-compat.d.ts",

0 commit comments

Comments
 (0)