@houheaven/eslint-config-helper 1.3.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.
Files changed (84) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +155 -28
  3. package/lib/format-es5.js +23 -0
  4. package/lib/format-es6.js +25 -0
  5. package/lib/format-html.js +23 -0
  6. package/lib/format-import.js +23 -0
  7. package/lib/format-typescript.js +28 -0
  8. package/lib/format-vue2.js +23 -0
  9. package/lib/format-vue3.js +23 -0
  10. package/lib/html.js +13 -22
  11. package/lib/import.js +23 -0
  12. package/lib/javascript-es5.js +23 -0
  13. package/lib/javascript-es6.js +25 -0
  14. package/lib/rules/eslint/_deprecated.js +132 -0
  15. package/lib/rules/eslint/_removed.js +25 -0
  16. package/lib/rules/eslint/es6.js +279 -110
  17. package/lib/rules/eslint/layout-formatting.js +441 -0
  18. package/lib/rules/eslint/possible-errors.js +140 -131
  19. package/lib/rules/eslint/suggestions.js +666 -0
  20. package/lib/rules/html/accessibility.js +47 -23
  21. package/lib/rules/html/best-practice.js +122 -36
  22. package/lib/rules/html/seo.js +16 -11
  23. package/lib/rules/html/style.js +53 -15
  24. package/lib/rules/import/helpful-warnings.js +23 -18
  25. package/lib/rules/import/module-systems.js +16 -17
  26. package/lib/rules/import/static-analysis.js +54 -38
  27. package/lib/rules/import/style-guide.js +89 -61
  28. package/lib/rules/typescript/_deprecated.js +57 -0
  29. package/lib/rules/typescript/conflict.js +16 -0
  30. package/lib/rules/typescript/deprecated.js +41 -0
  31. package/lib/rules/typescript/extension.js +207 -0
  32. package/lib/rules/typescript/fixable.js +215 -0
  33. package/lib/rules/typescript/other.js +125 -0
  34. package/lib/rules/typescript/stylistic.js +34 -0
  35. package/lib/rules/typescript/suggestion.js +53 -0
  36. package/lib/rules/typescript/type-checked.js +263 -0
  37. package/lib/rules/vue/_deprecated.js +37 -0
  38. package/lib/rules/vue/common-base.js +1 -11
  39. package/lib/rules/vue/common-essential.js +25 -38
  40. package/lib/rules/vue/common-extension.js +321 -0
  41. package/lib/rules/vue/common-recommended.js +64 -31
  42. package/lib/rules/vue/common-strongly-recommended.js +37 -20
  43. package/lib/rules/vue/{common-extra.js → common-uncategorized.js} +141 -52
  44. package/lib/rules/vue/vue2-essential.js +16 -14
  45. package/lib/rules/vue/vue2-uncategorized.js +15 -0
  46. package/lib/rules/vue/vue3-essential.js +54 -24
  47. package/lib/rules/vue/vue3-strongly-recommended.js +8 -10
  48. package/lib/rules/vue/vue3-uncategorized.js +115 -0
  49. package/lib/support/es5-support.js +29 -0
  50. package/lib/support/es6-support.js +39 -0
  51. package/lib/support/html-support.js +38 -0
  52. package/lib/support/import-bugfix.js +65 -0
  53. package/lib/support/import-support.js +25 -0
  54. package/lib/support/typescript-support.js +27 -0
  55. package/lib/support/vue2-support.js +43 -0
  56. package/lib/support/vue3-support.js +43 -0
  57. package/lib/support/vue3-ts-support.js +51 -0
  58. package/lib/typescript.js +37 -0
  59. package/lib/utils/utils.js +160 -0
  60. package/lib/vue2.js +16 -22
  61. package/lib/vue3-ts.js +31 -0
  62. package/lib/vue3.js +13 -17
  63. package/package.json +39 -20
  64. package/lib/configs/eslint-es5.js +0 -24
  65. package/lib/configs/eslint.js +0 -23
  66. package/lib/configs/format-html.js +0 -22
  67. package/lib/configs/format-js.js +0 -134
  68. package/lib/configs/format-vue.js +0 -278
  69. package/lib/configs/html.js +0 -20
  70. package/lib/configs/import-bugfix.js +0 -36
  71. package/lib/configs/import.js +0 -44
  72. package/lib/configs/vue2.js +0 -28
  73. package/lib/configs/vue3.js +0 -28
  74. package/lib/eslint.js +0 -18
  75. package/lib/format.js +0 -40
  76. package/lib/rules/eslint/best-practices.js +0 -422
  77. package/lib/rules/eslint/node.js +0 -48
  78. package/lib/rules/eslint/strict-mode.js +0 -12
  79. package/lib/rules/eslint/stylistic-issues.js +0 -577
  80. package/lib/rules/eslint/variables.js +0 -73
  81. package/lib/rules/vue/common-eslint.js +0 -220
  82. package/lib/rules/vue/vue2-recommended.js +0 -17
  83. package/lib/rules/vue/vue2-strongly-recommended.js +0 -16
  84. package/lib/rules/vue/vue3-recommended.js +0 -17
