eslint-config-fe 1.4.1 → 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/base.js +32 -0
- package/commitlint.config.js +1 -0
- package/index.js +7 -364
- package/package.json +10 -9
- package/react.js +11 -0
- package/rules/base-babel.js +34 -0
- package/rules/base-extra.js +34 -0
- package/rules/base.js +944 -0
- package/rules/index.js +367 -0
- package/rules/react.js +526 -0
- package/rules/ts.js +117 -0
- package/ts.js +18 -0
- package/less.js +0 -1000
- package/react/index.js +0 -533
- package/ts/index.js +0 -129
package/rules/base.js
ADDED
|
@@ -0,0 +1,944 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
/**
|
|
4
|
+
* 限制数组的括号使用一致的换行符
|
|
5
|
+
*
|
|
6
|
+
* https://eslint.org/docs/rules/array-bracket-newline
|
|
7
|
+
*/
|
|
8
|
+
'array-bracket-newline': ['warn', 'consistent'],
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 限制在代码块中开括号后和闭括号前有空格
|
|
12
|
+
*
|
|
13
|
+
* https://eslint.org/docs/rules/block-spacing
|
|
14
|
+
*/
|
|
15
|
+
'block-spacing': ['warn', 'always'],
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 避免在 case 或 default 子句中出现声明语句
|
|
19
|
+
*
|
|
20
|
+
* https://eslint.org/docs/rules/no-case-declarations
|
|
21
|
+
*/
|
|
22
|
+
'no-case-declarations': 'error',
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 避免 case 语句缺失 break
|
|
26
|
+
*
|
|
27
|
+
* https://eslint.org/docs/rules/no-fallthrough
|
|
28
|
+
*/
|
|
29
|
+
'no-fallthrough': [
|
|
30
|
+
'error',
|
|
31
|
+
{ commentPattern: 'break[\\s\\w]*omitted' }
|
|
32
|
+
],
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 避免使用空解构模式
|
|
36
|
+
*
|
|
37
|
+
* https://eslint.org/docs/rules/no-empty-pattern
|
|
38
|
+
*/
|
|
39
|
+
'no-empty-pattern': 'error',
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 避免对原生对象或只读的全局对象进行赋值
|
|
43
|
+
*
|
|
44
|
+
* https://eslint.org/docs/rules/no-global-assign
|
|
45
|
+
*/
|
|
46
|
+
'no-global-assign': 'error',
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 避免 Symbolnew 操作符和 new 一起使用
|
|
50
|
+
*
|
|
51
|
+
* https://eslint.org/docs/rules/no-new-symbol
|
|
52
|
+
*/
|
|
53
|
+
'no-new-symbol': 'error',
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 避免正则表达式字面量中出现多个空格
|
|
57
|
+
*
|
|
58
|
+
* https://eslint.org/docs/rules/no-regex-spaces
|
|
59
|
+
*/
|
|
60
|
+
'no-regex-spaces': 'error',
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 避免不必要的 return await
|
|
64
|
+
*
|
|
65
|
+
* https://eslint.org/docs/rules/no-return-await
|
|
66
|
+
*/
|
|
67
|
+
'no-return-await': 'error',
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 避免给自身赋值
|
|
71
|
+
*
|
|
72
|
+
* https://eslint.org/docs/rules/no-self-assign
|
|
73
|
+
*/
|
|
74
|
+
'no-self-assign': 'error',
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 避免使用逗号操作符
|
|
78
|
+
*
|
|
79
|
+
* https://eslint.org/docs/rules/no-sequences
|
|
80
|
+
*/
|
|
81
|
+
'no-sequences': 'error',
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 避免使用令人困惑的多行表达式
|
|
85
|
+
*
|
|
86
|
+
* https://eslint.org/docs/rules/no-unexpected-multiline
|
|
87
|
+
*/
|
|
88
|
+
'no-unexpected-multiline': 'error',
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 避免使用一成不变的循环条件
|
|
92
|
+
*
|
|
93
|
+
* https://eslint.org/docs/rules/no-unmodified-loop-condition
|
|
94
|
+
*/
|
|
95
|
+
'no-unmodified-loop-condition': 'warn',
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 避免在 finally 语句块中出现控制流语句
|
|
99
|
+
*
|
|
100
|
+
* https://eslint.org/docs/rules/no-unsafe-finally
|
|
101
|
+
*/
|
|
102
|
+
'no-unsafe-finally': 'error',
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 避免在对象中使用不必要的计算属性
|
|
106
|
+
*
|
|
107
|
+
* https://eslint.org/docs/rules/no-useless-computed-key
|
|
108
|
+
*/
|
|
109
|
+
'no-useless-computed-key': 'error',
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 警告没有必要的字符拼接
|
|
113
|
+
*
|
|
114
|
+
* https://eslint.org/docs/rules/no-useless-concat
|
|
115
|
+
*/
|
|
116
|
+
'no-useless-concat': 'warn',
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 避免不必要的转义
|
|
120
|
+
*
|
|
121
|
+
* https://eslint.org/docs/rules/no-useless-escape
|
|
122
|
+
*/
|
|
123
|
+
'no-useless-escape': 'error',
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 避免属性前有空白
|
|
127
|
+
*
|
|
128
|
+
* https://eslint.org/docs/rules/no-whitespace-before-property
|
|
129
|
+
*/
|
|
130
|
+
'no-whitespace-before-property': 'error',
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 避免使用不带 await 表达式的 async 函数
|
|
134
|
+
*
|
|
135
|
+
* https://eslint.org/docs/rules/require-await
|
|
136
|
+
*/
|
|
137
|
+
'require-await': 'warn',
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 避免函数内没有yield的 generator 函数
|
|
141
|
+
*
|
|
142
|
+
* https://eslint.org/docs/rules/require-yield
|
|
143
|
+
*/
|
|
144
|
+
'require-yield': 'error',
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 限制 case 语句的冒号右边有空格
|
|
148
|
+
*
|
|
149
|
+
* https://eslint.org/docs/rules/switch-colon-spacing
|
|
150
|
+
*/
|
|
151
|
+
'switch-colon-spacing': ['error', { before: false, after: true }],
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 避免使用异步函数作为 Promise executor
|
|
155
|
+
*
|
|
156
|
+
* https://eslint.org/docs/rules/no-async-promise-executor
|
|
157
|
+
*/
|
|
158
|
+
'no-async-promise-executor': 'error',
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 限制在 getter 属性中出现一个 return 语句
|
|
162
|
+
*
|
|
163
|
+
* https://eslint.org/docs/rules/getter-return
|
|
164
|
+
*/
|
|
165
|
+
'getter-return': 'error',
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 避免在构造函数中返回值
|
|
169
|
+
*
|
|
170
|
+
* https://eslint.org/docs/rules/no-constructor-return
|
|
171
|
+
*/
|
|
172
|
+
'no-constructor-return': 'error',
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 避免重复的 if-else-if 条件
|
|
176
|
+
*
|
|
177
|
+
* https://eslint.org/docs/rules/no-dupe-else-if
|
|
178
|
+
*/
|
|
179
|
+
'no-dupe-else-if': 'error',
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* 避免对 import 声明重新赋值
|
|
183
|
+
*
|
|
184
|
+
* https://eslint.org/docs/rules/no-import-assign
|
|
185
|
+
*/
|
|
186
|
+
'no-import-assign': 'error',
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 避免在正则表达式中使用多余的反斜杠
|
|
190
|
+
*
|
|
191
|
+
* https://eslint.org/docs/rules/no-useless-backreference
|
|
192
|
+
*/
|
|
193
|
+
'no-useless-backreference': 'error',
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 警告在非空文件末尾至少存在一行空行
|
|
197
|
+
*
|
|
198
|
+
* https://eslint.org/docs/rules/eol-last
|
|
199
|
+
*/
|
|
200
|
+
'eol-last': ['warn', 'always'],
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* 避免使用非字符串连接而使用模板字面量
|
|
204
|
+
*
|
|
205
|
+
* https://eslint.org/docs/rules/prefer-template
|
|
206
|
+
*/
|
|
207
|
+
'prefer-template': 'error',
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* 限制2个缩进
|
|
211
|
+
*
|
|
212
|
+
* https://eslint.org/docs/rules/no-mixed-spaces-and-tabs
|
|
213
|
+
*/
|
|
214
|
+
indent: [
|
|
215
|
+
'error',
|
|
216
|
+
2,
|
|
217
|
+
{
|
|
218
|
+
SwitchCase: 1
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 限制 generator 函数星号后面有空格
|
|
224
|
+
*
|
|
225
|
+
* https://eslint.org/docs/rules/generator-star-spacing
|
|
226
|
+
*/
|
|
227
|
+
'generator-star-spacing': [
|
|
228
|
+
'error',
|
|
229
|
+
{
|
|
230
|
+
before: false,
|
|
231
|
+
after: true
|
|
232
|
+
}
|
|
233
|
+
],
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* 避免在括号内使用空格
|
|
237
|
+
*
|
|
238
|
+
* https://eslint.org/docs/rules/array-bracket-spacing
|
|
239
|
+
*/
|
|
240
|
+
'array-bracket-spacing': ['error', 'never'],
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* 限制箭头函数的参数被圆括号包围
|
|
244
|
+
*
|
|
245
|
+
* https://eslint.org/docs/rules/arrow-parens
|
|
246
|
+
*/
|
|
247
|
+
'arrow-parens': ['error', 'always'],
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 限制使用 console.error、console.warn、console.info
|
|
251
|
+
*
|
|
252
|
+
* https://eslint.org/docs/rules/no-console
|
|
253
|
+
*/
|
|
254
|
+
'no-console': [
|
|
255
|
+
'warn',
|
|
256
|
+
{
|
|
257
|
+
allow: ['error', 'warn', 'info']
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* 警告在条件中使用常量表达式
|
|
263
|
+
*
|
|
264
|
+
* https://eslint.org/docs/rules/no-constant-condition
|
|
265
|
+
*/
|
|
266
|
+
'no-constant-condition': 'warn',
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* 限制尾部没有逗号
|
|
270
|
+
*
|
|
271
|
+
* https://eslint.org/docs/rules/comma-dangle
|
|
272
|
+
*/
|
|
273
|
+
'comma-dangle': ['error', 'never'],
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* 避免使用 debugger
|
|
277
|
+
*
|
|
278
|
+
* https://eslint.org/docs/rules/no-debugger
|
|
279
|
+
*/
|
|
280
|
+
'no-debugger': 'error',
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* 警告在对象字面量中出现重复的键
|
|
284
|
+
*
|
|
285
|
+
* https://eslint.org/docs/rules/no-dupe-keys
|
|
286
|
+
*/
|
|
287
|
+
'no-dupe-keys': 'warn',
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* 避免正则表达式中出现空字符集
|
|
291
|
+
*
|
|
292
|
+
* https://eslint.org/docs/rules/no-empty-character-class
|
|
293
|
+
*/
|
|
294
|
+
'no-empty-character-class': 'error',
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* 避免对 catch 子句中的异常重新赋值
|
|
298
|
+
*
|
|
299
|
+
* https://eslint.org/docs/rules/no-ex-assign
|
|
300
|
+
*/
|
|
301
|
+
'no-ex-assign': 'error',
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* 警告出现不必要的布尔类型转换
|
|
305
|
+
*
|
|
306
|
+
* https://eslint.org/docs/rules/no-extra-boolean-cast
|
|
307
|
+
*/
|
|
308
|
+
'no-extra-boolean-cast': 'warn',
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* 警告对 function 声明重新赋值
|
|
312
|
+
*
|
|
313
|
+
* https://eslint.org/docs/rules/no-func-assign
|
|
314
|
+
*/
|
|
315
|
+
'no-func-assign': 'warn',
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* 警告在嵌套的语句块中出现变量或 function 声明
|
|
319
|
+
*
|
|
320
|
+
* https://eslint.org/docs/rules/no-inner-declarations
|
|
321
|
+
*/
|
|
322
|
+
'no-inner-declarations': 'warn',
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* 避免使用无效的正则表达式在 RegExp 构造函数中
|
|
326
|
+
*
|
|
327
|
+
* https://eslint.org/docs/rules/no-invalid-regexp
|
|
328
|
+
*/
|
|
329
|
+
'no-invalid-regexp': 'error',
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* 避免全局对象被当作函数调用
|
|
333
|
+
*
|
|
334
|
+
* https://eslint.org/docs/rules/no-obj-calls
|
|
335
|
+
*/
|
|
336
|
+
'no-obj-calls': 'error',
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* 避免使用稀疏数组
|
|
340
|
+
*
|
|
341
|
+
* https://eslint.org/docs/rules/no-sparse-arrays
|
|
342
|
+
*/
|
|
343
|
+
'no-sparse-arrays': 'error',
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* 避免在 return、throw、continue 和 break 语句后出现不被执行的代码
|
|
347
|
+
*
|
|
348
|
+
* https://eslint.org/docs/rules/no-unreachable
|
|
349
|
+
*/
|
|
350
|
+
'no-unreachable': 'error',
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* 避免循环中只有一次迭代
|
|
354
|
+
*
|
|
355
|
+
* https://eslint.org/docs/rules/no-unreachable-loop
|
|
356
|
+
*/
|
|
357
|
+
'no-unreachable-loop': 'error',
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* 限制使用 isNaN()检查 NaN
|
|
361
|
+
*
|
|
362
|
+
* https://eslint.org/docs/rules/use-isnan
|
|
363
|
+
*/
|
|
364
|
+
'use-isnan': 'error',
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* 限制使用 typeof 表达式与有效的字符串进行比较
|
|
368
|
+
*
|
|
369
|
+
* https://eslint.org/docs/rules/valid-typeof
|
|
370
|
+
*/
|
|
371
|
+
'valid-typeof': 'error',
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* 避免省略花括号当一个块只包含一条语句时
|
|
375
|
+
*
|
|
376
|
+
* https://eslint.org/docs/rules/curly
|
|
377
|
+
*/
|
|
378
|
+
curly: ['error', 'all'],
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* 限制使用 === 和 !==
|
|
382
|
+
*
|
|
383
|
+
* https://eslint.org/docs/rules/eqeqeq
|
|
384
|
+
*/
|
|
385
|
+
eqeqeq: ['error', 'allow-null'],
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* 警告 for-in 中没有判断是否是自身属性
|
|
389
|
+
*
|
|
390
|
+
* https://eslint.org/docs/rules/guard-for-in
|
|
391
|
+
*/
|
|
392
|
+
'guard-for-in': 'warn',
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* 警告在 else 前有 return
|
|
396
|
+
*
|
|
397
|
+
* https://eslint.org/docs/rules/no-else-return
|
|
398
|
+
*/
|
|
399
|
+
'no-else-return': 'warn',
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* 警告使用了非循环使用标签
|
|
403
|
+
*
|
|
404
|
+
* https://eslint.org/docs/rules/no-labels
|
|
405
|
+
*/
|
|
406
|
+
'no-labels': [
|
|
407
|
+
'warn',
|
|
408
|
+
{
|
|
409
|
+
allowLoop: true
|
|
410
|
+
}
|
|
411
|
+
],
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* 警告使用了 eval()
|
|
415
|
+
*
|
|
416
|
+
* https://eslint.org/docs/rules/no-eval
|
|
417
|
+
*/
|
|
418
|
+
'no-eval': 'warn',
|
|
419
|
+
|
|
420
|
+
// /**
|
|
421
|
+
// * 避免扩展原生对象
|
|
422
|
+
// *
|
|
423
|
+
// * https://eslint.org/docs/rules/no-extend-native
|
|
424
|
+
// */
|
|
425
|
+
// 'no-extend-native': 'error',
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* 警告使用了不必要的函数绑定
|
|
429
|
+
*
|
|
430
|
+
* https://eslint.org/docs/rules/no-extra-bind
|
|
431
|
+
*/
|
|
432
|
+
'no-extra-bind': 'warn',
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* 警告使用了隐式的 eval()
|
|
436
|
+
*
|
|
437
|
+
* https://eslint.org/docs/rules/no-implied-eval
|
|
438
|
+
*/
|
|
439
|
+
'no-implied-eval': 'warn',
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* 避免使用废弃的迭代器属性 __iterator__
|
|
443
|
+
*
|
|
444
|
+
* https://eslint.org/docs/rules/no-iterator
|
|
445
|
+
*/
|
|
446
|
+
'no-iterator': 'error',
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* 警告使用了不规则的空白
|
|
450
|
+
*
|
|
451
|
+
* https://eslint.org/docs/rules/no-irregular-whitespace
|
|
452
|
+
*/
|
|
453
|
+
'no-irregular-whitespace': 'warn',
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* 警告使用了不必要的嵌套块
|
|
457
|
+
*
|
|
458
|
+
* https://eslint.org/docs/rules/no-lone-blocks
|
|
459
|
+
*/
|
|
460
|
+
'no-lone-blocks': 'warn',
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* 警告循环中存在函数
|
|
464
|
+
*
|
|
465
|
+
* https://eslint.org/docs/rules/no-loop-func
|
|
466
|
+
*/
|
|
467
|
+
'no-loop-func': 'warn',
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* 警告多行字符串 \
|
|
471
|
+
*
|
|
472
|
+
* https://eslint.org/docs/rules/no-multi-str
|
|
473
|
+
*/
|
|
474
|
+
'no-multi-str': 'warn',
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* 避免重新赋值原生对象
|
|
478
|
+
*
|
|
479
|
+
* https://eslint.org/docs/rules/no-native-reassign
|
|
480
|
+
*/
|
|
481
|
+
'no-native-reassign': 'error',
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* 避免使用原始包装实例
|
|
485
|
+
*
|
|
486
|
+
* https://eslint.org/docs/rules/no-new-wrappers
|
|
487
|
+
*/
|
|
488
|
+
'no-new-wrappers': 'error',
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* 警告使用了八进制字面量
|
|
492
|
+
*
|
|
493
|
+
* https://eslint.org/docs/rules/no-octal
|
|
494
|
+
*/
|
|
495
|
+
'no-octal': 'warn',
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* 警告在字符串字面量中使用八进制转义序列
|
|
499
|
+
*
|
|
500
|
+
* https://eslint.org/docs/rules/no-octal-escape
|
|
501
|
+
*/
|
|
502
|
+
'no-octal-escape': 'warn',
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* 避免使用 __proto__
|
|
506
|
+
*
|
|
507
|
+
* https://eslint.org/docs/rules/no-proto
|
|
508
|
+
*/
|
|
509
|
+
'no-proto': 'error',
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* 警告 var 重新声明变量
|
|
513
|
+
*
|
|
514
|
+
* https://eslint.org/docs/rules/no-redeclare
|
|
515
|
+
*/
|
|
516
|
+
'no-redeclare': 'warn',
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* 避免比较自身
|
|
520
|
+
*
|
|
521
|
+
* https://eslint.org/docs/rules/no-self-compare
|
|
522
|
+
*/
|
|
523
|
+
'no-self-compare': 'error',
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* 限制使用更简单结构的三元操作符
|
|
527
|
+
*
|
|
528
|
+
* https://eslint.org/docs/rules/no-unneeded-ternary
|
|
529
|
+
*/
|
|
530
|
+
'no-unneeded-ternary': 'error',
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* 警告使用了 with 语句
|
|
534
|
+
*
|
|
535
|
+
* https://eslint.org/docs/rules/no-with
|
|
536
|
+
*/
|
|
537
|
+
'no-with': 'warn',
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* 限制调用 parseInt() 函数时传入第二个参数
|
|
541
|
+
*
|
|
542
|
+
* https://eslint.org/docs/rules/no-with
|
|
543
|
+
*/
|
|
544
|
+
radix: 'error',
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* 限制把立即执行的函数包裹起来再执行
|
|
548
|
+
*
|
|
549
|
+
* https://eslint.org/docs/rules/wrap-iife
|
|
550
|
+
*/
|
|
551
|
+
'wrap-iife': ['error', 'any'],
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* 避免使用 delete 删除变量
|
|
555
|
+
*
|
|
556
|
+
* https://eslint.org/docs/rules/no-delete-var
|
|
557
|
+
*/
|
|
558
|
+
'no-delete-var': 'warn',
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* 避免 function 定义中出现重复的参数名
|
|
562
|
+
*
|
|
563
|
+
* https://eslint.org/docs/rules/no-dupe-args
|
|
564
|
+
*/
|
|
565
|
+
'no-dupe-args': 'error',
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* 避免出现重复的 case 条件
|
|
569
|
+
*
|
|
570
|
+
* https://eslint.org/docs/rules/no-duplicate-case
|
|
571
|
+
*/
|
|
572
|
+
'no-duplicate-case': 'error',
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* 警告标签与变量同名
|
|
576
|
+
*
|
|
577
|
+
* https://eslint.org/docs/rules/no-label-var
|
|
578
|
+
*/
|
|
579
|
+
'no-label-var': 'warn',
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* 避免变量名或者函数名与全局对象属性、关键字相同
|
|
583
|
+
*
|
|
584
|
+
* https://eslint.org/docs/rules/no-shadow-restricted-names
|
|
585
|
+
*/
|
|
586
|
+
'no-shadow-restricted-names': 'error',
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* 避免使用未声明的变量
|
|
590
|
+
*
|
|
591
|
+
* https://eslint.org/docs/rules/no-undef
|
|
592
|
+
*/
|
|
593
|
+
'no-undef': 'error',
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* 警告定义变量的初始值为 undefined
|
|
597
|
+
*
|
|
598
|
+
* https://eslint.org/docs/rules/no-undef-init
|
|
599
|
+
*/
|
|
600
|
+
'no-undef-init': 'warn',
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* 警告当前作用域中声明的变量未使用,不检查传递的参数是否被使用
|
|
604
|
+
*
|
|
605
|
+
* https://eslint.org/docs/rules/no-unused-vars
|
|
606
|
+
*/
|
|
607
|
+
'no-unused-vars': [
|
|
608
|
+
'warn',
|
|
609
|
+
{
|
|
610
|
+
vars: 'local',
|
|
611
|
+
args: 'none'
|
|
612
|
+
}
|
|
613
|
+
],
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* 避免非函数在定义前使用
|
|
617
|
+
*
|
|
618
|
+
* https://eslint.org/docs/rules/no-use-before-define
|
|
619
|
+
*/
|
|
620
|
+
'no-use-before-define': ['error', 'nofunc'],
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* 限制大括号风格,if-else中的else语句,连同catch 和 finally,都必须在右括号后另起一行
|
|
624
|
+
*
|
|
625
|
+
* https://eslint.org/docs/rules/brace-style
|
|
626
|
+
*/
|
|
627
|
+
'brace-style': ['warn', 'stroustrup'],
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* 限制在逗号后加空格
|
|
631
|
+
* 默认选项 { "before": false, "after": true }
|
|
632
|
+
*
|
|
633
|
+
* https://eslint.org/docs/rules/comma-spacing
|
|
634
|
+
*/
|
|
635
|
+
'comma-spacing': 'error',
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* 限制逗号风格,要求逗号放在数组元素、对象属性或变量声明之后,且在同一行
|
|
639
|
+
*
|
|
640
|
+
* https://eslint.org/docs/rules/comma-style
|
|
641
|
+
*/
|
|
642
|
+
'comma-style': ['error', 'last'],
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* 警告使用了无参构造函数时未带括号
|
|
646
|
+
*
|
|
647
|
+
* https://eslint.org/docs/rules/new-parens
|
|
648
|
+
*/
|
|
649
|
+
'new-parens': 'warn',
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* 避免使用 Array 构造函数
|
|
653
|
+
*
|
|
654
|
+
* https://eslint.org/docs/rules/no-array-constructor
|
|
655
|
+
*/
|
|
656
|
+
'no-array-constructor': 'error',
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* 避免一行出现多个空格,除了对象属性定义、二元表达式、定义变量对齐
|
|
660
|
+
*
|
|
661
|
+
* https://eslint.org/docs/rules/no-multi-spaces
|
|
662
|
+
*/
|
|
663
|
+
'no-multi-spaces': [
|
|
664
|
+
'error',
|
|
665
|
+
{
|
|
666
|
+
exceptions: {
|
|
667
|
+
Property: true,
|
|
668
|
+
BinaryExpression: true,
|
|
669
|
+
VariableDeclarator: true
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
],
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* 避免使用 Object 构造函数
|
|
676
|
+
*
|
|
677
|
+
* https://eslint.org/docs/rules/no-new-object
|
|
678
|
+
*/
|
|
679
|
+
'no-new-object': 'error',
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* 避免函数标识符和其调用之间出现空格
|
|
683
|
+
*
|
|
684
|
+
* https://eslint.org/docs/rules/func-call-spacing
|
|
685
|
+
*/
|
|
686
|
+
'func-call-spacing': 'error',
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* 避免行尾出现空白
|
|
690
|
+
*
|
|
691
|
+
* https://eslint.org/docs/rules/no-trailing-spaces
|
|
692
|
+
*/
|
|
693
|
+
'no-trailing-spaces': 'error',
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* 避免 空格 和 tab 混合缩进
|
|
697
|
+
*
|
|
698
|
+
* https://eslint.org/docs/rules/no-mixed-spaces-and-tabs
|
|
699
|
+
*/
|
|
700
|
+
'no-mixed-spaces-and-tabs': 'error',
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* 限制函数中的变量分开声明
|
|
704
|
+
*
|
|
705
|
+
* https://eslint.org/docs/rules/one-var
|
|
706
|
+
*/
|
|
707
|
+
'one-var': ['error', 'never'],
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* 限制换行符在操作符之前
|
|
711
|
+
*
|
|
712
|
+
* https://eslint.org/docs/rules/operator-linebreak
|
|
713
|
+
*/
|
|
714
|
+
'operator-linebreak': ['error', 'before'],
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* 限制使用单引号除了字符串中包含了一个其它的引号
|
|
718
|
+
*
|
|
719
|
+
* https://eslint.org/docs/rules/quotes
|
|
720
|
+
*/
|
|
721
|
+
quotes: [
|
|
722
|
+
'error',
|
|
723
|
+
'single',
|
|
724
|
+
{ avoidEscape: true }
|
|
725
|
+
],
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* 限制分号后面有空格
|
|
729
|
+
* 默认选项为 {"before": false, "after": true}
|
|
730
|
+
*
|
|
731
|
+
* https://eslint.org/docs/rules/semi-spacing
|
|
732
|
+
*/
|
|
733
|
+
'semi-spacing': 'error',
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* 限制关键字前后出现空格
|
|
737
|
+
*
|
|
738
|
+
* https://eslint.org/docs/rules/keyword-spacing
|
|
739
|
+
*/
|
|
740
|
+
'keyword-spacing': [
|
|
741
|
+
'error',
|
|
742
|
+
{
|
|
743
|
+
before: true,
|
|
744
|
+
after: true
|
|
745
|
+
}
|
|
746
|
+
],
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* 限制对象字面量的键后面无空格,值前面有空格
|
|
750
|
+
* 默认选项 { "beforeColon": false, "afterColon": true, "mode": "strict" }
|
|
751
|
+
*
|
|
752
|
+
* https://eslint.org/docs/rules/keyword-spacing
|
|
753
|
+
*/
|
|
754
|
+
'key-spacing': 'error',
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* 限制函数圆括号之前有一个空格除了具名函数
|
|
758
|
+
*
|
|
759
|
+
* https://eslint.org/docs/rules/space-before-function-paren
|
|
760
|
+
*/
|
|
761
|
+
'space-before-function-paren': [
|
|
762
|
+
'error',
|
|
763
|
+
{
|
|
764
|
+
anonymous: 'always',
|
|
765
|
+
named: 'never',
|
|
766
|
+
asyncArrow: 'always'
|
|
767
|
+
}
|
|
768
|
+
],
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* 限制语句块之前有空格
|
|
772
|
+
*
|
|
773
|
+
* https://eslint.org/docs/rules/space-before-blocks
|
|
774
|
+
*/
|
|
775
|
+
'space-before-blocks': ['error', 'always'],
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* 限制计算属性中无空格
|
|
779
|
+
*
|
|
780
|
+
* https://eslint.org/docs/rules/computed-property-spacing
|
|
781
|
+
*/
|
|
782
|
+
'computed-property-spacing': ['error', 'never'],
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* 限制圆括号内无空格
|
|
786
|
+
*
|
|
787
|
+
* https://eslint.org/docs/rules/space-in-parens
|
|
788
|
+
*/
|
|
789
|
+
'space-in-parens': ['error', 'never'],
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* 限制单词类一元操作符之前或之后有空格,限制一元操作符之前或之后无空格
|
|
793
|
+
* 默认选项 {"words": true, "nonwords": false}
|
|
794
|
+
*
|
|
795
|
+
* https://eslint.org/docs/rules/space-unary-ops
|
|
796
|
+
*/
|
|
797
|
+
'space-unary-ops': 'warn',
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* 限制注释前至少要有一个空格,除了固定的几个字符
|
|
801
|
+
*
|
|
802
|
+
* https://eslint.org/docs/rules/spaced-comment
|
|
803
|
+
*/
|
|
804
|
+
'spaced-comment': [
|
|
805
|
+
'error',
|
|
806
|
+
'always',
|
|
807
|
+
{
|
|
808
|
+
exceptions: [
|
|
809
|
+
'-',
|
|
810
|
+
'+',
|
|
811
|
+
'\'',
|
|
812
|
+
'#'
|
|
813
|
+
],
|
|
814
|
+
block: {
|
|
815
|
+
balanced: true
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
],
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* 限制行的最大长度
|
|
822
|
+
*
|
|
823
|
+
* https://eslint.org/docs/rules/max-len
|
|
824
|
+
*/
|
|
825
|
+
'max-len': [
|
|
826
|
+
'error',
|
|
827
|
+
{
|
|
828
|
+
code: 120,
|
|
829
|
+
tabWidth: 4,
|
|
830
|
+
ignorePattern: 'data:image\\/',
|
|
831
|
+
ignoreUrls: true,
|
|
832
|
+
ignoreRegExpLiterals: true
|
|
833
|
+
}
|
|
834
|
+
],
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* 限制中缀操作符周围有空格
|
|
838
|
+
*
|
|
839
|
+
* https://eslint.org/docs/rules/space-infix-ops
|
|
840
|
+
*/
|
|
841
|
+
'space-infix-ops': 'error',
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* 限制使用点号访问属性,部分关键字除外
|
|
845
|
+
* 默认选项 { "allowKeywords": true }
|
|
846
|
+
*
|
|
847
|
+
* https://eslint.org/docs/rules/dot-notation
|
|
848
|
+
*/
|
|
849
|
+
'dot-notation': [
|
|
850
|
+
'error',
|
|
851
|
+
{
|
|
852
|
+
allowPattern: '^catch$'
|
|
853
|
+
}
|
|
854
|
+
],
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* 限制箭头函数的箭头之前和之后有空格
|
|
858
|
+
* 默认选项 { "before": true, "after": true }
|
|
859
|
+
*
|
|
860
|
+
* https://eslint.org/docs/rules/arrow-spacing
|
|
861
|
+
*/
|
|
862
|
+
'arrow-spacing': 'error',
|
|
863
|
+
|
|
864
|
+
/**
|
|
865
|
+
* 限制派生类中的构造函数必须调用 super()
|
|
866
|
+
*
|
|
867
|
+
* https://eslint.org/docs/rules/constructor-super
|
|
868
|
+
*/
|
|
869
|
+
'constructor-super': 'error',
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* 避免可能与比较操作符相混淆的地方使用箭头函数
|
|
873
|
+
* 默认选项 { "allowParens": true }
|
|
874
|
+
*
|
|
875
|
+
* https://eslint.org/docs/rules/no-confusing-arrow
|
|
876
|
+
*/
|
|
877
|
+
'no-confusing-arrow': 'error',
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* 警告修改类声明的变量
|
|
881
|
+
*
|
|
882
|
+
* https://eslint.org/docs/rules/no-class-assign
|
|
883
|
+
*/
|
|
884
|
+
'no-class-assign': 'warn',
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* 避免修改 const 声明的变量
|
|
888
|
+
*
|
|
889
|
+
* https://eslint.org/docs/rules/no-const-assign
|
|
890
|
+
*/
|
|
891
|
+
'no-const-assign': 'error',
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* 警告类成员中重复的名称
|
|
895
|
+
*
|
|
896
|
+
* https://eslint.org/docs/rules/no-dupe-class-members
|
|
897
|
+
*/
|
|
898
|
+
'no-dupe-class-members': 'warn',
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* 警告在构造函数中调用super()之前使用this或super
|
|
902
|
+
*
|
|
903
|
+
* https://eslint.org/docs/rules/no-this-before-super
|
|
904
|
+
*/
|
|
905
|
+
'no-this-before-super': 'warn',
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* 警告使用了 let 或 const 非 var
|
|
909
|
+
*
|
|
910
|
+
* https://eslint.org/docs/rules/no-var
|
|
911
|
+
*/
|
|
912
|
+
'no-var': 'warn',
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* 警告重复导入
|
|
916
|
+
*
|
|
917
|
+
* https://eslint.org/docs/rules/no-duplicate-imports
|
|
918
|
+
*/
|
|
919
|
+
'no-duplicate-imports': 'warn',
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* 限制一行只有一条语句
|
|
923
|
+
* 默认选项 { "max": 1 }
|
|
924
|
+
*
|
|
925
|
+
* https://eslint.org/docs/rules/max-statements-per-line
|
|
926
|
+
*/
|
|
927
|
+
'max-statements-per-line': 'error',
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* 警告使用了不必要的构造函数
|
|
931
|
+
*
|
|
932
|
+
* https://eslint.org/docs/rules/no-useless-constructor
|
|
933
|
+
*/
|
|
934
|
+
'no-useless-constructor': 'warn',
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* 限制对象属性在有需要的情况下使用引号
|
|
938
|
+
*
|
|
939
|
+
* https://eslint.org/docs/rules/quote-props
|
|
940
|
+
*/
|
|
941
|
+
'quote-props': ['error', 'as-needed']
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
|