@houheaven/eslint-config-helper 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +149 -28
- package/lib/format-es5.js +23 -0
- package/lib/format-es6.js +25 -0
- package/lib/format-html.js +23 -0
- package/lib/format-import.js +23 -0
- package/lib/format-typescript.js +28 -0
- package/lib/format-vue2.js +23 -0
- package/lib/format-vue3.js +23 -0
- package/lib/html.js +13 -22
- package/lib/import.js +23 -0
- package/lib/javascript-es5.js +23 -0
- package/lib/javascript-es6.js +25 -0
- package/lib/rules/eslint/_deprecated.js +132 -0
- package/lib/rules/eslint/_removed.js +25 -0
- package/lib/rules/eslint/es6.js +279 -110
- package/lib/rules/eslint/layout-formatting.js +441 -0
- package/lib/rules/eslint/possible-errors.js +140 -131
- package/lib/rules/eslint/suggestions.js +666 -0
- package/lib/rules/html/accessibility.js +47 -23
- package/lib/rules/html/best-practice.js +122 -36
- package/lib/rules/html/seo.js +16 -11
- package/lib/rules/html/style.js +53 -15
- package/lib/rules/import/helpful-warnings.js +23 -18
- package/lib/rules/import/module-systems.js +16 -17
- package/lib/rules/import/static-analysis.js +54 -38
- package/lib/rules/import/style-guide.js +89 -61
- package/lib/rules/typescript/_deprecated.js +57 -0
- package/lib/rules/typescript/conflict.js +16 -0
- package/lib/rules/typescript/deprecated.js +41 -0
- package/lib/rules/typescript/extension.js +207 -0
- package/lib/rules/typescript/fixable.js +215 -0
- package/lib/rules/typescript/other.js +125 -0
- package/lib/rules/typescript/stylistic.js +34 -0
- package/lib/rules/typescript/suggestion.js +53 -0
- package/lib/rules/typescript/type-checked.js +263 -0
- package/lib/rules/vue/_deprecated.js +37 -0
- package/lib/rules/vue/common-base.js +1 -11
- package/lib/rules/vue/common-essential.js +25 -38
- package/lib/rules/vue/common-extension.js +321 -0
- package/lib/rules/vue/common-recommended.js +64 -31
- package/lib/rules/vue/common-strongly-recommended.js +37 -20
- package/lib/rules/vue/{common-extra.js → common-uncategorized.js} +141 -52
- package/lib/rules/vue/vue2-essential.js +16 -14
- package/lib/rules/vue/vue2-uncategorized.js +15 -0
- package/lib/rules/vue/vue3-essential.js +54 -24
- package/lib/rules/vue/vue3-strongly-recommended.js +8 -10
- package/lib/rules/vue/vue3-uncategorized.js +115 -0
- package/lib/support/es5-support.js +29 -0
- package/lib/support/es6-support.js +39 -0
- package/lib/support/html-support.js +38 -0
- package/lib/support/import-bugfix.js +65 -0
- package/lib/support/import-support.js +25 -0
- package/lib/support/typescript-support.js +27 -0
- package/lib/support/vue2-support.js +43 -0
- package/lib/support/vue3-support.js +43 -0
- package/lib/support/vue3-ts-support.js +51 -0
- package/lib/typescript.js +24 -32
- package/lib/utils/utils.js +160 -0
- package/lib/vue2.js +16 -22
- package/lib/vue3-ts.js +31 -0
- package/lib/vue3.js +13 -17
- package/package.json +38 -22
- package/lib/configs/eslint-es5.js +0 -24
- package/lib/configs/eslint.js +0 -23
- package/lib/configs/format-html.js +0 -22
- package/lib/configs/format-js.js +0 -134
- package/lib/configs/format-vue.js +0 -278
- package/lib/configs/html.js +0 -20
- package/lib/configs/import-bugfix.js +0 -36
- package/lib/configs/import.js +0 -44
- package/lib/configs/typescript.js +0 -10
- package/lib/configs/vue2.js +0 -28
- package/lib/configs/vue3.js +0 -28
- package/lib/eslint.js +0 -18
- package/lib/format.js +0 -40
- package/lib/rules/eslint/best-practices.js +0 -422
- package/lib/rules/eslint/node.js +0 -48
- package/lib/rules/eslint/strict-mode.js +0 -12
- package/lib/rules/eslint/stylistic-issues.js +0 -578
- package/lib/rules/eslint/variables.js +0 -73
- package/lib/rules/typescript/all.js +0 -193
- package/lib/rules/typescript/base.js +0 -10
- package/lib/rules/typescript/eslint-recommended.js +0 -36
- package/lib/rules/typescript/recommended-requiring-type-checking.js +0 -26
- package/lib/rules/typescript/recommended.js +0 -36
- package/lib/rules/typescript/strict.js +0 -47
- package/lib/rules/vue/common-eslint.js +0 -220
- package/lib/rules/vue/vue2-recommended.js +0 -17
- package/lib/rules/vue/vue2-strongly-recommended.js +0 -16
- package/lib/rules/vue/vue3-recommended.js +0 -17
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports = {
|
|
3
|
+
rules: {
|
|
4
|
+
// 规范数组的类型注释方式 T[] 或 Array<T>
|
|
5
|
+
// https://typescript-eslint.io/rules/array-type
|
|
6
|
+
"@typescript-eslint/array-type": ["warn", {
|
|
7
|
+
default: "array",
|
|
8
|
+
readonly: "array",
|
|
9
|
+
}],
|
|
10
|
+
|
|
11
|
+
// 禁止使用 tslint 注释
|
|
12
|
+
// https://typescript-eslint.io/rules/ban-tslint-comment
|
|
13
|
+
"@typescript-eslint/ban-tslint-comment": "warn",
|
|
14
|
+
|
|
15
|
+
// 一致的泛型构造函数类型
|
|
16
|
+
// https://typescript-eslint.io/rules/consistent-generic-constructors
|
|
17
|
+
"@typescript-eslint/consistent-generic-constructors": ["warn", "type-annotation"],
|
|
18
|
+
|
|
19
|
+
// 一致的索引对象类型
|
|
20
|
+
// https://typescript-eslint.io/rules/consistent-indexed-object-style
|
|
21
|
+
"@typescript-eslint/consistent-indexed-object-style": ["warn", "record"],
|
|
22
|
+
|
|
23
|
+
// 一致的类型断言风格
|
|
24
|
+
// https://typescript-eslint.io/rules/consistent-type-assertions
|
|
25
|
+
"@typescript-eslint/consistent-type-assertions": ["error", {
|
|
26
|
+
// assertionStyle: "never",
|
|
27
|
+
assertionStyle: "as",
|
|
28
|
+
objectLiteralTypeAssertions: "allow-as-parameter",
|
|
29
|
+
arrayLiteralTypeAssertions: "allow-as-parameter",
|
|
30
|
+
}],
|
|
31
|
+
|
|
32
|
+
// 一致的类型定义风格
|
|
33
|
+
// https://typescript-eslint.io/rules/consistent-type-definitions
|
|
34
|
+
"@typescript-eslint/consistent-type-definitions": ["warn", "interface"],
|
|
35
|
+
|
|
36
|
+
// 一致的类型导出风格
|
|
37
|
+
// 依赖:parserServices
|
|
38
|
+
// https://typescript-eslint.io/rules/consistent-type-exports
|
|
39
|
+
"@typescript-eslint/consistent-type-exports": ["warn", {
|
|
40
|
+
fixMixedExportsWithInlineTypeSpecifier: false,
|
|
41
|
+
}],
|
|
42
|
+
|
|
43
|
+
// 一致的类型导入风格
|
|
44
|
+
// https://typescript-eslint.io/rules/consistent-type-imports
|
|
45
|
+
"@typescript-eslint/consistent-type-imports": ["warn", {
|
|
46
|
+
prefer: "type-imports",
|
|
47
|
+
fixStyle: "separate-type-imports",
|
|
48
|
+
disallowTypeAnnotations: true,
|
|
49
|
+
}],
|
|
50
|
+
|
|
51
|
+
// 一致的成员可访问性
|
|
52
|
+
// https://typescript-eslint.io/rules/explicit-member-accessibility
|
|
53
|
+
"@typescript-eslint/explicit-member-accessibility": "off",
|
|
54
|
+
|
|
55
|
+
// 一致的方法签名风格
|
|
56
|
+
// https://typescript-eslint.io/rules/method-signature-style
|
|
57
|
+
"@typescript-eslint/method-signature-style": ["warn", "property"],
|
|
58
|
+
|
|
59
|
+
// 禁止令人困惑的 void 表达式
|
|
60
|
+
// https://typescript-eslint.io/rules/no-confusing-void-expression
|
|
61
|
+
"@typescript-eslint/no-confusing-void-expression": ["warn", {
|
|
62
|
+
ignoreArrowShorthand: false,
|
|
63
|
+
ignoreVoidOperator: false,
|
|
64
|
+
ignoreVoidReturningFunctions: false,
|
|
65
|
+
}],
|
|
66
|
+
|
|
67
|
+
// 禁止重复的类型组成部分
|
|
68
|
+
// 依赖:parserServices
|
|
69
|
+
// https://typescript-eslint.io/rules/no-duplicate-type-constituents
|
|
70
|
+
"@typescript-eslint/no-duplicate-type-constituents": ["warn", {
|
|
71
|
+
ignoreIntersections: false,
|
|
72
|
+
ignoreUnions: false,
|
|
73
|
+
}],
|
|
74
|
+
|
|
75
|
+
// 禁止动态删除属性
|
|
76
|
+
// https://typescript-eslint.io/rules/no-dynamic-delete
|
|
77
|
+
"@typescript-eslint/no-dynamic-delete": "warn",
|
|
78
|
+
|
|
79
|
+
// 禁止显式 any 类型
|
|
80
|
+
// https://typescript-eslint.io/rules/no-explicit-any
|
|
81
|
+
"@typescript-eslint/no-explicit-any": ["error", {
|
|
82
|
+
fixToUnknown: false,
|
|
83
|
+
ignoreRestArgs: false,
|
|
84
|
+
}],
|
|
85
|
+
|
|
86
|
+
// 禁止额外的非空断言
|
|
87
|
+
// https://typescript-eslint.io/rules/no-extra-non-null-assertion
|
|
88
|
+
"@typescript-eslint/no-extra-non-null-assertion": "warn",
|
|
89
|
+
|
|
90
|
+
// 禁止导入类型副作用
|
|
91
|
+
// https://typescript-eslint.io/rules/no-import-type-side-effects
|
|
92
|
+
"@typescript-eslint/no-import-type-side-effects": "warn",
|
|
93
|
+
|
|
94
|
+
// 禁止可推断的类型
|
|
95
|
+
// https://typescript-eslint.io/rules/no-inferrable-types
|
|
96
|
+
"@typescript-eslint/no-inferrable-types": ["warn", {
|
|
97
|
+
ignoreParameters: false,
|
|
98
|
+
ignoreProperties: false,
|
|
99
|
+
}],
|
|
100
|
+
|
|
101
|
+
// 禁止无意义的 void 表达式
|
|
102
|
+
// 依赖:parserServices
|
|
103
|
+
// https://typescript-eslint.io/rules/no-meaningless-void-operator
|
|
104
|
+
"@typescript-eslint/no-meaningless-void-operator": ["warn", {
|
|
105
|
+
checkNever: false,
|
|
106
|
+
}],
|
|
107
|
+
|
|
108
|
+
// 禁止使用某些类型
|
|
109
|
+
// https://typescript-eslint.io/rules/no-restricted-types
|
|
110
|
+
"@typescript-eslint/no-restricted-types": "off",
|
|
111
|
+
|
|
112
|
+
// 禁止不必要的布尔值字面量比较
|
|
113
|
+
// https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare
|
|
114
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": ["warn", {
|
|
115
|
+
allowComparingNullableBooleansToTrue: true,
|
|
116
|
+
allowComparingNullableBooleansToFalse: true,
|
|
117
|
+
}],
|
|
118
|
+
|
|
119
|
+
// 禁止不必要的类型限定符
|
|
120
|
+
// https://typescript-eslint.io/rules/no-unnecessary-qualifier
|
|
121
|
+
"@typescript-eslint/no-unnecessary-qualifier": "warn",
|
|
122
|
+
|
|
123
|
+
// 禁止不必要的模板表达式
|
|
124
|
+
// https://typescript-eslint.io/rules/no-unnecessary-template-expression
|
|
125
|
+
"@typescript-eslint/no-unnecessary-template-expression": "warn",
|
|
126
|
+
|
|
127
|
+
// 禁止不必要的类型参数
|
|
128
|
+
// https://typescript-eslint.io/rules/no-unnecessary-type-arguments
|
|
129
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "warn",
|
|
130
|
+
|
|
131
|
+
// 禁止不必要的类型断言
|
|
132
|
+
// https://typescript-eslint.io/rules/no-unnecessary-type-assertion
|
|
133
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
|
|
134
|
+
|
|
135
|
+
// 禁止无意义的空导出
|
|
136
|
+
// https://typescript-eslint.io/rules/no-useless-empty-export
|
|
137
|
+
"@typescript-eslint/no-useless-empty-export": "warn",
|
|
138
|
+
|
|
139
|
+
// 禁止包装对象类型
|
|
140
|
+
// https://typescript-eslint.io/rules/no-wrapper-object-types
|
|
141
|
+
"@typescript-eslint/no-wrapper-object-types": "warn",
|
|
142
|
+
|
|
143
|
+
// 非空类型断言风格
|
|
144
|
+
// https://typescript-eslint.io/rules/non-nullable-type-assertion-style
|
|
145
|
+
"@typescript-eslint/non-nullable-type-assertion-style": "warn",
|
|
146
|
+
|
|
147
|
+
// 推荐使用 as const 断言
|
|
148
|
+
// https://typescript-eslint.io/rules/prefer-as-const
|
|
149
|
+
"@typescript-eslint/prefer-as-const": "warn",
|
|
150
|
+
|
|
151
|
+
// 推荐使用函数类型而不是接口
|
|
152
|
+
// https://typescript-eslint.io/rules/prefer-function-type
|
|
153
|
+
"@typescript-eslint/prefer-function-type": "warn",
|
|
154
|
+
|
|
155
|
+
// 推荐使用 includes 而不是 indexOf
|
|
156
|
+
// https://typescript-eslint.io/rules/prefer-includes
|
|
157
|
+
"@typescript-eslint/prefer-includes": "warn",
|
|
158
|
+
|
|
159
|
+
// 推荐使用 namespace 而不是 module
|
|
160
|
+
// https://typescript-eslint.io/rules/prefer-namespace-keyword
|
|
161
|
+
"@typescript-eslint/prefer-namespace-keyword": "warn",
|
|
162
|
+
|
|
163
|
+
// 推荐使用可选链而不是短路表达式
|
|
164
|
+
// https://typescript-eslint.io/rules/prefer-optional-chain
|
|
165
|
+
"@typescript-eslint/prefer-optional-chain": ["warn", {
|
|
166
|
+
allowPotentiallyUnsafeFixesThatModifyTheReturnTypeIKnowWhatImDoing: false,
|
|
167
|
+
checkAny: true,
|
|
168
|
+
checkBigInt: true,
|
|
169
|
+
checkBoolean: true,
|
|
170
|
+
checkNumber: true,
|
|
171
|
+
checkString: true,
|
|
172
|
+
checkUnknown: true,
|
|
173
|
+
requireNullish: false,
|
|
174
|
+
}],
|
|
175
|
+
|
|
176
|
+
// 推荐使用只读类型
|
|
177
|
+
// https://typescript-eslint.io/rules/prefer-readonly
|
|
178
|
+
"@typescript-eslint/prefer-readonly": ["off", {
|
|
179
|
+
onlyInlineLambdas: false,
|
|
180
|
+
}],
|
|
181
|
+
|
|
182
|
+
// 推荐使用 reduce 类型参数
|
|
183
|
+
// https://typescript-eslint.io/rules/prefer-reduce-type-parameter
|
|
184
|
+
"@typescript-eslint/prefer-reduce-type-parameter": "warn",
|
|
185
|
+
|
|
186
|
+
// 推荐使用 RegExp.exec 而不是 String.match
|
|
187
|
+
// https://typescript-eslint.io/rules/prefer-regexp-exec
|
|
188
|
+
"@typescript-eslint/prefer-regexp-exec": "warn",
|
|
189
|
+
|
|
190
|
+
// 推荐使用返回 this 类型
|
|
191
|
+
// https://typescript-eslint.io/rules/prefer-return-this-type
|
|
192
|
+
"@typescript-eslint/prefer-return-this-type": "off",
|
|
193
|
+
|
|
194
|
+
// 推荐使用 startsWith 和 endsWith 方法
|
|
195
|
+
// https://typescript-eslint.io/rules/prefer-string-starts-ends-with
|
|
196
|
+
"@typescript-eslint/prefer-string-starts-ends-with": ["warn", {
|
|
197
|
+
allowSingleElementEquality: "never",
|
|
198
|
+
}],
|
|
199
|
+
|
|
200
|
+
// 推荐使用异步函数
|
|
201
|
+
// https://typescript-eslint.io/rules/promise-function-async
|
|
202
|
+
"@typescript-eslint/promise-function-async": ["warn", {
|
|
203
|
+
allowAny: true,
|
|
204
|
+
allowedPromiseNames: [],
|
|
205
|
+
checkArrowFunctions: true,
|
|
206
|
+
checkFunctionDeclarations: true,
|
|
207
|
+
checkFunctionExpressions: true,
|
|
208
|
+
checkMethodDeclarations: true,
|
|
209
|
+
}],
|
|
210
|
+
|
|
211
|
+
// 推荐返回 await
|
|
212
|
+
// https://typescript-eslint.io/rules/return-await
|
|
213
|
+
"@typescript-eslint/return-await": ["off", "in-try-catch"],
|
|
214
|
+
},
|
|
215
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports = {
|
|
3
|
+
rules: {
|
|
4
|
+
// 要求函数重载签名必须连续排列
|
|
5
|
+
// https://typescript-eslint.io/rules/adjacent-overload-signatures
|
|
6
|
+
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
7
|
+
|
|
8
|
+
// 要求函数返回类型
|
|
9
|
+
// https://typescript-eslint.io/rules/explicit-function-return-type
|
|
10
|
+
"@typescript-eslint/explicit-function-return-type": ["error", {
|
|
11
|
+
allowExpressions: false,
|
|
12
|
+
allowTypedFunctionExpressions: true,
|
|
13
|
+
allowHigherOrderFunctions: true,
|
|
14
|
+
allowDirectConstAssertionInArrowFunctions: true,
|
|
15
|
+
allowConciseArrowFunctionExpressionsStartingWithVoid: false,
|
|
16
|
+
allowFunctionsWithoutTypeParameters: false,
|
|
17
|
+
allowedNames: [],
|
|
18
|
+
allowIIFEs: false,
|
|
19
|
+
}],
|
|
20
|
+
|
|
21
|
+
// 要求模块边界的类型
|
|
22
|
+
// https://typescript-eslint.io/rules/explicit-module-boundary-types
|
|
23
|
+
"@typescript-eslint/explicit-module-boundary-types": ["error", {
|
|
24
|
+
allowArgumentsExplicitlyTypedAsAny: false,
|
|
25
|
+
allowDirectConstAssertionInArrowFunctions: true,
|
|
26
|
+
allowedNames: [],
|
|
27
|
+
allowHigherOrderFunctions: true,
|
|
28
|
+
allowTypedFunctionExpressions: true,
|
|
29
|
+
allowOverloadFunctions: false,
|
|
30
|
+
}],
|
|
31
|
+
|
|
32
|
+
// 要求成员排序
|
|
33
|
+
// https://typescript-eslint.io/rules/member-ordering
|
|
34
|
+
"@typescript-eslint/member-ordering": "off",
|
|
35
|
+
|
|
36
|
+
// 禁止重复的枚举值
|
|
37
|
+
// https://typescript-eslint.io/rules/no-duplicate-enum-values
|
|
38
|
+
"@typescript-eslint/no-duplicate-enum-values": "error",
|
|
39
|
+
|
|
40
|
+
// 禁止多余的类
|
|
41
|
+
// https://typescript-eslint.io/rules/no-extraneous-class
|
|
42
|
+
"@typescript-eslint/no-extraneous-class": ["error", {
|
|
43
|
+
allowConstructorOnly: false,
|
|
44
|
+
allowEmpty: false,
|
|
45
|
+
allowStaticOnly: false,
|
|
46
|
+
allowWithDecorator: false,
|
|
47
|
+
}],
|
|
48
|
+
|
|
49
|
+
// 禁止无效的 void 类型
|
|
50
|
+
// https://typescript-eslint.io/rules/no-invalid-void-type
|
|
51
|
+
"@typescript-eslint/no-invalid-void-type": ["error", {
|
|
52
|
+
allowInGenericTypeArguments: true,
|
|
53
|
+
allowAsThisParameter: false,
|
|
54
|
+
}],
|
|
55
|
+
|
|
56
|
+
// 禁止使用 new 操作符调用无参数构造函数
|
|
57
|
+
// https://typescript-eslint.io/rules/no-misused-new
|
|
58
|
+
"@typescript-eslint/no-misused-new": "error",
|
|
59
|
+
|
|
60
|
+
// 禁止使用 namespace 关键字
|
|
61
|
+
// https://typescript-eslint.io/rules/no-namespace
|
|
62
|
+
"@typescript-eslint/no-namespace": ["error", {
|
|
63
|
+
allowDeclarations: true,
|
|
64
|
+
allowDefinitionFiles: true,
|
|
65
|
+
}],
|
|
66
|
+
|
|
67
|
+
// 禁止使用 require 导入,推荐使用 import 语句
|
|
68
|
+
// https://typescript-eslint.io/rules/no-require-imports
|
|
69
|
+
"@typescript-eslint/no-require-imports": ["error", {
|
|
70
|
+
allow: [],
|
|
71
|
+
allowAsImport: false,
|
|
72
|
+
}],
|
|
73
|
+
|
|
74
|
+
// 禁止使用 this 别名
|
|
75
|
+
// https://typescript-eslint.io/rules/no-this-alias
|
|
76
|
+
"@typescript-eslint/no-this-alias": ["error", {
|
|
77
|
+
allowDestructuring: true,
|
|
78
|
+
allowedNames: [],
|
|
79
|
+
}],
|
|
80
|
+
|
|
81
|
+
// 禁止不必要的参数属性赋值
|
|
82
|
+
// https://typescript-eslint.io/rules/no-unnecessary-parameter-property-assignment
|
|
83
|
+
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
|
|
84
|
+
|
|
85
|
+
// 禁止不安全的声明合并
|
|
86
|
+
// https://typescript-eslint.io/rules/no-unsafe-declaration-merging
|
|
87
|
+
"@typescript-eslint/no-unsafe-declaration-merging": "error",
|
|
88
|
+
|
|
89
|
+
// 禁止使用不安全的函数类型
|
|
90
|
+
// https://typescript-eslint.io/rules/no-unsafe-function-type
|
|
91
|
+
"@typescript-eslint/no-unsafe-function-type": "error",
|
|
92
|
+
|
|
93
|
+
// 参数属性
|
|
94
|
+
// https://typescript-eslint.io/rules/parameter-properties
|
|
95
|
+
"@typescript-eslint/parameter-properties": ["error", {
|
|
96
|
+
allow: [],
|
|
97
|
+
prefer: "class-property",
|
|
98
|
+
}],
|
|
99
|
+
|
|
100
|
+
// 要求使用 for-of 循环
|
|
101
|
+
// https://typescript-eslint.io/rules/prefer-for-of
|
|
102
|
+
"@typescript-eslint/prefer-for-of": "error",
|
|
103
|
+
|
|
104
|
+
// 要求所有枚举成员均为字面量值
|
|
105
|
+
// https://typescript-eslint.io/rules/prefer-literal-enum-member
|
|
106
|
+
"@typescript-eslint/prefer-literal-enum-member": ["error", {
|
|
107
|
+
allowBitwiseExpressions: false,
|
|
108
|
+
}],
|
|
109
|
+
|
|
110
|
+
// 三斜线引用
|
|
111
|
+
// https://typescript-eslint.io/rules/triple-slash-reference
|
|
112
|
+
"@typescript-eslint/triple-slash-reference": ["error", {
|
|
113
|
+
lib: "always",
|
|
114
|
+
path: "never",
|
|
115
|
+
types: "prefer-import",
|
|
116
|
+
}],
|
|
117
|
+
|
|
118
|
+
// 要求使用统一的函数签名
|
|
119
|
+
// https://typescript-eslint.io/rules/unified-signatures
|
|
120
|
+
"@typescript-eslint/unified-signatures": ["error", {
|
|
121
|
+
ignoreDifferentlyNamedParameters: false,
|
|
122
|
+
ignoreOverloadsWithDifferentJSDoc: false,
|
|
123
|
+
}],
|
|
124
|
+
},
|
|
125
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
// ==========================================================
|
|
3
|
+
// - @stylistic/eslint-plugin 定制规则
|
|
4
|
+
// ==========================================================
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
rules: {
|
|
8
|
+
// 要求或禁止在成员之间使用分号
|
|
9
|
+
// https://eslint.style/rules/member-delimiter-style
|
|
10
|
+
"@stylistic/member-delimiter-style": ["warn", {
|
|
11
|
+
multiline: {
|
|
12
|
+
delimiter: "semi",
|
|
13
|
+
requireLast: true,
|
|
14
|
+
},
|
|
15
|
+
singleline: {
|
|
16
|
+
delimiter: "semi",
|
|
17
|
+
requireLast: true,
|
|
18
|
+
},
|
|
19
|
+
multilineDetection: "brackets",
|
|
20
|
+
}],
|
|
21
|
+
|
|
22
|
+
// 要求或禁止在类型注解周围使用空格
|
|
23
|
+
// https://eslint.style/rules/type-annotation-spacing
|
|
24
|
+
"@stylistic/type-annotation-spacing": ["warn", {
|
|
25
|
+
before: true,
|
|
26
|
+
after: true,
|
|
27
|
+
overrides: {
|
|
28
|
+
colon: {
|
|
29
|
+
before: false,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}],
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports = {
|
|
3
|
+
rules: {
|
|
4
|
+
// 禁止使用 @ts-ignore、@ts-nocheck、@ts-check、@ts-expect-error 等注释
|
|
5
|
+
// @ts-nocheck - 禁用整个文件的类型检查
|
|
6
|
+
// @ts-check - 启用整个文件的类型检查(默认开启)
|
|
7
|
+
// @ts-ignore - 忽略下一行代码的类型检查错误
|
|
8
|
+
// @ts-expect-error - 预期下一行代码会报错,但编译通过,用于测试类型错误边界(如类型断言失败)
|
|
9
|
+
// https://typescript-eslint.io/rules/ban-ts-comment
|
|
10
|
+
"@typescript-eslint/ban-ts-comment": ["error", {
|
|
11
|
+
"ts-check": true,
|
|
12
|
+
"ts-nocheck": false,
|
|
13
|
+
"ts-ignore": false,
|
|
14
|
+
"ts-expect-error": true,
|
|
15
|
+
}],
|
|
16
|
+
|
|
17
|
+
// 要求类字面量属性的样式
|
|
18
|
+
// https://typescript-eslint.io/rules/class-literal-property-style
|
|
19
|
+
"@typescript-eslint/class-literal-property-style": ["warn", "fields"],
|
|
20
|
+
|
|
21
|
+
// 禁止使用令人混淆的非空断言
|
|
22
|
+
// https://typescript-eslint.io/rules/no-confusing-non-null-assertion
|
|
23
|
+
"@typescript-eslint/no-confusing-non-null-assertion": "error",
|
|
24
|
+
|
|
25
|
+
// 禁止使用空对象类型
|
|
26
|
+
// https://typescript-eslint.io/rules/no-empty-object-type
|
|
27
|
+
"@typescript-eslint/no-empty-object-type": ["error", {
|
|
28
|
+
"allowInterfaces": "never",
|
|
29
|
+
"allowObjectTypes": "never",
|
|
30
|
+
"allowWithName": "",
|
|
31
|
+
}],
|
|
32
|
+
|
|
33
|
+
// 禁止使用非空断言的空值合并运算符
|
|
34
|
+
// https://typescript-eslint.io/rules/no-non-null-asserted-nullish-coalescing
|
|
35
|
+
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
|
|
36
|
+
|
|
37
|
+
// 禁止使用非空断言的可选链
|
|
38
|
+
// https://typescript-eslint.io/rules/no-non-null-asserted-optional-chain
|
|
39
|
+
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
|
|
40
|
+
|
|
41
|
+
// 禁止使用非空断言
|
|
42
|
+
// https://typescript-eslint.io/rules/no-non-null-assertion
|
|
43
|
+
"@typescript-eslint/no-non-null-assertion": "error",
|
|
44
|
+
|
|
45
|
+
// 禁止使用不必要的类型约束
|
|
46
|
+
// https://typescript-eslint.io/rules/no-unnecessary-type-constraint
|
|
47
|
+
"@typescript-eslint/no-unnecessary-type-constraint": "error",
|
|
48
|
+
|
|
49
|
+
// 要求枚举成员初始化器
|
|
50
|
+
// https://typescript-eslint.io/rules/prefer-enum-initializers
|
|
51
|
+
"@typescript-eslint/prefer-enum-initializers": "error",
|
|
52
|
+
},
|
|
53
|
+
};
|