-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.json
374 lines (362 loc) · 7.3 KB
/
.eslintrc.json
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
{
"env": {
"browser": false,
"node": true,
"commonjs": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"no-console": [
"warn",
{
"allow": [
"table",
"warn",
"info",
"error"
]
}
],
"import/extensions": "off",
"no-bitwise": "off",
"no-param-reassign": "off",
"class-methods-use-this": "off",
/**
* 明确类成员可访问性
*/
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
"accessibility": "no-public"
}
],
/**
* 允许未使用的变量
*/
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"vars": "all",
"args": "after-used",
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_"
}
],
/**
* 是否使用类型推断
*/
"@typescript-eslint/no-inferrable-types": [
"error",
// 禁用属性类型推断,启用参数类型推断
{
"ignoreParameters": false,
"ignoreProperties": true
}
],
/**
* 指定数组的元素之间要以空格隔开(,后面), never参数:[ 之前和 ] 之后不能带空格,always参数:[ 之前和 ] 之后必须带空格
*/
"array-bracket-spacing": [
"error",
"always"
],
/**
* 必须使用全等
*/
"eqeqeq": [
"error",
"always",
{
"null": "ignore"
}
],
/**
* always-multiline:多行模式必须带逗号,单行模式不能带逗号
*/
"comma-dangle": "off",
"@typescript-eslint/comma-dangle": [
2,
"always-multiline"
],
/**
* 缩进
* https: //eslint.org/docs/rules/indent#options
*/
"indent": "off",
"@typescript-eslint/indent": [
"error",
2,
{
"VariableDeclarator": "first",
"MemberExpression": 1,
"SwitchCase": 1,
"FunctionExpression": {
"parameters": "first"
},
"CallExpression": {
"arguments": "first"
},
"ArrayExpression": "first",
"ObjectExpression": "first",
"ImportDeclaration": "first"
}
],
/**
* 控制逗号前后的空格
*/
"comma-spacing": "off",
"@typescript-eslint/comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
/**
* 控制逗号在行尾出现还是在行首出现
* http: //eslint.org/docs/rules/comma-style
*/
"comma-style": [
"error",
"last"
],
"prefer-const":["warn"],
/**
* 所有引号使用双引号
*/
"quotes": "off",
"@typescript-eslint/quotes": [
"error",
"double"
],
/**
* 以方括号取对象属性时,[ 后面和 ] 前面是否需要空格, 可选参数 never, always
*/
"computed-property-spacing": [
"error",
"always"
],
/**
* if-else等块的换行风格
*/
"brace-style": [
"error",
"1tbs",
{
"allowSingleLine": true
}
],
/**
* 箭头函数前后的空格
*/
"arrow-spacing": [
"error",
{
"before": true,
"after": true
}
],
/**
* 对象字面量中冒号的前后空格
*/
"key-spacing": [
"error",
{
"beforeColon": false,
"afterColon": true
}
],
/**
* 关键词前后的空格
*/
"keyword-spacing": "off",
"@typescript-eslint/keyword-spacing": [
"error"
],
/**
* 类型冒号前后的空格
*/
"@typescript-eslint/type-annotation-spacing":[
"error",
{
"before": true,
"after": true
}
],
"space-in-parens": [
"error", "never"
],
/**
* 禁止额外的非空断言
*/
"@typescript-eslint/no-extra-non-null-assertion": [
"error"
],
/**
* 大括号内是否允许不必要的空格
*/
"object-curly-spacing": "off",
"@typescript-eslint/object-curly-spacing": [
"error",
"always",
{
"arraysInObjects": false,
"objectsInObjects": false
}
],
/**
* 强制函数括号前的空格保持一致
*/
"space-before-function-paren": "off",
"@typescript-eslint/space-before-function-paren": [
"error"
],
/**
* 分号
*/
"semi": "off",
"@typescript-eslint/semi": [
"error",
"always"
],
/**
* 分号前后的空格
*/
"semi-spacing": [
"error",
{
"before": false,
"after": true
}
],
/**
* 禁用var,用let和const代替
*/
"no-var": "error",
/**
* 不能用多余的空格
*/
"no-multi-spaces":[
"error",
{
"ignoreEOLComments": true,
"exceptions": {
"ImportDeclaration": false,
"VariableDeclarator": false,
"BinaryExpression": false,
"Property": false
}
}
],
/**
* 注释前的空格
*/
"spaced-comment": [
"error", "always",
{
"markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","
]
}
],
/**
* 属性的点前后不能有空格
*/
"no-whitespace-before-property": "error",
/**
* 方法调用前的括号不能有空格
*/
"no-spaced-func": "error",
/**
* 该规则旨在确保中缀操作符周围有空格。
*/
"space-infix-ops": "off",
"@typescript-eslint/space-infix-ops": [
"error",
{
"int32Hint": false
}
],
/**
* 没有可被修剪的空格
*/
"no-trailing-spaces": "error",
/**
* 禁止不必要的分号
*/
"no-extra-semi": "off",
"@typescript-eslint/no-extra-semi": [
"error"
],
/**
* 块之前的空格
*/
"space-before-blocks":["error","always"],
/**
* 不允许空函数
*/
"no-empty-function": "off",
"@typescript-eslint/no-empty-function": [
"warn",
{
"allow": [
"private-constructors",
"protected-constructors",
"decoratedFunctions"
]
}
],
// 以下是还没有处理的配置
"generator-star-spacing": [
"error",
{
"before": true,
"after": true
}
],
"@typescript-eslint/interface-name-prefix": 0,
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-parameter-properties": 0,
"@typescript-eslint/camelcase": [
"off",
{
"properties": "always"
}
],
"@typescript-eslint/explicit-function-return-type": [
"off",
{
"allowExpressions": true,
"allowTypedFunctionExpressions": true
}
]
},
"settings": {
"import/resolver": {
"node": {
"extensions": [
".ts",
".js",
".json",
".node"
],
"paths": [
"src"
]
}
}
}
}