Skip to content

Commit ce9e4dc

Browse files
committed
fix: align TypeScript and ESLint compatibility
1 parent 8a11d3d commit ce9e4dc

3 files changed

Lines changed: 30 additions & 30 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: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
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
"allowSyntheticDefaultImports": true,
1110
"paths": {
1211
"@/*": [
13-
"src/*"
12+
"./src/*"
1413
],
1514
"@@/*": [
16-
".dumi/tmp/*"
15+
"./.dumi/tmp/*"
1716
],
1817
"@rc-component/trigger": [
19-
"src/index.tsx"
18+
"./src/index.tsx"
2019
],
2120
"@rc-component/trigger/es": [
22-
"src"
21+
"./src"
2322
],
2423
"@rc-component/trigger/es/*": [
25-
"src/*"
24+
"./src/*"
2625
],
2726
"@rc-component/trigger/assets/*": [
28-
"assets/*"
27+
"./assets/*"
2928
]
3029
},
31-
"ignoreDeprecations": "6.0",
3230
"noImplicitAny": false,
3331
"strictNullChecks": false,
3432
"strictPropertyInitialization": false,
3533
"strictFunctionTypes": false,
3634
"strict": false,
3735
"noImplicitThis": false,
38-
"strictBindCallApply": false
36+
"strictBindCallApply": false,
37+
"module": "ESNext"
3938
},
4039
"include": [
4140
"react-compat.d.ts",

0 commit comments

Comments
 (0)