eslint-config-tencent 1.0.2 → 1.0.3
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-legacy.js +1 -16
- package/base.js +1 -685
- package/import.js +1 -23
- package/index.js +1 -3
- package/package.json +6 -6
- package/prettier.js +1 -75
- package/react.js +1 -3
- package/ts-legacy.js +1 -19
- package/ts.js +1 -419
package/base-legacy.js
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
module.exports
|
|
2
|
-
extends: ['./base'],
|
|
3
|
-
rules: {
|
|
4
|
-
// 豁免规则
|
|
5
|
-
camelCase: 'off',
|
|
6
|
-
eqeqeq: 'off',
|
|
7
|
-
'func-type': 'off',
|
|
8
|
-
'max-len': 'off',
|
|
9
|
-
'no-param-reassign': 'off',
|
|
10
|
-
'no-underscore-dangle': 'off',
|
|
11
|
-
'no-var': 'off',
|
|
12
|
-
'prefer-const': 'off',
|
|
13
|
-
'prefer-template': 'off',
|
|
14
|
-
'template-curly-spacing': 'off',
|
|
15
|
-
},
|
|
16
|
-
};
|
|
1
|
+
module.exports={extends:["./base"],rules:{camelCase:"off",eqeqeq:"off","func-type":"off","max-len":"off","no-param-reassign":"off","no-underscore-dangle":"off","no-var":"off","prefer-const":"off","prefer-template":"off","template-curly-spacing":"off"}};
|
package/base.js
CHANGED
|
@@ -1,685 +1 @@
|
|
|
1
|
-
module.exports
|
|
2
|
-
parser: '@babel/eslint-parser',
|
|
3
|
-
parserOptions: {
|
|
4
|
-
ecmaVersion: 2019,
|
|
5
|
-
// ECMAScript modules 模式
|
|
6
|
-
sourceType: 'module',
|
|
7
|
-
ecmaFeatures: {
|
|
8
|
-
// 不允许 return 语句出现在 global 环境下
|
|
9
|
-
globalReturn: false,
|
|
10
|
-
// 开启全局 script 模式
|
|
11
|
-
impliedStrict: true,
|
|
12
|
-
jsx: true
|
|
13
|
-
},
|
|
14
|
-
// 即使没有 babelrc 配置文件,也使用 babel-eslint 来解析
|
|
15
|
-
requireConfigFile: false,
|
|
16
|
-
// 仅允许 import export 语句出现在模块的顶层
|
|
17
|
-
allowImportExportEverywhere: false
|
|
18
|
-
},
|
|
19
|
-
env: {
|
|
20
|
-
browser: true,
|
|
21
|
-
node: true,
|
|
22
|
-
commonjs: true,
|
|
23
|
-
es6: true
|
|
24
|
-
},
|
|
25
|
-
// 以当前目录为根目录,不再向上查找 .eslintrc.js
|
|
26
|
-
root: true,rules:{
|
|
27
|
-
/**
|
|
28
|
-
* 不要在中括号中添加空格
|
|
29
|
-
*/
|
|
30
|
-
'array-bracket-spacing': [
|
|
31
|
-
"error",
|
|
32
|
-
"never"
|
|
33
|
-
],
|
|
34
|
-
/**
|
|
35
|
-
* 数组的方法除了 forEach 之外,回调函数必须有返回值
|
|
36
|
-
*/
|
|
37
|
-
'array-callback-return': "warn",
|
|
38
|
-
/**
|
|
39
|
-
* 要求箭头函数体使用大括号
|
|
40
|
-
*/
|
|
41
|
-
'arrow-body-style': [
|
|
42
|
-
"warn",
|
|
43
|
-
"as-needed"
|
|
44
|
-
],
|
|
45
|
-
/**
|
|
46
|
-
* 要求箭头函数的参数使用圆括号
|
|
47
|
-
*/
|
|
48
|
-
'arrow-parens': [
|
|
49
|
-
"warn",
|
|
50
|
-
"as-needed",
|
|
51
|
-
{
|
|
52
|
-
"requireForBlockBody": true
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
/**
|
|
56
|
-
* 强制箭头函数的箭头前后使用一致的空格
|
|
57
|
-
*/
|
|
58
|
-
'arrow-spacing': "warn",
|
|
59
|
-
/**
|
|
60
|
-
* 要求打开的块标志和同一行上的标志拥有一致的间距。此规则还会在同一行关闭的块标记和前边的标记强制实施一致的间距。
|
|
61
|
-
*/
|
|
62
|
-
'block-spacing': "error",
|
|
63
|
-
/**
|
|
64
|
-
* 强制在代码块中使用一致的大括号风格
|
|
65
|
-
*/
|
|
66
|
-
'brace-style': "error",
|
|
67
|
-
/**
|
|
68
|
-
* 使用驼峰命名法(camelCase)命名对象、函数和实例。
|
|
69
|
-
*/
|
|
70
|
-
'camelcase': [
|
|
71
|
-
"error",
|
|
72
|
-
{
|
|
73
|
-
"ignoreDestructuring": true,
|
|
74
|
-
"properties": "never"
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
/**
|
|
78
|
-
* 添加尾随逗号
|
|
79
|
-
*/
|
|
80
|
-
'comma-dangle': [
|
|
81
|
-
"warn",
|
|
82
|
-
"always-multiline"
|
|
83
|
-
],
|
|
84
|
-
/**
|
|
85
|
-
* 强制在逗号前后使用一致的空格
|
|
86
|
-
*/
|
|
87
|
-
'comma-spacing': [
|
|
88
|
-
"error",
|
|
89
|
-
{
|
|
90
|
-
"before": false,
|
|
91
|
-
"after": true
|
|
92
|
-
}
|
|
93
|
-
],
|
|
94
|
-
/**
|
|
95
|
-
* 强制使用一致的逗号风格
|
|
96
|
-
*/
|
|
97
|
-
'comma-style': [
|
|
98
|
-
"error",
|
|
99
|
-
"last"
|
|
100
|
-
],
|
|
101
|
-
/**
|
|
102
|
-
* 强制在计算的属性的方括号中使用一致的空格
|
|
103
|
-
*/
|
|
104
|
-
'computed-property-spacing': [
|
|
105
|
-
"warn",
|
|
106
|
-
"never"
|
|
107
|
-
],
|
|
108
|
-
/**
|
|
109
|
-
* 禁止使用 foo['bar'],必须写成 foo.bar
|
|
110
|
-
*/
|
|
111
|
-
'dot-notation': "warn",
|
|
112
|
-
/**
|
|
113
|
-
* 要求或禁止文件末尾存在空行
|
|
114
|
-
*/
|
|
115
|
-
'eol-last': [
|
|
116
|
-
"error",
|
|
117
|
-
"always"
|
|
118
|
-
],
|
|
119
|
-
/**
|
|
120
|
-
* 必须使用 === 或 !==,禁止使用 == 或 !=
|
|
121
|
-
*/
|
|
122
|
-
'eqeqeq': [
|
|
123
|
-
"warn",
|
|
124
|
-
"always"
|
|
125
|
-
],
|
|
126
|
-
/**
|
|
127
|
-
* 要求或禁止在函数标识符和其调用之间有空格
|
|
128
|
-
*/
|
|
129
|
-
'func-call-spacing': [
|
|
130
|
-
"error",
|
|
131
|
-
"never"
|
|
132
|
-
],
|
|
133
|
-
/**
|
|
134
|
-
* 必须只使用函数声明或只使用函数表达式
|
|
135
|
-
*/
|
|
136
|
-
'func-style': [
|
|
137
|
-
"off",
|
|
138
|
-
"expression"
|
|
139
|
-
],
|
|
140
|
-
/**
|
|
141
|
-
* 强制在函数括号内使用一致的换行
|
|
142
|
-
*/
|
|
143
|
-
'function-paren-newline': [
|
|
144
|
-
"warn",
|
|
145
|
-
"multiline"
|
|
146
|
-
],
|
|
147
|
-
/**
|
|
148
|
-
* 强制 generator 函数中 * 号周围使用一致的空格
|
|
149
|
-
*/
|
|
150
|
-
'generator-star-spacing': [
|
|
151
|
-
"warn",
|
|
152
|
-
{
|
|
153
|
-
"before": false,
|
|
154
|
-
"after": true
|
|
155
|
-
}
|
|
156
|
-
],
|
|
157
|
-
/**
|
|
158
|
-
* 限制变量名长度
|
|
159
|
-
*/
|
|
160
|
-
'id-length': "off",
|
|
161
|
-
/**
|
|
162
|
-
* 强制隐式返回的箭头函数体的位置
|
|
163
|
-
*/
|
|
164
|
-
'implicit-arrow-linebreak': [
|
|
165
|
-
"warn",
|
|
166
|
-
"beside"
|
|
167
|
-
],
|
|
168
|
-
/**
|
|
169
|
-
* 使用 2 个空格缩进
|
|
170
|
-
*/
|
|
171
|
-
'indent': [
|
|
172
|
-
"warn",
|
|
173
|
-
2,
|
|
174
|
-
{
|
|
175
|
-
"SwitchCase": 1,
|
|
176
|
-
"VariableDeclarator": 1,
|
|
177
|
-
"outerIIFEBody": 1,
|
|
178
|
-
"FunctionDeclaration": {
|
|
179
|
-
"parameters": 1,
|
|
180
|
-
"body": 1
|
|
181
|
-
},
|
|
182
|
-
"FunctionExpression": {
|
|
183
|
-
"parameters": 1,
|
|
184
|
-
"body": 1
|
|
185
|
-
},
|
|
186
|
-
"CallExpression": {
|
|
187
|
-
"arguments": 1
|
|
188
|
-
},
|
|
189
|
-
"ArrayExpression": 1,
|
|
190
|
-
"ObjectExpression": 1,
|
|
191
|
-
"ImportDeclaration": 1,
|
|
192
|
-
"flatTernaryExpressions": false,
|
|
193
|
-
"ignoredNodes": [
|
|
194
|
-
"JSXElement",
|
|
195
|
-
"JSXElement > *",
|
|
196
|
-
"JSXAttribute",
|
|
197
|
-
"JSXIdentifier",
|
|
198
|
-
"JSXNamespacedName",
|
|
199
|
-
"JSXMemberExpression",
|
|
200
|
-
"JSXSpreadAttribute",
|
|
201
|
-
"JSXExpressionContainer",
|
|
202
|
-
"JSXOpeningElement",
|
|
203
|
-
"JSXClosingElement",
|
|
204
|
-
"JSXFragment",
|
|
205
|
-
"JSXOpeningFragment",
|
|
206
|
-
"JSXClosingFragment",
|
|
207
|
-
"JSXText",
|
|
208
|
-
"JSXEmptyExpression",
|
|
209
|
-
"JSXSpreadChild"
|
|
210
|
-
],
|
|
211
|
-
"ignoreComments": false
|
|
212
|
-
}
|
|
213
|
-
],
|
|
214
|
-
/**
|
|
215
|
-
* 强制在对象字面量的属性中键和值之间使用一致的间距
|
|
216
|
-
*/
|
|
217
|
-
'key-spacing': "error",
|
|
218
|
-
/**
|
|
219
|
-
* 强制在关键字前后使用一致的空格
|
|
220
|
-
*/
|
|
221
|
-
'keyword-spacing': [
|
|
222
|
-
"error",
|
|
223
|
-
{
|
|
224
|
-
"overrides": {
|
|
225
|
-
"if": {
|
|
226
|
-
"after": true
|
|
227
|
-
},
|
|
228
|
-
"for": {
|
|
229
|
-
"after": true
|
|
230
|
-
},
|
|
231
|
-
"while": {
|
|
232
|
-
"after": true
|
|
233
|
-
},
|
|
234
|
-
"else": {
|
|
235
|
-
"after": true
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
],
|
|
240
|
-
/**
|
|
241
|
-
* 只允许使用 unix 的 LF 作为换行符,Windows 的 CRLF 不可以使用
|
|
242
|
-
*/
|
|
243
|
-
'linebreak-style': [
|
|
244
|
-
"warn",
|
|
245
|
-
"unix"
|
|
246
|
-
],
|
|
247
|
-
/**
|
|
248
|
-
* 强制一行的最大长度,限制单行不能超过100个字符,字符串和正则表达式除外。
|
|
249
|
-
*/
|
|
250
|
-
'max-len': [
|
|
251
|
-
"error",
|
|
252
|
-
{
|
|
253
|
-
"code": 120,
|
|
254
|
-
"ignoreStrings": true,
|
|
255
|
-
"ignoreUrls": true,
|
|
256
|
-
"ignoreRegExpLiterals": true,
|
|
257
|
-
"ignoreTemplateLiterals": true
|
|
258
|
-
}
|
|
259
|
-
],
|
|
260
|
-
/**
|
|
261
|
-
* 只有在命名构造器或者类的时候,才用帕斯卡拼命名法(PascalCase),即首字母大写。
|
|
262
|
-
*/
|
|
263
|
-
'new-cap': [
|
|
264
|
-
"error",
|
|
265
|
-
{
|
|
266
|
-
"newIsCap": true,
|
|
267
|
-
"newIsCapExceptions": [],
|
|
268
|
-
"capIsNew": false,
|
|
269
|
-
"capIsNewExceptions": [
|
|
270
|
-
"Immutable.Map",
|
|
271
|
-
"Immutable.Set",
|
|
272
|
-
"Immutable.List"
|
|
273
|
-
],
|
|
274
|
-
"properties": false
|
|
275
|
-
}
|
|
276
|
-
],
|
|
277
|
-
/**
|
|
278
|
-
* 在编写多个方法链式调用(超过两个方法链式调用)时。 使用前导点,强调这行是一个方法调用,而不是一个语句。
|
|
279
|
-
*/
|
|
280
|
-
'newline-per-chained-call': [
|
|
281
|
-
"warn",
|
|
282
|
-
{
|
|
283
|
-
"ignoreChainWithDepth": 2
|
|
284
|
-
}
|
|
285
|
-
],
|
|
286
|
-
/**
|
|
287
|
-
* 使用字面量语法创建数组。
|
|
288
|
-
*/
|
|
289
|
-
'no-array-constructor': [
|
|
290
|
-
"error"
|
|
291
|
-
],
|
|
292
|
-
/**
|
|
293
|
-
* 在 case 和 default 的子句中,如果存在声明 (例如. let, const, function, 和 class),使用大括号来创建块级作用域。
|
|
294
|
-
*/
|
|
295
|
-
'no-case-declarations': "error",
|
|
296
|
-
/**
|
|
297
|
-
* 避免搞混箭头函数符号 (=>) 和比较运算符 (<=, >=)。
|
|
298
|
-
*/
|
|
299
|
-
'no-confusing-arrow': "warn",
|
|
300
|
-
/**
|
|
301
|
-
* 禁止对使用 const 定义的常量重新赋值
|
|
302
|
-
*/
|
|
303
|
-
'no-const-assign': "error",
|
|
304
|
-
/**
|
|
305
|
-
* 禁止重复定义类的成员
|
|
306
|
-
*/
|
|
307
|
-
'no-dupe-class-members': "error",
|
|
308
|
-
/**
|
|
309
|
-
* 禁止在 else 内使用 return,必须改为提前结束
|
|
310
|
-
*/
|
|
311
|
-
'no-else-return': [
|
|
312
|
-
"warn",
|
|
313
|
-
{
|
|
314
|
-
"allowElseIf": false
|
|
315
|
-
}
|
|
316
|
-
],
|
|
317
|
-
/**
|
|
318
|
-
* 禁止使用 eval
|
|
319
|
-
*/
|
|
320
|
-
'no-eval': "error",
|
|
321
|
-
/**
|
|
322
|
-
* 不要使用迭代器。
|
|
323
|
-
* @reason 推荐使用 JavaScript 的高阶函数代替 for-in。
|
|
324
|
-
*/
|
|
325
|
-
'no-iterator': "warn",
|
|
326
|
-
/**
|
|
327
|
-
* 禁止在循环内的函数内部出现循环体条件语句中定义的变量
|
|
328
|
-
*/
|
|
329
|
-
'no-loop-func': "error",
|
|
330
|
-
/**
|
|
331
|
-
* 禁止混合使用不同的操作符:
|
|
332
|
-
* - 禁止 `%`, `**` 之间混用
|
|
333
|
-
* - 禁止 `%` 与其它运算符之间混用
|
|
334
|
-
* - 禁止乘除运算符之间混用
|
|
335
|
-
* - 禁止位运算符之间的任何混用
|
|
336
|
-
* - 禁止比较运算符之间混用
|
|
337
|
-
* - 禁止 `&&`, `||` 之间混用
|
|
338
|
-
*/
|
|
339
|
-
'no-mixed-operators': [
|
|
340
|
-
"error",
|
|
341
|
-
{
|
|
342
|
-
"groups": [
|
|
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
|
-
"!=="
|
|
375
|
-
],
|
|
376
|
-
[
|
|
377
|
-
"&&",
|
|
378
|
-
"||"
|
|
379
|
-
]
|
|
380
|
-
],
|
|
381
|
-
"allowSamePrecedence": false
|
|
382
|
-
}
|
|
383
|
-
],
|
|
384
|
-
/**
|
|
385
|
-
* 禁止连续赋值,比如 foo = bar = 1
|
|
386
|
-
*/
|
|
387
|
-
'no-multi-assign': "error",
|
|
388
|
-
/**
|
|
389
|
-
* 不要使用多个空行填充代码。
|
|
390
|
-
*/
|
|
391
|
-
'no-multiple-empty-lines': "error",
|
|
392
|
-
/**
|
|
393
|
-
* 禁止使用嵌套的三元表达式,比如 a ? b : c ? d : e
|
|
394
|
-
*/
|
|
395
|
-
'no-nested-ternary': "warn",
|
|
396
|
-
/**
|
|
397
|
-
* 禁止使用 new Function
|
|
398
|
-
* @reason 这和 eval 是等价的
|
|
399
|
-
*/
|
|
400
|
-
'no-new-func': "error",
|
|
401
|
-
/**
|
|
402
|
-
* 禁止直接 new Object
|
|
403
|
-
*/
|
|
404
|
-
'no-new-object': "error",
|
|
405
|
-
/**
|
|
406
|
-
* 禁止使用 new 来生成 String, Number 或 Boolean
|
|
407
|
-
*/
|
|
408
|
-
'no-new-wrappers': "warn",
|
|
409
|
-
/**
|
|
410
|
-
* 禁止对函数的参数重新赋值
|
|
411
|
-
*/
|
|
412
|
-
'no-param-reassign': [
|
|
413
|
-
"warn",
|
|
414
|
-
{
|
|
415
|
-
"props": true,
|
|
416
|
-
"ignorePropertyModificationsFor": [
|
|
417
|
-
"acc",
|
|
418
|
-
"accumulator",
|
|
419
|
-
"e",
|
|
420
|
-
"ctx",
|
|
421
|
-
"req",
|
|
422
|
-
"request",
|
|
423
|
-
"res",
|
|
424
|
-
"response",
|
|
425
|
-
"$scope",
|
|
426
|
-
"staticContext",
|
|
427
|
-
"state"
|
|
428
|
-
]
|
|
429
|
-
}
|
|
430
|
-
],
|
|
431
|
-
/**
|
|
432
|
-
* 禁止使用 ++ 或 --
|
|
433
|
-
*/
|
|
434
|
-
'no-plusplus': [
|
|
435
|
-
"error",
|
|
436
|
-
{
|
|
437
|
-
"allowForLoopAfterthoughts": true
|
|
438
|
-
}
|
|
439
|
-
],
|
|
440
|
-
/**
|
|
441
|
-
* 禁止使用 hasOwnProperty, isPrototypeOf 或 propertyIsEnumerable
|
|
442
|
-
*/
|
|
443
|
-
'no-prototype-builtins': "error",
|
|
444
|
-
/**
|
|
445
|
-
* 计算指数时,可以使用 ** 运算符。
|
|
446
|
-
*/
|
|
447
|
-
'no-restricted-properties': [
|
|
448
|
-
"warn",
|
|
449
|
-
{
|
|
450
|
-
"object": "Math",
|
|
451
|
-
"property": "pow",
|
|
452
|
-
"message": "Please use ** instand"
|
|
453
|
-
}
|
|
454
|
-
],
|
|
455
|
-
/**
|
|
456
|
-
* 推荐使用 JavaScript 的高阶函数代替 for-in
|
|
457
|
-
*/
|
|
458
|
-
'no-restricted-syntax': [
|
|
459
|
-
"warn",
|
|
460
|
-
{
|
|
461
|
-
"selector": "ForInStatement",
|
|
462
|
-
"message": "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array."
|
|
463
|
-
},
|
|
464
|
-
{
|
|
465
|
-
"selector": "LabeledStatement",
|
|
466
|
-
"message": "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
"selector": "WithStatement",
|
|
470
|
-
"message": "`with` is disallowed in strict mode because it makes code impossible to predict and optimize."
|
|
471
|
-
}
|
|
472
|
-
],
|
|
473
|
-
/**
|
|
474
|
-
* 避免在行尾添加空格。
|
|
475
|
-
*/
|
|
476
|
-
'no-trailing-spaces': "error",
|
|
477
|
-
/**
|
|
478
|
-
* 变量应先声明再使用,禁止引用任何未声明的变量,除非你明确知道引用的变量存在于当前作用域链上。
|
|
479
|
-
*/
|
|
480
|
-
'no-undef': [
|
|
481
|
-
"error"
|
|
482
|
-
],
|
|
483
|
-
/**
|
|
484
|
-
* 禁止变量名出现下划线
|
|
485
|
-
*/
|
|
486
|
-
'no-underscore-dangle': "warn",
|
|
487
|
-
/**
|
|
488
|
-
* 必须使用 !a 替代 a ? false : true
|
|
489
|
-
*/
|
|
490
|
-
'no-unneeded-ternary': "warn",
|
|
491
|
-
/**
|
|
492
|
-
* 已定义的变量必须使用
|
|
493
|
-
* 但不检查最后一个使用的参数之前的参数
|
|
494
|
-
* 也不检查 rest 属性的兄弟属性
|
|
495
|
-
*/
|
|
496
|
-
'no-unused-vars': [
|
|
497
|
-
"error",
|
|
498
|
-
{
|
|
499
|
-
"args": "after-used",
|
|
500
|
-
"ignoreRestSiblings": true
|
|
501
|
-
}
|
|
502
|
-
],
|
|
503
|
-
/**
|
|
504
|
-
* 禁止出现没必要的 constructor
|
|
505
|
-
*/
|
|
506
|
-
'no-useless-constructor': "warn",
|
|
507
|
-
/**
|
|
508
|
-
* 禁止出现没必要的转义
|
|
509
|
-
*/
|
|
510
|
-
'no-useless-escape': "error",
|
|
511
|
-
/**
|
|
512
|
-
* 禁止使用 var
|
|
513
|
-
*/
|
|
514
|
-
'no-var': "error",
|
|
515
|
-
/**
|
|
516
|
-
* 禁止属性前有空白
|
|
517
|
-
*/
|
|
518
|
-
'no-whitespace-before-property': "warn",
|
|
519
|
-
/**
|
|
520
|
-
* 强制单个语句的位置
|
|
521
|
-
*/
|
|
522
|
-
'nonblock-statement-body-position': [
|
|
523
|
-
"error",
|
|
524
|
-
"beside"
|
|
525
|
-
],
|
|
526
|
-
/**
|
|
527
|
-
* 强制在大括号中使用一致的空格
|
|
528
|
-
*/
|
|
529
|
-
'object-curly-spacing': [
|
|
530
|
-
"warn",
|
|
531
|
-
"always"
|
|
532
|
-
],
|
|
533
|
-
/**
|
|
534
|
-
* 将对象方法、属性简写,且间歇属性放在前面。
|
|
535
|
-
*/
|
|
536
|
-
'object-shorthand': "warn",
|
|
537
|
-
/**
|
|
538
|
-
* 禁止变量申明时用逗号一次申明多个
|
|
539
|
-
*/
|
|
540
|
-
'one-var': [
|
|
541
|
-
"warn",
|
|
542
|
-
"never"
|
|
543
|
-
],
|
|
544
|
-
/**
|
|
545
|
-
* 避免在赋值语句 = 前后换行。如果你的代码单行长度超过了 max-len 定义的长度而不得不换行,那么使用括号包裹。
|
|
546
|
-
*/
|
|
547
|
-
'operator-linebreak': [
|
|
548
|
-
"error",
|
|
549
|
-
"before",
|
|
550
|
-
{
|
|
551
|
-
"overrides": {
|
|
552
|
-
"=": "none"
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
],
|
|
556
|
-
/**
|
|
557
|
-
* 要求或禁止块内填充
|
|
558
|
-
*/
|
|
559
|
-
'padded-blocks': [
|
|
560
|
-
"error",
|
|
561
|
-
"never"
|
|
562
|
-
],
|
|
563
|
-
/**
|
|
564
|
-
* 要求回调函数使用箭头函数
|
|
565
|
-
*/
|
|
566
|
-
'prefer-arrow-callback': "warn",
|
|
567
|
-
/**
|
|
568
|
-
* 申明后不再被修改的变量必须使用 const 来申明
|
|
569
|
-
*/
|
|
570
|
-
'prefer-const': [
|
|
571
|
-
"error",
|
|
572
|
-
{
|
|
573
|
-
"destructuring": "any",
|
|
574
|
-
"ignoreReadBeforeAssign": false
|
|
575
|
-
}
|
|
576
|
-
],
|
|
577
|
-
/**
|
|
578
|
-
* 优先使用解构赋值
|
|
579
|
-
*/
|
|
580
|
-
'prefer-destructuring': [
|
|
581
|
-
"warn",
|
|
582
|
-
{
|
|
583
|
-
"VariableDeclarator": {
|
|
584
|
-
"array": false,
|
|
585
|
-
"object": true
|
|
586
|
-
},
|
|
587
|
-
"AssignmentExpression": {
|
|
588
|
-
"array": true,
|
|
589
|
-
"object": false
|
|
590
|
-
}
|
|
591
|
-
},
|
|
592
|
-
{
|
|
593
|
-
"enforceForRenamedProperties": false
|
|
594
|
-
}
|
|
595
|
-
],
|
|
596
|
-
/**
|
|
597
|
-
* 必须使用 ...args 而不是 arguments
|
|
598
|
-
*/
|
|
599
|
-
'prefer-rest-params': "warn",
|
|
600
|
-
/**
|
|
601
|
-
* 必须使用 ... 而不是 apply,比如 foo(...args)
|
|
602
|
-
*/
|
|
603
|
-
'prefer-spread': "warn",
|
|
604
|
-
/**
|
|
605
|
-
* 必须使用模版字符串而不是字符串连接
|
|
606
|
-
*/
|
|
607
|
-
'prefer-template': "error",
|
|
608
|
-
/**
|
|
609
|
-
* 要求对象字面量属性名称用引号括起来
|
|
610
|
-
*/
|
|
611
|
-
'quote-props': [
|
|
612
|
-
"error",
|
|
613
|
-
"as-needed",
|
|
614
|
-
{
|
|
615
|
-
"keywords": false
|
|
616
|
-
}
|
|
617
|
-
],
|
|
618
|
-
/**
|
|
619
|
-
* 使用单引号 '' 定义字符串
|
|
620
|
-
*/
|
|
621
|
-
'quotes': [
|
|
622
|
-
"warn",
|
|
623
|
-
"single",
|
|
624
|
-
{
|
|
625
|
-
"allowTemplateLiterals": false
|
|
626
|
-
}
|
|
627
|
-
],
|
|
628
|
-
/**
|
|
629
|
-
* parseInt 必须传入第二个参数
|
|
630
|
-
*/
|
|
631
|
-
'radix': "warn",
|
|
632
|
-
/**
|
|
633
|
-
* 要加分号
|
|
634
|
-
*/
|
|
635
|
-
'semi': [
|
|
636
|
-
"error",
|
|
637
|
-
"always"
|
|
638
|
-
],
|
|
639
|
-
/**
|
|
640
|
-
* 强制在块之前使用一致的空格
|
|
641
|
-
*/
|
|
642
|
-
'space-before-blocks': "error",
|
|
643
|
-
/**
|
|
644
|
-
* 强制在 function 的左括号之前使用一致的空格
|
|
645
|
-
*/
|
|
646
|
-
'space-before-function-paren': [
|
|
647
|
-
"error",
|
|
648
|
-
{
|
|
649
|
-
"anonymous": "always",
|
|
650
|
-
"named": "never",
|
|
651
|
-
"asyncArrow": "always"
|
|
652
|
-
}
|
|
653
|
-
],
|
|
654
|
-
/**
|
|
655
|
-
* 强制在圆括号内使用一致的空格
|
|
656
|
-
*/
|
|
657
|
-
'space-in-parens': [
|
|
658
|
-
"error",
|
|
659
|
-
"never"
|
|
660
|
-
],
|
|
661
|
-
/**
|
|
662
|
-
* 要求操作符周围有空格
|
|
663
|
-
*/
|
|
664
|
-
'space-infix-ops': "error",
|
|
665
|
-
/**
|
|
666
|
-
* 注释的斜线或 * 后必须有空格
|
|
667
|
-
*/
|
|
668
|
-
'spaced-comment': [
|
|
669
|
-
"error",
|
|
670
|
-
"always"
|
|
671
|
-
],
|
|
672
|
-
/**
|
|
673
|
-
* 要求或禁止模板字符串中的嵌入表达式周围空格的使用
|
|
674
|
-
*/
|
|
675
|
-
'template-curly-spacing': [
|
|
676
|
-
"error",
|
|
677
|
-
"never"
|
|
678
|
-
],
|
|
679
|
-
/**
|
|
680
|
-
* 要求立即执行的函数使用括号括起来
|
|
681
|
-
*/
|
|
682
|
-
'wrap-iife': [
|
|
683
|
-
"error",
|
|
684
|
-
"outside"
|
|
685
|
-
],},};
|
|
1
|
+
module.exports={parser:"@babel/eslint-parser",parserOptions:{ecmaVersion:2019,sourceType:"module",ecmaFeatures:{globalReturn:false,impliedStrict:true,jsx:true},requireConfigFile:false,allowImportExportEverywhere:false},env:{browser:true,node:true,commonjs:true,es6:true},root:true,rules:{"array-bracket-spacing":["error","never"],"array-callback-return":"warn","arrow-body-style":["warn","as-needed"],"arrow-parens":["warn","as-needed",{requireForBlockBody:true}],"arrow-spacing":"warn","block-spacing":"error","brace-style":"error",camelcase:["error",{ignoreDestructuring:true,properties:"never"}],"comma-dangle":["warn","always-multiline"],"comma-spacing":["error",{before:false,after:true}],"comma-style":["error","last"],"computed-property-spacing":["warn","never"],"dot-notation":"warn","eol-last":["error","always"],eqeqeq:["warn","always"],"func-call-spacing":["error","never"],"func-style":["off","expression"],"function-paren-newline":["warn","multiline"],"generator-star-spacing":["warn",{before:false,after:true}],"id-length":"off","implicit-arrow-linebreak":["warn","beside"],indent:["warn",2,{SwitchCase:1,VariableDeclarator:1,outerIIFEBody:1,FunctionDeclaration:{parameters:1,body:1},FunctionExpression:{parameters:1,body:1},CallExpression:{arguments:1},ArrayExpression:1,ObjectExpression:1,ImportDeclaration:1,flatTernaryExpressions:false,ignoredNodes:["JSXElement","JSXElement > *","JSXAttribute","JSXIdentifier","JSXNamespacedName","JSXMemberExpression","JSXSpreadAttribute","JSXExpressionContainer","JSXOpeningElement","JSXClosingElement","JSXFragment","JSXOpeningFragment","JSXClosingFragment","JSXText","JSXEmptyExpression","JSXSpreadChild"],ignoreComments:false}],"key-spacing":"error","keyword-spacing":["error",{overrides:{if:{after:true},for:{after:true},while:{after:true},else:{after:true}}}],"linebreak-style":["warn","unix"],"max-len":["error",{code:120,ignoreStrings:true,ignoreUrls:true,ignoreRegExpLiterals:true,ignoreTemplateLiterals:true}],"new-cap":["error",{newIsCap:true,newIsCapExceptions:[],capIsNew:false,capIsNewExceptions:["Immutable.Map","Immutable.Set","Immutable.List"],properties:false}],"newline-per-chained-call":["warn",{ignoreChainWithDepth:2}],"no-array-constructor":["error"],"no-case-declarations":"error","no-confusing-arrow":"warn","no-const-assign":"error","no-dupe-class-members":"error","no-else-return":["warn",{allowElseIf:false}],"no-eval":"error","no-iterator":"warn","no-loop-func":"error","no-mixed-operators":["error",{groups:[["%","**"],["%","+"],["%","-"],["%","*"],["%","/"],["&","|","<<",">>",">>>"],["==","!=","===","!=="],["&&","||"]],allowSamePrecedence:false}],"no-multi-assign":"error","no-multiple-empty-lines":"error","no-nested-ternary":"warn","no-new-func":"error","no-new-object":"error","no-new-wrappers":"warn","no-param-reassign":["warn",{props:true,ignorePropertyModificationsFor:["acc","accumulator","e","ctx","req","request","res","response","$scope","staticContext","state"]}],"no-plusplus":["error",{allowForLoopAfterthoughts:true}],"no-prototype-builtins":"error","no-restricted-properties":["warn",{object:"Math",property:"pow",message:"Please use ** instand"}],"no-restricted-syntax":["warn",{selector:"ForInStatement",message:"for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array."},{selector:"LabeledStatement",message:"Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."},{selector:"WithStatement",message:"`with` is disallowed in strict mode because it makes code impossible to predict and optimize."}],"no-trailing-spaces":"error","no-undef":["error"],"no-underscore-dangle":"warn","no-unneeded-ternary":"warn","no-unused-vars":["error",{args:"after-used",ignoreRestSiblings:true,argsIgnorePattern:"^_.+",varsIgnorePattern:"^_.+"}],"no-useless-constructor":"warn","no-useless-escape":"error","no-var":"error","no-whitespace-before-property":"warn","nonblock-statement-body-position":["error","beside"],"object-curly-spacing":["warn","always"],"object-shorthand":"warn","one-var":["warn","never"],"operator-linebreak":["error","before",{overrides:{"=":"none"}}],"padded-blocks":["error","never"],"prefer-arrow-callback":"warn","prefer-const":["error",{destructuring:"any",ignoreReadBeforeAssign:false}],"prefer-destructuring":["warn",{VariableDeclarator:{array:false,object:true},AssignmentExpression:{array:true,object:false}},{enforceForRenamedProperties:false}],"prefer-rest-params":"warn","prefer-spread":"warn","prefer-template":"error","quote-props":["error","as-needed",{keywords:false}],quotes:["warn","single",{allowTemplateLiterals:false}],radix:"warn",semi:["error","always"],"space-before-blocks":"error","space-before-function-paren":["error",{anonymous:"always",named:"never",asyncArrow:"always"}],"space-in-parens":["error","never"],"space-infix-ops":"error","spaced-comment":["error","always"],"template-curly-spacing":["error","never"],"wrap-iife":["error","outside"]}};
|
package/import.js
CHANGED
|
@@ -1,23 +1 @@
|
|
|
1
|
-
module.exports
|
|
2
|
-
|
|
3
|
-
plugins: ['import'],rules:{
|
|
4
|
-
/**
|
|
5
|
-
* 导入语句前不允许有任何非导入语句
|
|
6
|
-
*/
|
|
7
|
-
'import/first': "error",
|
|
8
|
-
/**
|
|
9
|
-
* 禁止重复导入模块
|
|
10
|
-
*/
|
|
11
|
-
'import/no-duplicates': "error",
|
|
12
|
-
/**
|
|
13
|
-
* 禁止使用 let 导出
|
|
14
|
-
*/
|
|
15
|
-
'import/no-mutable-exports': "warn",
|
|
16
|
-
/**
|
|
17
|
-
* 禁用导入的模块时使用 webpack 特有的语法(感叹号)
|
|
18
|
-
*/
|
|
19
|
-
'import/no-webpack-loader-syntax': "warn",
|
|
20
|
-
/**
|
|
21
|
-
* 当只有一个导出时,必须使用 export default 来导出
|
|
22
|
-
*/
|
|
23
|
-
'import/prefer-default-export': "off",},};
|
|
1
|
+
module.exports={plugins:["import"],rules:{"import/first":"error","import/no-duplicates":"error","import/no-mutable-exports":"warn","import/no-webpack-loader-syntax":"warn","import/prefer-default-export":"off"}};
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-tencent",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "a eslint config",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
7
|
"files": [
|
|
8
8
|
"base.js",
|
|
9
9
|
"base-legacy.js",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@babel/core": "^7.14.6",
|
|
23
|
-
"@typescript-eslint/eslint-plugin": "^4.27.0",
|
|
24
|
-
"@typescript-eslint/parser": "^4.27.0",
|
|
25
|
-
"eslint": "^7.28.0",
|
|
26
|
-
"eslint-plugin-prettier": "^3.4.0",
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "^4.27.0 || ^5.12.0",
|
|
24
|
+
"@typescript-eslint/parser": "^4.27.0 || ^5.12.0",
|
|
25
|
+
"eslint": "^7.28.0 || ^8.0.0",
|
|
26
|
+
"eslint-plugin-prettier": "^3.4.0 || ^4.0.0",
|
|
27
27
|
"prettier": "^2.3.1"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/prettier.js
CHANGED
|
@@ -1,75 +1 @@
|
|
|
1
|
-
module.exports
|
|
2
|
-
|
|
3
|
-
plugins: ['prettier'],rules:{
|
|
4
|
-
'wrap-iife': 'off',
|
|
5
|
-
'template-curly-spacing': 'off',
|
|
6
|
-
'space-infix-ops': 'off',
|
|
7
|
-
'space-in-parens': 'off',
|
|
8
|
-
'space-before-blocks': 'off',
|
|
9
|
-
'quote-props': 'off',
|
|
10
|
-
'padded-blocks': 'off',
|
|
11
|
-
'operator-linebreak': 'off',
|
|
12
|
-
'object-curly-spacing': 'off',
|
|
13
|
-
'nonblock-statement-body-position': 'off',
|
|
14
|
-
'no-whitespace-before-property': 'off',
|
|
15
|
-
'no-trailing-spaces': 'off',
|
|
16
|
-
'no-multiple-empty-lines': 'off',
|
|
17
|
-
'no-mixed-operators': 'off',
|
|
18
|
-
'no-confusing-arrow': 'off',
|
|
19
|
-
'newline-per-chained-call': 'off',
|
|
20
|
-
'max-len': 'off',
|
|
21
|
-
'linebreak-style': 'off',
|
|
22
|
-
'key-spacing': 'off',
|
|
23
|
-
'implicit-arrow-linebreak': 'off',
|
|
24
|
-
'generator-star-spacing': 'off',
|
|
25
|
-
'function-paren-newline': 'off',
|
|
26
|
-
'eol-last': 'off',
|
|
27
|
-
'computed-property-spacing': 'off',
|
|
28
|
-
'comma-style': 'off',
|
|
29
|
-
'comma-dangle': 'off',
|
|
30
|
-
'block-spacing': 'off',
|
|
31
|
-
'arrow-spacing': 'off',
|
|
32
|
-
'arrow-parens': 'off',
|
|
33
|
-
'array-bracket-spacing': 'off',
|
|
34
|
-
|
|
35
|
-
'@typescript-eslint/type-annotation-spacing': 'off',
|
|
36
|
-
'@typescript-eslint/space-before-function-paren': 'off',
|
|
37
|
-
'@typescript-eslint/semi': 'off',
|
|
38
|
-
'@typescript-eslint/quotes': 'off',
|
|
39
|
-
'@typescript-eslint/keyword-spacing': 'off',
|
|
40
|
-
'@typescript-eslint/indent': 'off',
|
|
41
|
-
'@typescript-eslint/func-call-spacing': 'off',
|
|
42
|
-
'@typescript-eslint/comma-spacing': 'off',
|
|
43
|
-
'@typescript-eslint/brace-style': 'off'
|
|
44
|
-
,
|
|
45
|
-
/**
|
|
46
|
-
* prettier 格式错误
|
|
47
|
-
*/
|
|
48
|
-
'prettier/prettier': [
|
|
49
|
-
"warn",
|
|
50
|
-
{
|
|
51
|
-
"printWidth": 120,
|
|
52
|
-
"tabWidth": 2,
|
|
53
|
-
"useTabs": false,
|
|
54
|
-
"semi": true,
|
|
55
|
-
"singleQuote": true,
|
|
56
|
-
"quoteProps": "as-needed",
|
|
57
|
-
"jsxSingleQuote": false,
|
|
58
|
-
"trailingComma": "all",
|
|
59
|
-
"bracketSpacing": true,
|
|
60
|
-
"jsxBracketSameLine": false,
|
|
61
|
-
"arrowParens": "always",
|
|
62
|
-
"rangeStart": 0,
|
|
63
|
-
"rangeEnd": null,
|
|
64
|
-
"requirePragma": false,
|
|
65
|
-
"insertPragma": false,
|
|
66
|
-
"proseWrap": "preserve",
|
|
67
|
-
"htmlWhitespaceSensitivity": "css",
|
|
68
|
-
"vueIndentScriptAndStyle": false,
|
|
69
|
-
"endOfLine": "lf",
|
|
70
|
-
"embeddedLanguageFormatting": "auto"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
"usePrettierrc": false
|
|
74
|
-
}
|
|
75
|
-
],},};
|
|
1
|
+
module.exports={plugins:["prettier"],rules:{"wrap-iife":"off","template-curly-spacing":"off","space-infix-ops":"off","space-in-parens":"off","space-before-blocks":"off","quote-props":"off","padded-blocks":"off","operator-linebreak":"off","object-curly-spacing":"off","nonblock-statement-body-position":"off","no-whitespace-before-property":"off","no-trailing-spaces":"off","no-multiple-empty-lines":"off","no-mixed-operators":"off","no-confusing-arrow":"off","newline-per-chained-call":"off","max-len":"off","linebreak-style":"off","key-spacing":"off","implicit-arrow-linebreak":"off","generator-star-spacing":"off","function-paren-newline":"off","eol-last":"off","computed-property-spacing":"off","comma-style":"off","comma-dangle":"off","block-spacing":"off","arrow-spacing":"off","arrow-parens":"off","array-bracket-spacing":"off","@typescript-eslint/type-annotation-spacing":"off","@typescript-eslint/space-before-function-paren":"off","@typescript-eslint/semi":"off","@typescript-eslint/quotes":"off","@typescript-eslint/keyword-spacing":"off","@typescript-eslint/indent":"off","@typescript-eslint/func-call-spacing":"off","@typescript-eslint/comma-spacing":"off","@typescript-eslint/brace-style":"off","prettier/prettier":["warn",{printWidth:120,tabWidth:2,useTabs:false,semi:true,singleQuote:true,quoteProps:"as-needed",jsxSingleQuote:false,trailingComma:"all",bracketSpacing:true,jsxBracketSameLine:false,arrowParens:"always",rangeStart:0,rangeEnd:null,requirePragma:false,insertPragma:false,proseWrap:"preserve",htmlWhitespaceSensitivity:"css",vueIndentScriptAndStyle:false,endOfLine:"lf",embeddedLanguageFormatting:"auto"},{usePrettierrc:false}]}};
|
package/react.js
CHANGED
package/ts-legacy.js
CHANGED
|
@@ -1,19 +1 @@
|
|
|
1
|
-
module.exports
|
|
2
|
-
rules: {
|
|
3
|
-
// 降级为 推荐
|
|
4
|
-
'@typescript-eslint/no-non-null-asserted-optional-chain': 'warn',
|
|
5
|
-
// 降级为 可选
|
|
6
|
-
'@typescript-eslint/prefer-optional-chain': 'off',
|
|
7
|
-
// 豁免
|
|
8
|
-
'@typescript-eslint/consistent-type-assertions': 'off',
|
|
9
|
-
'@typescript-eslint/explicit-member-accessibility': 'off',
|
|
10
|
-
'@typescript-eslint/member-ordering': 'off',
|
|
11
|
-
'@typescript-eslint/no-inferrable-types': 'off',
|
|
12
|
-
'@typescript-eslint/no-namespace': 'off',
|
|
13
|
-
'@typescript-eslint/no-require-imports': 'off',
|
|
14
|
-
'@typescript-eslint/no-this-alias': 'off',
|
|
15
|
-
'@typescript-eslint/no-useless-constructor': 'off',
|
|
16
|
-
'@typescript-eslint/prefer-for-of': 'off',
|
|
17
|
-
'@typescript-eslint/prefer-function-type': 'off',
|
|
18
|
-
},
|
|
19
|
-
};
|
|
1
|
+
module.exports={rules:{"@typescript-eslint/no-non-null-asserted-optional-chain":"warn","@typescript-eslint/prefer-optional-chain":"off","@typescript-eslint/consistent-type-assertions":"off","@typescript-eslint/explicit-member-accessibility":"off","@typescript-eslint/member-ordering":"off","@typescript-eslint/no-inferrable-types":"off","@typescript-eslint/no-namespace":"off","@typescript-eslint/no-require-imports":"off","@typescript-eslint/no-this-alias":"off","@typescript-eslint/no-useless-constructor":"off","@typescript-eslint/prefer-for-of":"off","@typescript-eslint/prefer-function-type":"off"}};
|
package/ts.js
CHANGED
|
@@ -1,419 +1 @@
|
|
|
1
|
-
module.exports
|
|
2
|
-
|
|
3
|
-
parser: '@typescript-eslint/parser',
|
|
4
|
-
parserOptions: {
|
|
5
|
-
project: [
|
|
6
|
-
'./tsconfig.json',
|
|
7
|
-
],
|
|
8
|
-
},
|
|
9
|
-
plugins: ['@typescript-eslint'],rules:{
|
|
10
|
-
'brace-style': 'off',
|
|
11
|
-
'no-empty-function': 'off',
|
|
12
|
-
// https://github.com/typescript-eslint/typescript-eslint/issues/491
|
|
13
|
-
'no-invalid-this': 'off',
|
|
14
|
-
'no-magic-numbers': 'off',
|
|
15
|
-
'react/sort-comp': 'off',
|
|
16
|
-
'func-call-spacing': 'off',
|
|
17
|
-
'comma-spacing': 'off',
|
|
18
|
-
'dot-notation': 'off',
|
|
19
|
-
indent: 'off',
|
|
20
|
-
'keyword-spacing': 'off',
|
|
21
|
-
camelcase: 'off',
|
|
22
|
-
'no-underscore-dangle': 'off',
|
|
23
|
-
'no-array-constructor': 'off',
|
|
24
|
-
'no-dupe-class-members': 'off',
|
|
25
|
-
'no-undef': 'off',
|
|
26
|
-
'no-unused-vars': 'off',
|
|
27
|
-
'no-useless-constructor': 'off',
|
|
28
|
-
quotes: 'off',
|
|
29
|
-
semi: 'off',
|
|
30
|
-
'space-before-function-paren': 'off',
|
|
31
|
-
// https://github.com/typescript-eslint/typescript-eslint/issues/600
|
|
32
|
-
'spaced-comment': ['error', 'always', { markers: ['/'] }]
|
|
33
|
-
,
|
|
34
|
-
/**
|
|
35
|
-
* 重载的函数必须写在一起
|
|
36
|
-
* @reason 增加可读性
|
|
37
|
-
*/
|
|
38
|
-
'@typescript-eslint/adjacent-overload-signatures': "error",
|
|
39
|
-
/** 同 JS 规则的 TS 版本 */
|
|
40
|
-
'@typescript-eslint/brace-style': "error",
|
|
41
|
-
/** 同 JS 规则的 TS 版本 */
|
|
42
|
-
'@typescript-eslint/comma-spacing': [
|
|
43
|
-
"error",
|
|
44
|
-
{
|
|
45
|
-
"before": false,
|
|
46
|
-
"after": true
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
/**
|
|
50
|
-
* 类型断言必须使用 as Type,禁止使用 <Type>,禁止对对象字面量进行类型断言(断言成 any 是允许的)
|
|
51
|
-
* @reason <Type> 容易被理解为 jsx
|
|
52
|
-
*/
|
|
53
|
-
'@typescript-eslint/consistent-type-assertions': [
|
|
54
|
-
"error",
|
|
55
|
-
{
|
|
56
|
-
"assertionStyle": "as",
|
|
57
|
-
"objectLiteralTypeAssertions": "never"
|
|
58
|
-
}
|
|
59
|
-
],
|
|
60
|
-
/**
|
|
61
|
-
* 优先使用 interface 而不是 type
|
|
62
|
-
*/
|
|
63
|
-
'@typescript-eslint/consistent-type-definitions': "off",
|
|
64
|
-
/** 同 JS 规则的 TS 版本 */
|
|
65
|
-
'@typescript-eslint/dot-notation': "warn",
|
|
66
|
-
/**
|
|
67
|
-
* 必须设置类的成员的可访问性
|
|
68
|
-
* @reason 将不需要公开的成员设为私有的,可以增强代码的可理解性,对文档输出也很友好
|
|
69
|
-
*/
|
|
70
|
-
'@typescript-eslint/explicit-member-accessibility': "off",
|
|
71
|
-
/**
|
|
72
|
-
* 要求或禁止在函数标识符和其调用之间有空格
|
|
73
|
-
*/
|
|
74
|
-
'@typescript-eslint/func-call-spacing': [
|
|
75
|
-
"error",
|
|
76
|
-
"never"
|
|
77
|
-
],
|
|
78
|
-
/** 同 JS 规则的 TS 版本 */
|
|
79
|
-
'@typescript-eslint/indent': [
|
|
80
|
-
"warn",
|
|
81
|
-
2,
|
|
82
|
-
{
|
|
83
|
-
"SwitchCase": 1,
|
|
84
|
-
"VariableDeclarator": 1,
|
|
85
|
-
"outerIIFEBody": 1,
|
|
86
|
-
"FunctionDeclaration": {
|
|
87
|
-
"parameters": 1,
|
|
88
|
-
"body": 1
|
|
89
|
-
},
|
|
90
|
-
"FunctionExpression": {
|
|
91
|
-
"parameters": 1,
|
|
92
|
-
"body": 1
|
|
93
|
-
},
|
|
94
|
-
"CallExpression": {
|
|
95
|
-
"arguments": 1
|
|
96
|
-
},
|
|
97
|
-
"ArrayExpression": 1,
|
|
98
|
-
"ObjectExpression": 1,
|
|
99
|
-
"ImportDeclaration": 1,
|
|
100
|
-
"flatTernaryExpressions": false,
|
|
101
|
-
"ignoredNodes": [
|
|
102
|
-
"JSXElement",
|
|
103
|
-
"JSXElement > *",
|
|
104
|
-
"JSXAttribute",
|
|
105
|
-
"JSXIdentifier",
|
|
106
|
-
"JSXNamespacedName",
|
|
107
|
-
"JSXMemberExpression",
|
|
108
|
-
"JSXSpreadAttribute",
|
|
109
|
-
"JSXExpressionContainer",
|
|
110
|
-
"JSXOpeningElement",
|
|
111
|
-
"JSXClosingElement",
|
|
112
|
-
"JSXFragment",
|
|
113
|
-
"JSXOpeningFragment",
|
|
114
|
-
"JSXClosingFragment",
|
|
115
|
-
"JSXText",
|
|
116
|
-
"JSXEmptyExpression",
|
|
117
|
-
"JSXSpreadChild"
|
|
118
|
-
],
|
|
119
|
-
"ignoreComments": false
|
|
120
|
-
}
|
|
121
|
-
],
|
|
122
|
-
/** 同 JS 规则的 TS 版本 */
|
|
123
|
-
'@typescript-eslint/keyword-spacing': [
|
|
124
|
-
"error",
|
|
125
|
-
{
|
|
126
|
-
"overrides": {
|
|
127
|
-
"if": {
|
|
128
|
-
"after": true
|
|
129
|
-
},
|
|
130
|
-
"for": {
|
|
131
|
-
"after": true
|
|
132
|
-
},
|
|
133
|
-
"while": {
|
|
134
|
-
"after": true
|
|
135
|
-
},
|
|
136
|
-
"else": {
|
|
137
|
-
"after": true
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
"before": true,
|
|
141
|
-
"after": true
|
|
142
|
-
}
|
|
143
|
-
],
|
|
144
|
-
/**
|
|
145
|
-
* 指定类成员的排序规则
|
|
146
|
-
* @reason 优先级:
|
|
147
|
-
* 1. static > instance
|
|
148
|
-
* 2. field > constructor > method
|
|
149
|
-
* 3. public > protected > private
|
|
150
|
-
*/
|
|
151
|
-
'@typescript-eslint/member-ordering': [
|
|
152
|
-
"error",
|
|
153
|
-
{
|
|
154
|
-
"default": [
|
|
155
|
-
"public-static-field",
|
|
156
|
-
"protected-static-field",
|
|
157
|
-
"private-static-field",
|
|
158
|
-
"static-field",
|
|
159
|
-
"public-static-method",
|
|
160
|
-
"protected-static-method",
|
|
161
|
-
"private-static-method",
|
|
162
|
-
"static-method",
|
|
163
|
-
"public-instance-field",
|
|
164
|
-
"protected-instance-field",
|
|
165
|
-
"private-instance-field",
|
|
166
|
-
"public-field",
|
|
167
|
-
"protected-field",
|
|
168
|
-
"private-field",
|
|
169
|
-
"instance-field",
|
|
170
|
-
"field",
|
|
171
|
-
"constructor",
|
|
172
|
-
"public-instance-method",
|
|
173
|
-
"protected-instance-method",
|
|
174
|
-
"private-instance-method",
|
|
175
|
-
"public-method",
|
|
176
|
-
"protected-method",
|
|
177
|
-
"private-method",
|
|
178
|
-
"instance-method",
|
|
179
|
-
"method"
|
|
180
|
-
]
|
|
181
|
-
}
|
|
182
|
-
],
|
|
183
|
-
/**
|
|
184
|
-
* 接口中的方法必须用属性的方式定义
|
|
185
|
-
*/
|
|
186
|
-
'@typescript-eslint/method-signature-style': "off",
|
|
187
|
-
/** 代替 JS 规则 camelCase 的 TS 规则 */
|
|
188
|
-
'@typescript-eslint/naming-convention': [
|
|
189
|
-
"warn",
|
|
190
|
-
{
|
|
191
|
-
"selector": "function",
|
|
192
|
-
"format": [
|
|
193
|
-
"camelCase",
|
|
194
|
-
"PascalCase"
|
|
195
|
-
]
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
"selector": "variable",
|
|
199
|
-
"format": [
|
|
200
|
-
"camelCase",
|
|
201
|
-
"UPPER_CASE"
|
|
202
|
-
]
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
"selector": "variable",
|
|
206
|
-
"modifiers": [
|
|
207
|
-
"global"
|
|
208
|
-
],
|
|
209
|
-
"format": [
|
|
210
|
-
"camelCase",
|
|
211
|
-
"PascalCase",
|
|
212
|
-
"UPPER_CASE"
|
|
213
|
-
]
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
"selector": "variable",
|
|
217
|
-
"format": [
|
|
218
|
-
"camelCase",
|
|
219
|
-
"PascalCase"
|
|
220
|
-
],
|
|
221
|
-
"types": [
|
|
222
|
-
"function"
|
|
223
|
-
]
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
"selector": "variable",
|
|
227
|
-
"modifiers": [
|
|
228
|
-
"exported"
|
|
229
|
-
],
|
|
230
|
-
"format": [
|
|
231
|
-
"UPPER_CASE"
|
|
232
|
-
],
|
|
233
|
-
"types": [
|
|
234
|
-
"boolean",
|
|
235
|
-
"string",
|
|
236
|
-
"number",
|
|
237
|
-
"array"
|
|
238
|
-
]
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
"selector": "variable",
|
|
242
|
-
"modifiers": [
|
|
243
|
-
"exported"
|
|
244
|
-
],
|
|
245
|
-
"format": [
|
|
246
|
-
"camelCase",
|
|
247
|
-
"PascalCase"
|
|
248
|
-
],
|
|
249
|
-
"types": [
|
|
250
|
-
"function"
|
|
251
|
-
]
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
"selector": [
|
|
255
|
-
"class",
|
|
256
|
-
"typeLike"
|
|
257
|
-
],
|
|
258
|
-
"format": [
|
|
259
|
-
"PascalCase"
|
|
260
|
-
]
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
"selector": [
|
|
264
|
-
"classMethod",
|
|
265
|
-
"classProperty"
|
|
266
|
-
],
|
|
267
|
-
"leadingUnderscore": "forbid",
|
|
268
|
-
"trailingUnderscore": "forbid",
|
|
269
|
-
"format": [
|
|
270
|
-
"camelCase"
|
|
271
|
-
]
|
|
272
|
-
}
|
|
273
|
-
],
|
|
274
|
-
/** 同 JS 规则的 TS 版本 */
|
|
275
|
-
'@typescript-eslint/no-array-constructor': "error",
|
|
276
|
-
/** 同 JS 规则的 TS 版本 */
|
|
277
|
-
'@typescript-eslint/no-dupe-class-members': "error",
|
|
278
|
-
/**
|
|
279
|
-
* 禁止定义空的接口
|
|
280
|
-
*/
|
|
281
|
-
'@typescript-eslint/no-empty-interface': "error",
|
|
282
|
-
/**
|
|
283
|
-
* 禁止给一个初始化时直接赋值为 number, string 的变量显式的声明类型
|
|
284
|
-
* @reason 可以简化代码
|
|
285
|
-
*/
|
|
286
|
-
'@typescript-eslint/no-inferrable-types': "warn",
|
|
287
|
-
/**
|
|
288
|
-
* 禁止使用 namespace 来定义命名空间
|
|
289
|
-
* @reason 使用 es6 引入模块,才是更标准的方式。
|
|
290
|
-
* 但是允许使用 declare namespace ... {} 来定义外部命名空间
|
|
291
|
-
*/
|
|
292
|
-
'@typescript-eslint/no-namespace': [
|
|
293
|
-
"error",
|
|
294
|
-
{
|
|
295
|
-
"allowDeclarations": true,
|
|
296
|
-
"allowDefinitionFiles": true
|
|
297
|
-
}
|
|
298
|
-
],
|
|
299
|
-
/**
|
|
300
|
-
* 禁止在 optional chaining 之后使用 non-null 断言(感叹号)
|
|
301
|
-
* @reason optional chaining 后面的属性一定是非空的
|
|
302
|
-
*/
|
|
303
|
-
'@typescript-eslint/no-non-null-asserted-optional-chain': "error",
|
|
304
|
-
/**
|
|
305
|
-
* 禁止给类的构造函数的参数添加修饰符
|
|
306
|
-
*/
|
|
307
|
-
'@typescript-eslint/no-parameter-properties': "off",
|
|
308
|
-
/**
|
|
309
|
-
* 禁止使用 require
|
|
310
|
-
* @reason 统一使用 import 来引入模块,特殊情况使用单行注释允许 require 引入
|
|
311
|
-
*/
|
|
312
|
-
'@typescript-eslint/no-require-imports': "error",
|
|
313
|
-
/**
|
|
314
|
-
* 禁止将 this 赋值给其他变量,除非是解构赋值
|
|
315
|
-
*/
|
|
316
|
-
'@typescript-eslint/no-this-alias': [
|
|
317
|
-
"error",
|
|
318
|
-
{
|
|
319
|
-
"allowDestructuring": true
|
|
320
|
-
}
|
|
321
|
-
],
|
|
322
|
-
/**
|
|
323
|
-
* 禁止无用的表达式
|
|
324
|
-
*/
|
|
325
|
-
'@typescript-eslint/no-unused-expressions': [
|
|
326
|
-
"error",
|
|
327
|
-
{
|
|
328
|
-
"allowShortCircuit": true,
|
|
329
|
-
"allowTernary": true,
|
|
330
|
-
"allowTaggedTemplates": true
|
|
331
|
-
}
|
|
332
|
-
],
|
|
333
|
-
/** 同 JS 规则的 TS 版本 */
|
|
334
|
-
'@typescript-eslint/no-unused-vars': [
|
|
335
|
-
"error",
|
|
336
|
-
{
|
|
337
|
-
"args": "after-used",
|
|
338
|
-
"ignoreRestSiblings": true
|
|
339
|
-
}
|
|
340
|
-
],
|
|
341
|
-
/**
|
|
342
|
-
* 禁止出现没必要的 constructor
|
|
343
|
-
*/
|
|
344
|
-
'@typescript-eslint/no-useless-constructor': "warn",
|
|
345
|
-
/**
|
|
346
|
-
* 使用 for 循环遍历数组时,如果索引仅用于获取成员,则必须使用 for of 循环替代 for 循环
|
|
347
|
-
* @reason for of 循环更加易读
|
|
348
|
-
*/
|
|
349
|
-
'@typescript-eslint/prefer-for-of': "warn",
|
|
350
|
-
/**
|
|
351
|
-
* 使用函数类型别名替代包含函数调用声明的接口
|
|
352
|
-
*/
|
|
353
|
-
'@typescript-eslint/prefer-function-type': "warn",
|
|
354
|
-
/**
|
|
355
|
-
* 禁止使用 module 来定义命名空间
|
|
356
|
-
* @reason module 已成为 js 的关键字
|
|
357
|
-
*/
|
|
358
|
-
'@typescript-eslint/prefer-namespace-keyword': "error",
|
|
359
|
-
/**
|
|
360
|
-
* 使用 optional chaining 替代 &&
|
|
361
|
-
*/
|
|
362
|
-
'@typescript-eslint/prefer-optional-chain': "error",
|
|
363
|
-
/** 同 JS 规则的 TS 版本 */
|
|
364
|
-
'@typescript-eslint/quotes': [
|
|
365
|
-
"warn",
|
|
366
|
-
"single",
|
|
367
|
-
{
|
|
368
|
-
"allowTemplateLiterals": false
|
|
369
|
-
}
|
|
370
|
-
],
|
|
371
|
-
/** 同 JS 规则的 TS 版本 */
|
|
372
|
-
'@typescript-eslint/semi': [
|
|
373
|
-
"error",
|
|
374
|
-
"always"
|
|
375
|
-
],
|
|
376
|
-
/** 同 JS 规则的 TS 版本 */
|
|
377
|
-
'@typescript-eslint/space-before-function-paren': [
|
|
378
|
-
"error",
|
|
379
|
-
{
|
|
380
|
-
"anonymous": "always",
|
|
381
|
-
"named": "never",
|
|
382
|
-
"asyncArrow": "always"
|
|
383
|
-
}
|
|
384
|
-
],
|
|
385
|
-
/**
|
|
386
|
-
* 禁止使用三斜杠导入文件
|
|
387
|
-
* @reason 三斜杠是已废弃的语法,但在类型声明文件中还是可以使用的
|
|
388
|
-
*/
|
|
389
|
-
'@typescript-eslint/triple-slash-reference': [
|
|
390
|
-
"error",
|
|
391
|
-
{
|
|
392
|
-
"path": "never",
|
|
393
|
-
"types": "always",
|
|
394
|
-
"lib": "always"
|
|
395
|
-
}
|
|
396
|
-
],
|
|
397
|
-
/**
|
|
398
|
-
* 在类型注释周围需要一致的间距
|
|
399
|
-
*/
|
|
400
|
-
'@typescript-eslint/type-annotation-spacing': "error",
|
|
401
|
-
/**
|
|
402
|
-
* interface 和 type 定义时必须声明成员的类型
|
|
403
|
-
*/
|
|
404
|
-
'@typescript-eslint/typedef': [
|
|
405
|
-
"error",
|
|
406
|
-
{
|
|
407
|
-
"arrayDestructuring": false,
|
|
408
|
-
"arrowParameter": false,
|
|
409
|
-
"memberVariableDeclaration": false,
|
|
410
|
-
"objectDestructuring": false,
|
|
411
|
-
"parameter": false,
|
|
412
|
-
"propertyDeclaration": true,
|
|
413
|
-
"variableDeclaration": false
|
|
414
|
-
}
|
|
415
|
-
],
|
|
416
|
-
/**
|
|
417
|
-
* 函数重载时,若能通过联合类型将两个函数的类型声明合为一个,则使用联合类型而不是两个函数声明
|
|
418
|
-
*/
|
|
419
|
-
'@typescript-eslint/unified-signatures': "error",},};
|
|
1
|
+
module.exports={parser:"@typescript-eslint/parser",parserOptions:{project:["./tsconfig.json"]},plugins:["@typescript-eslint"],rules:{"brace-style":"off","no-empty-function":"off","no-invalid-this":"off","no-magic-numbers":"off","react/sort-comp":"off","func-call-spacing":"off","comma-spacing":"off","dot-notation":"off",indent:"off","keyword-spacing":"off",camelcase:"off","no-underscore-dangle":"off","no-array-constructor":"off","no-dupe-class-members":"off","no-undef":"off","no-unused-vars":"off","no-useless-constructor":"off",quotes:"off",semi:"off","space-before-function-paren":"off","spaced-comment":["error","always",{markers:["/"]}],"@typescript-eslint/adjacent-overload-signatures":"error","@typescript-eslint/brace-style":"error","@typescript-eslint/comma-spacing":["error",{before:false,after:true}],"@typescript-eslint/consistent-type-assertions":["error",{assertionStyle:"as",objectLiteralTypeAssertions:"never"}],"@typescript-eslint/consistent-type-definitions":"off","@typescript-eslint/dot-notation":"warn","@typescript-eslint/explicit-member-accessibility":"off","@typescript-eslint/func-call-spacing":["error","never"],"@typescript-eslint/indent":["warn",2,{SwitchCase:1,VariableDeclarator:1,outerIIFEBody:1,FunctionDeclaration:{parameters:1,body:1},FunctionExpression:{parameters:1,body:1},CallExpression:{arguments:1},ArrayExpression:1,ObjectExpression:1,ImportDeclaration:1,flatTernaryExpressions:false,ignoredNodes:["JSXElement","JSXElement > *","JSXAttribute","JSXIdentifier","JSXNamespacedName","JSXMemberExpression","JSXSpreadAttribute","JSXExpressionContainer","JSXOpeningElement","JSXClosingElement","JSXFragment","JSXOpeningFragment","JSXClosingFragment","JSXText","JSXEmptyExpression","JSXSpreadChild"],ignoreComments:false}],"@typescript-eslint/keyword-spacing":["error",{overrides:{if:{after:true},for:{after:true},while:{after:true},else:{after:true}},before:true,after:true}],"@typescript-eslint/member-ordering":["error",{default:["public-static-field","protected-static-field","private-static-field","static-field","public-static-method","protected-static-method","private-static-method","static-method","public-instance-field","protected-instance-field","private-instance-field","public-field","protected-field","private-field","instance-field","field","constructor","public-instance-method","protected-instance-method","private-instance-method","public-method","protected-method","private-method","instance-method","method"]}],"@typescript-eslint/method-signature-style":"off","@typescript-eslint/naming-convention":["warn",{selector:"function",format:["camelCase","PascalCase"]},{selector:"variable",format:["camelCase","UPPER_CASE"]},{selector:"variable",modifiers:["global"],format:["camelCase","PascalCase","UPPER_CASE"]},{selector:"variable",format:["camelCase","PascalCase"],types:["function"]},{selector:"variable",modifiers:["exported"],format:["UPPER_CASE"],types:["boolean","string","number","array"]},{selector:"variable",modifiers:["exported"],format:["camelCase","PascalCase"],types:["function"]},{selector:["class","typeLike"],format:["PascalCase"]},{selector:["classMethod","classProperty"],leadingUnderscore:"forbid",trailingUnderscore:"forbid",format:["camelCase"]}],"@typescript-eslint/no-array-constructor":"error","@typescript-eslint/no-dupe-class-members":"error","@typescript-eslint/no-empty-interface":"error","@typescript-eslint/no-inferrable-types":"warn","@typescript-eslint/no-misused-promises":["error",{checksConditionals:true}],"@typescript-eslint/no-namespace":["error",{allowDeclarations:true,allowDefinitionFiles:true}],"@typescript-eslint/no-non-null-asserted-optional-chain":"error","@typescript-eslint/no-parameter-properties":"off","@typescript-eslint/no-require-imports":"error","@typescript-eslint/no-this-alias":["error",{allowDestructuring:true}],"@typescript-eslint/no-unused-expressions":["error",{allowShortCircuit:true,allowTernary:true,allowTaggedTemplates:true}],"@typescript-eslint/no-unused-vars":["error",{args:"after-used",ignoreRestSiblings:true,argsIgnorePattern:"^_.+",varsIgnorePattern:"^_.+"}],"@typescript-eslint/no-useless-constructor":"warn","@typescript-eslint/prefer-for-of":"warn","@typescript-eslint/prefer-function-type":"warn","@typescript-eslint/prefer-namespace-keyword":"error","@typescript-eslint/prefer-optional-chain":"error","@typescript-eslint/quotes":["warn","single",{allowTemplateLiterals:false}],"@typescript-eslint/semi":["error","always"],"@typescript-eslint/space-before-function-paren":["error",{anonymous:"always",named:"never",asyncArrow:"always"}],"@typescript-eslint/triple-slash-reference":["error",{path:"never",types:"always",lib:"always"}],"@typescript-eslint/type-annotation-spacing":"error","@typescript-eslint/typedef":["error",{arrayDestructuring:false,arrowParameter:false,memberVariableDeclaration:false,objectDestructuring:false,parameter:false,propertyDeclaration:true,variableDeclaration:false}],"@typescript-eslint/unified-signatures":"error"}};
|