@@ -1,577 +0,0 @@
1
-
2
- // ==========================================================
3
- // Stylistic Issues
4
- // 这些规则是关于风格指南的,而且是非常主观的
5
- // ==========================================================
6
-
7
- module.exports = {
8
- rules: {
9
- // 在数组开括号后和闭括号前强制换行
10
- // https://eslint.org/docs/rules/array-bracket-newline
11
- "array-bracket-newline": ["warn", "consistent"],
12
-
13
- // 强制数组元素间出现换行
14
- // https://eslint.org/docs/rules/array-element-newline
15
- "array-element-newline": ["warn", "consistent"],
16
-
17
- // 强制数组方括号中使用一致的空格
18
- "array-bracket-spacing": ["warn", "never"],
19
-
20
- // 禁止或强制在代码块中开括号前和闭括号后有空格
21
- // https://eslint.org/docs/rules/block-spacing
22
- "block-spacing": ["warn", "always"],
23
-
24
- // 强制在代码块中使用一致的大括号风格
25
- "brace-style": ["warn", "stroustrup", { "allowSingleLine": true }],
26
-
27
- // 要求使用骆驼拼写法
28
- "camelcase": ["off", {
29
- properties: "never",
30
- ignoreDestructuring: false,
31
- }],
32
-
33
- // enforce or disallow capitalization of the first letter of a comment
34
- // https://eslint.org/docs/rules/capitalized-comments
35
- "capitalized-comments": ["off", "never", {
36
- line: {
37
- ignorePattern: ".*",
38
- ignoreInlineComments: true,
39
- ignoreConsecutiveComments: true,
40
- },
41
- block: {
42
- ignorePattern: ".*",
43
- ignoreInlineComments: true,
44
- ignoreConsecutiveComments: true,
45
- },
46
- }],
47
-
48
- // 要求或禁止使用拖尾逗号(对象、数组、导入、导出、函数参数的最后一项后面是否允许有逗号)
49
- "comma-dangle": ["warn", {
50
- arrays: "always-multiline",
51
- objects: "always-multiline",
52
- imports: "always-multiline",
53
- exports: "always-multiline",
54
- functions: "never",
55
- }],
56
-
57
- // 强制在逗号前后使用一致的空格
58
- "comma-spacing": ["warn", {
59
- before: false,
60
- after: true,
61
- }],
62
-
63
- // 强制使用一致的逗号风格
64
- "comma-style": ["warn", "last", {
65
- exceptions: {
66
- ArrayExpression: false,
67
- ArrayPattern: false,
68
- ArrowFunctionExpression: false,
69
- CallExpression: false,
70
- FunctionDeclaration: false,
71
- FunctionExpression: false,
72
- ImportDeclaration: false,
73
- ObjectExpression: false,
74
- ObjectPattern: false,
75
- VariableDeclaration: false,
76
- NewExpression: false,
77
- },
78
- }],
79
-
80
- // 强制在计算的属性的方括号中使用一致的空格
81
- "computed-property-spacing": ["warn", "never"],
82
-
83
- // enforces consistent naming when capturing the current execution context
84
- "consistent-this": "off",
85
-
86
- // 要求或禁止文件末尾存在空行
87
- "eol-last": ["warn", "always"],
88
-
89
- // 函数调用参数换行符
90
- // https://eslint.org/docs/rules/function-call-argument-newline
91
- "function-call-argument-newline": ["warn", "consistent"],
92
-
93
- // 要求或禁止在函数标识符和其调用之间有空格
94
- // https://eslint.org/docs/rules/func-call-spacing
95
- "func-call-spacing": ["warn", "never"],
96
-
97
- // requires function names to match the name of the variable or property to which they are
98
- // assigned
99
- // https://eslint.org/docs/rules/func-name-matching
100
- "func-name-matching": ["off", "always", {
101
- includeCommonJSModuleExports: false,
102
- considerPropertyDescriptor: true,
103
- }],
104
-
105
- // 要求函数表达式要有一个函数名称
106
- // https://eslint.org/docs/rules/func-names
107
- "func-names": "off",
108
-
109
- // enforces use of function declarations or expressions
110
- // https://eslint.org/docs/rules/func-style
111
- // TODO: enable
112
- "func-style": ["off", "expression"],
113
-
114
- // 强制在函数括号内使用一致的换行
115
- // https://eslint.org/docs/rules/function-paren-newline
116
- "function-paren-newline": ["warn", "consistent"],
117
-
118
- // disallow specified identifiers
119
- // https://eslint.org/docs/rules/id-denylist
120
- "id-denylist": "off",
121
-
122
- // this option enforces minimum and maximum identifier lengths
123
- // (variable names, property names etc.)
124
- "id-length": "off",
125
-
126
- // require identifiers to match the provided regular expression
127
- "id-match": "off",
128
-
129
- // 强制隐式返回的箭头函数体的位置
130
- // https://eslint.org/docs/rules/implicit-arrow-linebreak
131
- "implicit-arrow-linebreak": ["warn", "beside"],
132
-
133
- // 强制使用一致的缩进
134
- // https://eslint.org/docs/rules/indent
135
- "indent": ["error", 2, {
136
- SwitchCase: 1,
137
- VariableDeclarator: 1,
138
- outerIIFEBody: 1,
139
- // MemberExpression: null,
140
- FunctionDeclaration: {
141
- parameters: 1,
142
- body: 1,
143
- },
144
- FunctionExpression: {
145
- parameters: 1,
146
- body: 1,
147
- },
148
- CallExpression: {
149
- arguments: 1,
150
- },
151
- ArrayExpression: 1,
152
- ObjectExpression: 1,
153
- ImportDeclaration: 1,
154
- flatTernaryExpressions: false,
155
- // list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js
156
- ignoredNodes: [
157
- "JSXElement",
158
- "JSXElement > *",
159
- "JSXAttribute",
160
- "JSXIdentifier",
161
- "JSXNamespacedName",
162
- "JSXMemberExpression",
163
- "JSXSpreadAttribute",
164
- "JSXExpressionContainer",
165
- "JSXOpeningElement",
166
- "JSXClosingElement",
167
- "JSXFragment",
168
- "JSXOpeningFragment",
169
- "JSXClosingFragment",
170
- "JSXText",
171
- "JSXEmptyExpression",
172
- "JSXSpreadChild",
173
- ],
174
- ignoreComments: false,
175
- }],
176
-
177
- // 强制在 JSX 属性中一致地使用双引号或单引号
178
- // https://eslint.org/docs/rules/jsx-quotes
179
- "jsx-quotes": ["warn", "prefer-double"],
180
-
181
- // 强制在对象字面量的键和值之间使用一致的空格
182
- "key-spacing": ["warn", {
183
- beforeColon: false,
184
- afterColon: true,
185
- }],
186
-
187
- // 强制关键字周围空格的一致性
188
- "keyword-spacing": ["warn", {
189
- "before": true,
190
- "after": true,
191
- "overrides": {
192
- "if": { "after": true },
193
- "for": { "after": false },
194
- "while": { "after": false },
195
- "switch": { "after": false },
196
- "case": { "after": true },
197
- "catch": { "after": false },
198
- "return": { "after": true },
199
- "throw": { "after": true },
200
- },
201
- }],
202
-
203
- // enforce position of line comments
204
- // https://eslint.org/docs/rules/line-comment-position
205
- // TODO: enable?
206
- "line-comment-position": ["off", {
207
- position: "above",
208
- ignorePattern: "",
209
- applyDefaultPatterns: true,
210
- }],
211
-
212
- // 强制使用一致的换行符风格
213
- // Windows - "CRLF"
214
- // Unix、Linux - "LF"
215
- // https://eslint.org/docs/rules/linebreak-style
216
- "linebreak-style": ["warn", "unix"],
217
-
218
- // require or disallow an empty line between class members
219
- // https://eslint.org/docs/rules/lines-between-class-members
220
- "lines-between-class-members": ["error", "always", { exceptAfterSingleLine: false }],
221
-
222
- // 要求在注释周围有空行
223
- "lines-around-comment": "off",
224
-
225
- // require or disallow newlines around directives
226
- // https://eslint.org/docs/rules/lines-around-directive
227
- "lines-around-directive": ["error", {
228
- before: "always",
229
- after: "always",
230
- }],
231
-
232
- // specify the maximum depth that blocks can be nested
233
- "max-depth": ["off", 4],
234
-
235
- // 强制一行的最大长度
236
- // https://eslint.org/docs/rules/max-len
237
- "max-len": ["warn", {
238
- "code": 200,
239
- "tabWidth": 2,
240
- "comments": 200,
241
- "ignoreComments": false,
242
- "ignoreTrailingComments": true,
243
- "ignoreUrls": true,
244
- "ignoreStrings": true,
245
- "ignoreTemplateLiterals": true,
246
- "ignoreRegExpLiterals": true,
247
- }],
248
-
249
- // specify the max number of lines in a file
250
- // https://eslint.org/docs/rules/max-lines
251
- "max-lines": ["off", {
252
- max: 300,
253
- skipBlankLines: true,
254
- skipComments: true,
255
- }],
256
-
257
- // enforce a maximum function length
258
- // https://eslint.org/docs/rules/max-lines-per-function
259
- "max-lines-per-function": ["off", {
260
- max: 50,
261
- skipBlankLines: true,
262
- skipComments: true,
263
- IIFEs: true,
264
- }],
265
-
266
- // specify the maximum depth callbacks can be nested
267
- "max-nested-callbacks": "off",
268
-
269
- // limits the number of parameters that can be used in the function declaration.
270
- "max-params": ["off", 3],
271
-
272
- // specify the maximum number of statement allowed in a function
273
- "max-statements": ["off", 10],
274
-
275
- // restrict the number of statements per line
276
- // https://eslint.org/docs/rules/max-statements-per-line
277
- "max-statements-per-line": ["off", { max: 1 }],
278
-
279
- // enforce a particular style for multiline comments
280
- // https://eslint.org/docs/rules/multiline-comment-style
281
- "multiline-comment-style": ["off", "starred-block"],
282
-
283
- // 要求或禁止在三元操作数中间换行
284
- // https://eslint.org/docs/rules/multiline-ternary
285
- "multiline-ternary": ["off", "never"],
286
-
287
- // 要求构造器函数首字母大写
288
- // https://eslint.org/docs/latest/rules/new-cap
289
- "new-cap": ["warn", {
290
- newIsCap: true,
291
- newIsCapExceptions: [],
292
- newIsCapExceptionPattern: "^hh[A-Z]",
293
- capIsNew: false,
294
- capIsNewExceptions: ["Immutable.Map", "Immutable.Set", "Immutable.List"],
295
- }],
296
-
297
- // 强制或禁止调用无参构造函数时有圆括号
298
- // https://eslint.org/docs/rules/new-parens
299
- "new-parens": ["error", "always"],
300
-
301
- // allow/disallow an empty newline after var statement
302
- "newline-after-var": "off",
303
-
304
- // https://eslint.org/docs/rules/newline-before-return
305
- "newline-before-return": "off",
306
-
307
- // 要求方法链中每个调用都有一个换行符
308
- // https://eslint.org/docs/rules/newline-per-chained-call
309
- "newline-per-chained-call": ["warn", { ignoreChainWithDepth: 4 }],
310
-
311
- // disallow use of the Array constructor
312
- "no-array-constructor": "error",
313
-
314
- // 禁用按位运算符
315
- // https://eslint.org/docs/rules/no-bitwise
316
- "no-bitwise": "off",
317
- // "no-bitwise": "error",
318
-
319
- // disallow use of the continue statement
320
- // https://eslint.org/docs/rules/no-continue
321
- "no-continue": "error",
322
-
323
- // disallow comments inline after code
324
- "no-inline-comments": "off",
325
-
326
- // 禁止 if 作为唯一的语句出现在 else 语句中
327
- // https://eslint.org/docs/rules/no-lonely-if
328
- "no-lonely-if": "off",
329
- // "no-lonely-if": "error",
330
-
331
- // 禁止混合使用不同的操作符
332
- // https://eslint.org/docs/rules/no-mixed-operators
333
- "no-mixed-operators": [
334
- "off",
335
- {
336
- "groups": [
337
- ["+", "-", "*", "/", "%", "**"],
338
- ["&", "|", "^", "~", "<<", ">>", ">>>"],
339
- ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
340
- ["&&", "||"],
341
- ["in", "instanceof"],
342
- ],
343
- "allowSamePrecedence": true,
344
- },
345
- ],
346
-
347
- // 禁止空格和 tab 的混合缩进
348
- "no-mixed-spaces-and-tabs": "warn",
349
-
350
- // 禁止连续赋值
351
- // https://eslint.org/docs/rules/no-multi-assign
352
- "no-multi-assign": "off",
353
- // "no-multi-assign": ["error"],
354
-
355
- // 禁止出现多行空行
356
- // https://eslint.org/docs/rules/no-multiple-empty-lines
357
- "no-multiple-empty-lines": ["warn", {
358
- "max": 2,
359
- "maxBOF": 1,
360
- "maxEOF": 1,
361
- }],
362
-
363
- // disallow negated conditions
364
- // https://eslint.org/docs/rules/no-negated-condition
365
- "no-negated-condition": "off",
366
-
367
- // 禁用嵌套的三元表达式
368
- "no-nested-ternary": "off",
369
- // "no-nested-ternary": "error",
370
-
371
- // disallow use of the Object constructor
372
- "no-new-object": "error",
373
-
374
- // 禁用一元操作符 ++ 和 --
375
- // https://eslint.org/docs/rules/no-plusplus
376
- "no-plusplus": "off",
377
- // "no-plusplus": "error",
378
-
379
- // 禁用特定的语法
380
- // https://eslint.org/docs/rules/no-restricted-syntax
381
- "no-restricted-syntax": [
382
- "off",
383
- {
384
- selector: "ForInStatement",
385
- 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.",
386
- },
387
- {
388
- selector: "ForOfStatement",
389
- message: "iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.",
390
- },
391
- {
392
- selector: "LabeledStatement",
393
- message: "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
394
- },
395
- {
396
- selector: "WithStatement",
397
- message: "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
398
- },
399
- ],
400
-
401
- // 禁用 tab
402
- "no-tabs": "warn",
403
-
404
- // disallow the use of ternary operators
405
- "no-ternary": "off",
406
-
407
- // 禁用行尾空白
408
- "no-trailing-spaces": ["warn", {
409
- "skipBlankLines": true,
410
- "ignoreComments": false,
411
- }],
412
-
413
- // 禁止标识符中有悬空下划线
414
- // https://eslint.org/docs/rules/no-underscore-dangle
415
- "no-underscore-dangle": "off",
416
- // "no-underscore-dangle": ["error", {
417
- // allow: [],
418
- // allowAfterThis: false,
419
- // allowAfterSuper: false,
420
- // enforceInMethodNames: true,
421
- // }],
422
-
423
- // disallow the use of Boolean literals in conditional expressions
424
- // also, prefer `a || b` over `a ? a : b`
425
- // https://eslint.org/docs/rules/no-unneeded-ternary
426
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
427
-
428
- // 禁止属性前有空白
429
- // https://eslint.org/docs/rules/no-whitespace-before-property
430
- "no-whitespace-before-property": "error",
431
-
432
- // 强制单个语句的位置
433
- // https://eslint.org/docs/rules/nonblock-statement-body-position
434
- "nonblock-statement-body-position": "off",
435
-
436
- // 强制在花括号中使用一致的空格
437
- // https://eslint.org/docs/rules/object-curly-spacing
438
- "object-curly-spacing": ["warn", "always", {
439
- arraysInObjects: true,
440
- objectsInObjects: true,
441
- }],
442
-
443
- // 强制大括号内换行符的一致性
444
- // https://eslint.org/docs/rules/object-curly-newline
445
- "object-curly-newline": ["warn", {
446
- ObjectExpression: { minProperties: 40, multiline: true, consistent: true },
447
- ObjectPattern: "never",
448
- ImportDeclaration: "never",
449
- ExportDeclaration: "always",
450
- }],
451
-
452
- // 强制将对象的属性放在不同的行上
453
- // https://eslint.org/docs/rules/object-property-newline
454
- "object-property-newline": ["off", {
455
- allowAllPropertiesOnSameLine: false,
456
- }],
457
-
458
- // 强制函数中的变量要么一起声明要么分开声明
459
- "one-var": "off",
460
- // "one-var": ["error", "never"],
461
-
462
- // 要求或禁止在变量声明周围换行
463
- // https://eslint.org/docs/rules/one-var-declaration-per-line
464
- "one-var-declaration-per-line": "off",
465
-
466
- // require assignment operator shorthand where possible or prohibit it entirely
467
- // https://eslint.org/docs/rules/operator-assignment
468
- "operator-assignment": ["error", "always"],
469
-
470
- // 强制操作符使用一致的换行符
471
- // https://eslint.org/docs/rules/operator-linebreak
472
- "operator-linebreak": ["off", "before", { overrides: { "=": "none" } }],
473
-
474
- // 要求或禁止块内填充
475
- "padded-blocks": "off",
476
-
477
- // Require or disallow padding lines between statements
478
- // https://eslint.org/docs/rules/padding-line-between-statements
479
- "padding-line-between-statements": "off",
480
-
481
- // Disallow the use of Math.pow in favor of the ** operator
482
- // https://eslint.org/docs/rules/prefer-exponentiation-operator
483
- "prefer-exponentiation-operator": "error",
484
-
485
- // 禁止使用以对象字面量作为第一个参数的 Object.assign,优先使用对象扩展
486
- // https://eslint.org/docs/rules/prefer-object-spread
487
- "prefer-object-spread": "off",
488
- // "prefer-object-spread": "error",
489
-
490
- // 要求对象字面量属性名称用引号括起来
491
- // https://eslint.org/docs/rules/quote-props.html
492
- "quote-props": ["warn", "consistent"],
493
-
494
- // 强制使用一致的反勾号、双引号或单引号
495
- "quotes": ["warn", "double", { "avoidEscape": true }],
496
-
497
- // do not require jsdoc
498
- // https://eslint.org/docs/rules/require-jsdoc
499
- "require-jsdoc": "off",
500
-
501
- // 要求或禁止使用分号代替 ASI
502
- "semi": ["error", "always"],
503
-
504
- // 强制分号之前和之后使用一致的空格
505
- "semi-spacing": ["error", { before: false, after: true }],
506
-
507
- // 强制分号的位置
508
- // https://eslint.org/docs/rules/semi-style
509
- "semi-style": ["error", "last"],
510
-
511
- // requires object keys to be sorted
512
- "sort-keys": ["off", "asc", { caseSensitive: false, natural: true }],
513
-
514
- // sort variables within the same declaration block
515
- "sort-vars": "off",
516
-
517
- // 要求或禁止语句块之前的空格(代码块大括号前面是否需要空格)
518
- // https://eslint.org/docs/latest/rules/space-before-blocks
519
- "space-before-blocks": ["warn", {
520
- functions: "always",
521
- keywords: "always",
522
- classes: "always",
523
- }],
524
-
525
- // 强制在 function 的左括号之前使用一致的空格
526
- // https://eslint.org/docs/rules/space-before-function-paren
527
- "space-before-function-paren": ["warn", {
528
- anonymous: "never",
529
- named: "never",
530
- asyncArrow: "always",
531
- }],
532
-
533
- // 强制在圆括号内使用一致的空格
534
- "space-in-parens": ["warn", "never"],
535
-
536
- // 要求中缀操作符周围有空格(+-*/?| etc.)
537
- "space-infix-ops": "warn",
538
-
539
- // 强制在一元操作符前后使用一致的空格
540
- // https://eslint.org/docs/rules/space-unary-ops
541
- "space-unary-ops": ["warn", {
542
- words: true,
543
- nonwords: false,
544
- }],
545
-
546
- // 要求或禁止在注释前有空白 (space 或 tab)
547
- // require or disallow a space immediately following the // or /* in a comment
548
- // https://eslint.org/docs/rules/spaced-comment
549
- "spaced-comment": "off",
550
- // "spaced-comment": ["error", "always", {
551
- // line: {
552
- // exceptions: ["-", "+"],
553
- // markers: ["=", "!", "/"], // space here to support sprockets directives, slash for TS /// comments
554
- // },
555
- // block: {
556
- // exceptions: ["-", "+"],
557
- // markers: ["=", "!", ":", "::"], // space here to support sprockets directives and flow comment types
558
- // balanced: true,
559
- // }
560
- // }],
561
-
562
- // 强制在 switch 的冒号左右有空格
563
- // https://eslint.org/docs/rules/switch-colon-spacing
564
- "switch-colon-spacing": ["error", { after: true, before: false }],
565
-
566
- // 要求或禁止在模板标记和它们的字面量之间有空格
567
- // https://eslint.org/docs/rules/template-tag-spacing
568
- "template-tag-spacing": ["error", "never"],
569
-
570
- // 要求或禁止 Unicode 字节顺序标记 (BOM)
571
- // https://eslint.org/docs/rules/unicode-bom
572
- "unicode-bom": ["off", "never"],
573
-
574
- // 要求正则表达式被括号括起来
575
- "wrap-regex": "off",
576
- },
577
- };
@@ -1,73 +0,0 @@
1
-
2
- // ==========================================================
3
- // Variables
4
- // 这些规则与变量声明有关
5
- // ==========================================================
6
-
7
- // const confusingBrowserGlobals = require("confusing-browser-globals");
8
-
9
- module.exports = {
10
- rules: {
11
- // enforce or disallow variable initializations at definition
12
- "init-declarations": "off",
13
-
14
- // disallow the catch clause parameter name being the same as a variable in the outer scope
15
- "no-catch-shadow": "off",
16
-
17
- // disallow deletion of variables
18
- "no-delete-var": "error",
19
-
20
- // disallow labels that share a name with a variable
21
- // https://eslint.org/docs/rules/no-label-var
22
- "no-label-var": "error",
23
-
24
- // 禁用特定的全局变量
25
- // 'no-restricted-globals': [
26
- // 'error',
27
- // {
28
- // name: 'isFinite',
29
- // message:
30
- // 'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
31
- // },
32
- // {
33
- // name: 'isNaN',
34
- // message:
35
- // 'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
36
- // },
37
- // ].concat(confusingBrowserGlobals),
38
- "no-restricted-globals": "off",
39
-
40
- // disallow declaration of variables already declared in the outer scope
41
- "no-shadow": "error",
42
-
43
- // disallow shadowing of names such as arguments
44
- "no-shadow-restricted-names": "error",
45
-
46
- // 禁用未声明的变量
47
- // disallow use of undeclared variables unless mentioned in a /*global */ block
48
- "no-undef": "error",
49
-
50
- // disallow use of undefined when initializing variables
51
- "no-undef-init": "error",
52
-
53
- // disallow use of undefined variable
54
- // https://eslint.org/docs/rules/no-undefined
55
- // TODO: enable?
56
- "no-undefined": "off",
57
-
58
- // 禁止定义变量后不使用
59
- "no-unused-vars": ["error", {
60
- vars: "all",
61
- args: "none",
62
- ignoreRestSiblings: true,
63
- caughtErrors: "none",
64
- }],
65
-
66
- // 禁止定义前使用
67
- "no-use-before-define": ["error", {
68
- functions: false,
69
- classes: true,
70
- variables: true,
71
- }],
72
- },
73
- };