-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
127 lines (126 loc) · 4.4 KB
/
eslint.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import js from "@eslint/js";
import typescriptPlugin from "@typescript-eslint/eslint-plugin";
import typescriptParser from "@typescript-eslint/parser";
export default [
{
files: ["**/*.ts", "**/*.tsx"], // 针对 TypeScript 文件
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
},
plugins: {
"@typescript-eslint": typescriptPlugin,
},
rules: {
indent: ["error", "tab", { SwitchCase: 1, flatTernaryExpressions: true }],
"linebreak-style": ["error", "unix"],
quotes: ["warn", "single"],
semi: ["warn", "never"],
"array-bracket-spacing": ["error", "never"],
"brace-style": ["error", "1tbs", { allowSingleLine: true }],
"comma-dangle": ["warn", "always-multiline"],
"comma-spacing": ["error", { before: false, after: true }],
"comma-style": ["error", "last"],
"eol-last": "error",
"default-case": "error",
"no-duplicate-case": "error",
"no-eq-null": "error",
"no-floating-decimal": "error",
"no-mixed-spaces-and-tabs": ["error", false],
"no-var": "error",
"no-tabs": "off",
"no-empty": ["error", { allowEmptyCatch: true }],
"no-constant-condition": ["error", { checkLoops: false }],
eqeqeq: "error",
"prefer-const": "error",
"for-direction": "error",
"getter-return": "error",
"no-compare-neg-zero": "error",
"no-cond-assign": "error",
"no-extra-semi": "error",
"no-irregular-whitespace": "error",
"no-unreachable": "error",
"use-isnan": "error",
"valid-typeof": "error",
"dot-notation": ["error"],
"guard-for-in": "error",
"no-extra-label": "error",
"require-await": "error",
yoda: "error",
"block-spacing": "error",
"computed-property-spacing": ["error", "never"],
"no-whitespace-before-property": "error",
"object-curly-spacing": ["error", "always"],
"padded-blocks": ["error", "never"],
"quote-props": ["error", "as-needed"],
"semi-spacing": "off",
"semi-style": ["error", "last"],
"space-before-function-paren": [
"error",
{ anonymous: "always", named: "never", asyncArrow: "always" },
],
"space-infix-ops": "error",
"space-in-parens": ["error", "never"],
"space-unary-ops": "error",
"unicode-bom": ["error", "never"],
"arrow-spacing": "error",
"require-yield": "error",
"yield-star-spacing": ["error", "after"],
"symbol-description": "error",
"template-tag-spacing": "error",
"switch-colon-spacing": "error",
"keyword-spacing": "error",
"key-spacing": "error",
"jsx-quotes": "error",
"no-multi-spaces": "error",
"dot-location": ["error", "property"],
"no-loss-of-precision": "error",
"no-useless-concat": "error",
"object-shorthand": "error",
"prefer-template": "warn",
"template-curly-spacing": "error",
"multiline-ternary": "off",
"operator-linebreak": "off",
"no-trailing-spaces": ["error", { skipBlankLines: true }],
"one-var": "off",
"arrow-parens": ["error", "as-needed"],
camelcase: "off",
"spaced-comment": [
"error",
"always",
{
exceptions: ["+", "-", "*", "/"],
markers: ["/", "!", "@", "#", "#region", "#endregion"],
},
],
radix: "error", // parseInt 必须要指明是十进制
"no-self-assign": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/triple-slash-reference": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-namespace": "off",
"func-call-spacing": ["error", "never"],
"@typescript-eslint/consistent-type-assertions": [
"error",
{ assertionStyle: "as" },
],
"@typescript-eslint/no-confusing-non-null-assertion": "error",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
},
},
];