Skip to content

Commit feee481

Browse files
committed
chore: 更新 ESLint 配置,将规则的警告级别从字符串形式改为数字形式,简化配置
1 parent a79b77f commit feee481

File tree

4 files changed

+30
-27
lines changed

4 files changed

+30
-27
lines changed

src/eslint/base.mjs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ export default [
2020

2121
{
2222
rules: {
23-
curly: 'warn',
24-
'no-unused-vars': 'warn',
25-
eqeqeq: ['warn', 'always'],
26-
'no-console': 'warn',
23+
curly: 1,
24+
'no-unused-vars': 1,
25+
eqeqeq: [1, 'always'],
26+
'no-console': [1, { allow: ['warn', 'error'] }],
2727

28-
'@stylistic/array-bracket-newline': ['warn', { multiline: true }],
28+
'@stylistic/array-bracket-newline': [1, { multiline: true }],
2929

30-
'@stylistic/brace-style': ['warn', 'stroustrup', { allowSingleLine: false }],
30+
'@stylistic/brace-style': [1, 'stroustrup', { allowSingleLine: false }],
3131

32-
'@stylistic/curly-newline': ['warn', { consistent: true }],
32+
'@stylistic/curly-newline': [1, { consistent: true }],
3333

3434
'@stylistic/max-len': [
35-
'warn',
35+
1,
3636
{
3737
code: 100,
3838
ignoreUrls: true,
@@ -44,12 +44,12 @@ export default [
4444
},
4545
],
4646

47-
'@stylistic/no-extra-parens': ['warn', 'all'],
47+
'@stylistic/no-extra-parens': [1, 'all'],
4848

49-
'@stylistic/padded-blocks': ['error', 'never'],
49+
'@stylistic/padded-blocks': [2, 'never'],
5050

5151
'@stylistic/padding-line-between-statements': [
52-
'warn',
52+
1,
5353
{ blankLine: 'always', prev: '*', next: 'block-like' },
5454
{ blankLine: 'always', prev: 'block-like', next: '*' },
5555
{
@@ -61,6 +61,7 @@ export default [
6161

6262
'import-x/newline-after-import': 1,
6363
'import-x/no-unresolved': 0,
64+
'import-x/namespace': 0,
6465
},
6566
},
6667

@@ -69,8 +70,8 @@ export default [
6970
'simple-import-sort': simpleImportSort,
7071
},
7172
rules: {
72-
'simple-import-sort/imports': 'error',
73-
'simple-import-sort/exports': 'error',
73+
'simple-import-sort/imports': 2,
74+
'simple-import-sort/exports': 2,
7475
},
7576
},
7677

src/eslint/jsx.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,30 @@ export default [
1111
{
1212
rules: {
1313
'@stylistic/jsx-curly-brace-presence': [
14-
'warn',
14+
1,
1515
{
1616
props: 'never',
1717
children: 'never',
1818
propElementValues: 'always',
1919
},
2020
],
2121

22-
'@stylistic/jsx-first-prop-new-line': ['warn', 'multiline'],
22+
'@stylistic/jsx-first-prop-new-line': [1, 'multiline'],
2323

24-
'@stylistic/jsx-one-expression-per-line': ['warn', { allow: 'non-jsx' }],
24+
'@stylistic/jsx-one-expression-per-line': [1, { allow: 'non-jsx' }],
2525

26-
'@stylistic/jsx-props-no-multi-spaces': ['warn'],
26+
'@stylistic/jsx-props-no-multi-spaces': [1],
2727

2828
'@stylistic/jsx-self-closing-comp': [
29-
'warn',
29+
1,
3030
{
3131
component: true,
3232
html: true,
3333
},
3434
],
3535

3636
'@stylistic/jsx-sort-props': [
37-
'warn',
37+
1,
3838
{
3939
ignoreCase: false,
4040
shorthandFirst: true,

src/eslint/typescript-strict.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ export default tseslint.config(
1717
},
1818

1919
rules: {
20-
'@typescript-eslint/no-explicit-any': 'warn',
21-
'@typescript-eslint/no-floating-promises': 'warn',
22-
'@typescript-eslint/no-unsafe-argument': 'warn',
20+
'@typescript-eslint/no-explicit-any': 1,
21+
'@typescript-eslint/no-floating-promises': 1,
22+
'@typescript-eslint/no-unsafe-argument': 1,
23+
'@typescript-eslint/no-unsafe-call': 0,
24+
'@typescript-eslint/no-non-null-assertion': 0,
2325
'@typescript-eslint/no-use-before-define': [
24-
'warn',
26+
1,
2527
{
2628
functions: true,
2729
classes: true,
@@ -30,7 +32,7 @@ export default tseslint.config(
3032
},
3133
],
3234
'@typescript-eslint/restrict-template-expressions': [
33-
'warn',
35+
1,
3436
{
3537
allowNumber: true,
3638
},

src/eslint/typescript.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export default tseslint.config(
3636
{
3737
files: TYPESCRIPT_FILES,
3838
rules: {
39-
'@typescript-eslint/no-explicit-any': 'warn',
40-
'@typescript-eslint/no-floating-promises': 'warn',
41-
'@typescript-eslint/no-unsafe-argument': 'warn',
39+
'@typescript-eslint/no-explicit-any': 1,
40+
'@typescript-eslint/no-floating-promises': 1,
41+
'@typescript-eslint/no-unsafe-argument': 1,
4242
},
4343
},
4444
)

0 commit comments

Comments
 (0)