Skip to content

Commit cb141c0

Browse files
committed
fixed eslint tsconfig
1 parent 9ce3e69 commit cb141c0

File tree

6 files changed

+41
-38
lines changed

6 files changed

+41
-38
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
module.exports = {
33
root: true,
44
extends: [
5+
"@cs-magic/eslint-config/node",
56
"@cs-magic/eslint-config/typescript-type-checked",
6-
// "@cs-magic/eslint-config/prettier" // todo: compatiability test
7+
"@cs-magic/eslint-config/prettier", // todo: compatability test
78
],
89
parserOptions: {
910
project: true,
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
// base.js - 基础 JavaScript 规则
22
module.exports = {
3-
settings: {
4-
"import/resolver": {
5-
typescript: {
6-
alwaysTryTypes: true,
7-
// project: "./tsconfig.json",
8-
},
9-
},
10-
},
113
env: {
124
es2022: true,
13-
node: true,
145
},
6+
157
extends: ["eslint:recommended", "plugin:import/recommended"],
8+
169
rules: {
1710
"no-console": ["warn", { allow: ["warn", "error"] }],
1811
"no-debugger": "warn",
@@ -24,16 +17,24 @@ module.exports = {
2417
"error",
2518
{
2619
groups: ["builtin", "external", "internal", "parent", "sibling", "index"],
27-
"pathGroups": [
20+
pathGroups: [
2821
{
29-
"pattern": "contentlayer/generated",
30-
"group": "internal",
31-
"position": "after"
32-
}
22+
pattern: "contentlayer/generated",
23+
group: "internal",
24+
position: "after",
25+
},
3326
],
3427
"newlines-between": "always",
3528
alphabetize: { order: "asc" },
3629
},
3730
],
3831
},
32+
33+
settings: {
34+
"import/resolver": {
35+
typescript: {
36+
alwaysTryTypes: true, // project: "./tsconfig.json",
37+
},
38+
},
39+
},
3940
}

packages/tools/eslint-config/next.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@ module.exports = {
66
node: true,
77
},
88

9-
extends: [
10-
"plugin:@next/next/recommended",
11-
"./react.js",
12-
],
9+
extends: ["plugin:@next/next/recommended", "./react.js"],
1310
rules: {
1411
// Next.js 特定规则
1512
"@next/next/no-html-link-for-pages": "error",
1613
"@next/next/no-img-element": "error",
1714
},
18-
};
15+
}

packages/tools/eslint-config/node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// node.js - Node.js 配置
22
module.exports = {
3-
extends: ["./typescript.js"],
3+
extends: ["./base.js"],
44
env: {
5+
es2022: true,
56
node: true,
6-
browser: false,
77
},
88
rules: {
99
// Node.js 特定规则

packages/tools/eslint-config/react.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ module.exports = {
66
},
77

88
extends: [
9-
'eslint:recommended',
9+
"eslint:recommended",
1010
"plugin:react/recommended",
1111
"plugin:react-hooks/recommended",
1212
"plugin:jsx-a11y/recommended",
13-
"./typescript.js",
1413
],
1514
plugins: ["react", "jsx-a11y"],
1615
settings: {
@@ -20,10 +19,10 @@ module.exports = {
2019
},
2120
parserOptions: {
2221
ecmaFeatures: {
23-
jsx: true
22+
jsx: true,
2423
},
2524
ecmaVersion: 12,
26-
sourceType: 'module'
25+
sourceType: "module",
2726
},
2827
rules: {
2928
// React 规则
@@ -42,33 +41,33 @@ module.exports = {
4241
// JSX 可访问性
4342
"jsx-a11y/anchor-is-valid": "warn",
4443
"jsx-a11y/click-events-have-key-events": "warn",
45-
'jsx-a11y/heading-has-content': 'warn',
44+
"jsx-a11y/heading-has-content": "warn",
4645

4746
// 目前不会自动 fix
4847
// - [eslint-plugin-react/docs/rules/no-unescaped-entities.md at 4ef92b49ab70eacb913afa394209ac5a24522fad · jsx-eslint/eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/no-unescaped-entities.md)
4948
// - [autofix for no-unescaped-entities · Issue #1537 · jsx-eslint/eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react/issues/1537)
50-
'react/no-unescaped-entities': [
51-
'warn',
49+
"react/no-unescaped-entities": [
50+
"warn",
5251
{
5352
forbid: [
5453
{
5554
char: '"',
56-
alternatives: ['{"\\""}']
55+
alternatives: ['{"\\""}'],
5756
},
5857
{
5958
char: "'",
60-
alternatives: ["{'\\''}", "'"]
59+
alternatives: ["{'\\''}", "'"],
6160
},
6261
{
6362
char: ">",
64-
alternatives: [">"]
63+
alternatives: [">"],
6564
},
6665
{
6766
char: "}",
68-
alternatives: ["}"]
69-
}
70-
]
71-
}
72-
]
67+
alternatives: ["}"],
68+
},
69+
],
70+
},
71+
],
7372
},
74-
};
73+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// packages/tools/eslint-config/tsconfig.json
2+
{
3+
"extends": ["@cs-magic/ts-config"],
4+
"include": ["*.js"]
5+
}

0 commit comments

Comments
 (0)