@houheaven/eslint-config-helper 1.4.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +149 -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 +24 -32
  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 +38 -22
  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/typescript.js +0 -10
  73. package/lib/configs/vue2.js +0 -28
  74. package/lib/configs/vue3.js +0 -28
  75. package/lib/eslint.js +0 -18
  76. package/lib/format.js +0 -40
  77. package/lib/rules/eslint/best-practices.js +0 -422
  78. package/lib/rules/eslint/node.js +0 -48
  79. package/lib/rules/eslint/strict-mode.js +0 -12
  80. package/lib/rules/eslint/stylistic-issues.js +0 -578
  81. package/lib/rules/eslint/variables.js +0 -73
  82. package/lib/rules/typescript/all.js +0 -193
  83. package/lib/rules/typescript/base.js +0 -10
  84. package/lib/rules/typescript/eslint-recommended.js +0 -36
  85. package/lib/rules/typescript/recommended-requiring-type-checking.js +0 -26
  86. package/lib/rules/typescript/recommended.js +0 -36
  87. package/lib/rules/typescript/strict.js +0 -47
  88. package/lib/rules/vue/common-eslint.js +0 -220
  89. package/lib/rules/vue/vue2-recommended.js +0 -17
  90. package/lib/rules/vue/vue2-strongly-recommended.js +0 -16
  91. package/lib/rules/vue/vue3-recommended.js +0 -17
@@ -1,578 +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
- "lines-between-class-members": "off",
222
-
223
- // 要求在注释周围有空行
224
- "lines-around-comment": "off",
225
-
226
- // require or disallow newlines around directives
227
- // https://eslint.org/docs/rules/lines-around-directive
228
- "lines-around-directive": ["error", {
229
- before: "always",
230
- after: "always",
231
- }],
232
-
233
- // specify the maximum depth that blocks can be nested
234
- "max-depth": ["off", 4],
235
-
236
- // 强制一行的最大长度
237
- // https://eslint.org/docs/rules/max-len
238
- "max-len": ["warn", {
239
- "code": 200,
240
- "tabWidth": 2,
241
- "comments": 200,
242
- "ignoreComments": false,
243
- "ignoreTrailingComments": true,
244
- "ignoreUrls": true,
245
- "ignoreStrings": true,
246
- "ignoreTemplateLiterals": true,
247
- "ignoreRegExpLiterals": true,
248
- }],
249
-
250
- // specify the max number of lines in a file
251
- // https://eslint.org/docs/rules/max-lines
252
- "max-lines": ["off", {
253
- max: 300,
254
- skipBlankLines: true,
255
- skipComments: true,
256
- }],
257
-
258
- // enforce a maximum function length
259
- // https://eslint.org/docs/rules/max-lines-per-function
260
- "max-lines-per-function": ["off", {
261
- max: 50,
262
- skipBlankLines: true,
263
- skipComments: true,
264
- IIFEs: true,
265
- }],
266
-
267
- // specify the maximum depth callbacks can be nested
268
- "max-nested-callbacks": "off",
269
-
270
- // limits the number of parameters that can be used in the function declaration.
271
- "max-params": ["off", 3],
272
-
273
- // specify the maximum number of statement allowed in a function
274
- "max-statements": ["off", 10],
275
-
276
- // restrict the number of statements per line
277
- // https://eslint.org/docs/rules/max-statements-per-line
278
- "max-statements-per-line": ["off", { max: 1 }],
279
-
280
- // enforce a particular style for multiline comments
281
- // https://eslint.org/docs/rules/multiline-comment-style
282
- "multiline-comment-style": ["off", "starred-block"],
283
-
284
- // 要求或禁止在三元操作数中间换行
285
- // https://eslint.org/docs/rules/multiline-ternary
286
- "multiline-ternary": ["off", "never"],
287
-
288
- // 要求构造器函数首字母大写
289
- // https://eslint.org/docs/latest/rules/new-cap
290
- "new-cap": ["warn", {
291
- newIsCap: true,
292
- newIsCapExceptions: [],
293
- newIsCapExceptionPattern: "^hh[A-Z]",
294
- capIsNew: false,
295
- capIsNewExceptions: ["Immutable.Map", "Immutable.Set", "Immutable.List"],
296
- }],
297
-
298
- // 强制或禁止调用无参构造函数时有圆括号
299
- // https://eslint.org/docs/rules/new-parens
300
- "new-parens": ["error", "always"],
301
-
302
- // allow/disallow an empty newline after var statement
303
- "newline-after-var": "off",
304
-
305
- // https://eslint.org/docs/rules/newline-before-return
306
- "newline-before-return": "off",
307
-
308
- // 要求方法链中每个调用都有一个换行符
309
- // https://eslint.org/docs/rules/newline-per-chained-call
310
- "newline-per-chained-call": ["warn", { ignoreChainWithDepth: 4 }],
311
-
312
- // disallow use of the Array constructor
313
- "no-array-constructor": "error",
314
-
315
- // 禁用按位运算符
316
- // https://eslint.org/docs/rules/no-bitwise
317
- "no-bitwise": "off",
318
- // "no-bitwise": "error",
319
-
320
- // disallow use of the continue statement
321
- // https://eslint.org/docs/rules/no-continue
322
- "no-continue": "error",
323
-
324
- // disallow comments inline after code
325
- "no-inline-comments": "off",
326
-
327
- // 禁止 if 作为唯一的语句出现在 else 语句中
328
- // https://eslint.org/docs/rules/no-lonely-if
329
- "no-lonely-if": "off",
330
- // "no-lonely-if": "error",
331
-
332
- // 禁止混合使用不同的操作符
333
- // https://eslint.org/docs/rules/no-mixed-operators
334
- "no-mixed-operators": [
335
- "off",
336
- {
337
- "groups": [
338
- ["+", "-", "*", "/", "%", "**"],
339
- ["&", "|", "^", "~", "<<", ">>", ">>>"],
340
- ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
341
- ["&&", "||"],
342
- ["in", "instanceof"],
343
- ],
344
- "allowSamePrecedence": true,
345
- },
346
- ],
347
-
348
- // 禁止空格和 tab 的混合缩进
349
- "no-mixed-spaces-and-tabs": "warn",
350
-
351
- // 禁止连续赋值
352
- // https://eslint.org/docs/rules/no-multi-assign
353
- "no-multi-assign": "off",
354
- // "no-multi-assign": ["error"],
355
-
356
- // 禁止出现多行空行
357
- // https://eslint.org/docs/rules/no-multiple-empty-lines
358
- "no-multiple-empty-lines": ["warn", {
359
- "max": 2,
360
- "maxBOF": 1,
361
- "maxEOF": 1,
362
- }],
363
-
364
- // disallow negated conditions
365
- // https://eslint.org/docs/rules/no-negated-condition
366
- "no-negated-condition": "off",
367
-
368
- // 禁用嵌套的三元表达式
369
- "no-nested-ternary": "off",
370
- // "no-nested-ternary": "error",
371
-
372
- // disallow use of the Object constructor
373
- "no-new-object": "error",
374
-
375
- // 禁用一元操作符 ++ 和 --
376
- // https://eslint.org/docs/rules/no-plusplus
377
- "no-plusplus": "off",
378
- // "no-plusplus": "error",
379
-
380
- // 禁用特定的语法
381
- // https://eslint.org/docs/rules/no-restricted-syntax
382
- "no-restricted-syntax": [
383
- "off",
384
- {
385
- selector: "ForInStatement",
386
- 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.",
387
- },
388
- {
389
- selector: "ForOfStatement",
390
- 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.",
391
- },
392
- {
393
- selector: "LabeledStatement",
394
- message: "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
395
- },
396
- {
397
- selector: "WithStatement",
398
- message: "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
399
- },
400
- ],
401
-
402
- // 禁用 tab
403
- "no-tabs": "warn",
404
-
405
- // disallow the use of ternary operators
406
- "no-ternary": "off",
407
-
408
- // 禁用行尾空白
409
- "no-trailing-spaces": ["warn", {
410
- "skipBlankLines": true,
411
- "ignoreComments": false,
412
- }],
413
-
414
- // 禁止标识符中有悬空下划线
415
- // https://eslint.org/docs/rules/no-underscore-dangle
416
- "no-underscore-dangle": "off",
417
- // "no-underscore-dangle": ["error", {
418
- // allow: [],
419
- // allowAfterThis: false,
420
- // allowAfterSuper: false,
421
- // enforceInMethodNames: true,
422
- // }],
423
-
424
- // disallow the use of Boolean literals in conditional expressions
425
- // also, prefer `a || b` over `a ? a : b`
426
- // https://eslint.org/docs/rules/no-unneeded-ternary
427
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
428
-
429
- // 禁止属性前有空白
430
- // https://eslint.org/docs/rules/no-whitespace-before-property
431
- "no-whitespace-before-property": "error",
432
-
433
- // 强制单个语句的位置
434
- // https://eslint.org/docs/rules/nonblock-statement-body-position
435
- "nonblock-statement-body-position": "off",
436
-
437
- // 强制在花括号中使用一致的空格
438
- // https://eslint.org/docs/rules/object-curly-spacing
439
- "object-curly-spacing": ["warn", "always", {
440
- arraysInObjects: true,
441
- objectsInObjects: true,
442
- }],
443
-
444
- // 强制大括号内换行符的一致性
445
- // https://eslint.org/docs/rules/object-curly-newline
446
- "object-curly-newline": ["warn", {
447
- ObjectExpression: { minProperties: 40, multiline: true, consistent: true },
448
- ObjectPattern: "never",
449
- ImportDeclaration: "never",
450
- ExportDeclaration: "always",
451
- }],
452
-
453
- // 强制将对象的属性放在不同的行上
454
- // https://eslint.org/docs/rules/object-property-newline
455
- "object-property-newline": ["off", {
456
- allowAllPropertiesOnSameLine: false,
457
- }],
458
-
459
- // 强制函数中的变量要么一起声明要么分开声明
460
- "one-var": "off",
461
- // "one-var": ["error", "never"],
462
-
463
- // 要求或禁止在变量声明周围换行
464
- // https://eslint.org/docs/rules/one-var-declaration-per-line
465
- "one-var-declaration-per-line": "off",
466
-
467
- // require assignment operator shorthand where possible or prohibit it entirely
468
- // https://eslint.org/docs/rules/operator-assignment
469
- "operator-assignment": ["error", "always"],
470
-
471
- // 强制操作符使用一致的换行符
472
- // https://eslint.org/docs/rules/operator-linebreak
473
- "operator-linebreak": ["off", "before", { overrides: { "=": "none" } }],
474
-
475
- // 要求或禁止块内填充
476
- "padded-blocks": "off",
477
-
478
- // Require or disallow padding lines between statements
479
- // https://eslint.org/docs/rules/padding-line-between-statements
480
- "padding-line-between-statements": "off",
481
-
482
- // Disallow the use of Math.pow in favor of the ** operator
483
- // https://eslint.org/docs/rules/prefer-exponentiation-operator
484
- "prefer-exponentiation-operator": "error",
485
-
486
- // 禁止使用以对象字面量作为第一个参数的 Object.assign,优先使用对象扩展
487
- // https://eslint.org/docs/rules/prefer-object-spread
488
- "prefer-object-spread": "off",
489
- // "prefer-object-spread": "error",
490
-
491
- // 要求对象字面量属性名称用引号括起来
492
- // https://eslint.org/docs/rules/quote-props.html
493
- "quote-props": ["warn", "consistent"],
494
-
495
- // 强制使用一致的反勾号、双引号或单引号
496
- "quotes": ["warn", "double", { "avoidEscape": true }],
497
-
498
- // do not require jsdoc
499
- // https://eslint.org/docs/rules/require-jsdoc
500
- "require-jsdoc": "off",
501
-
502
- // 要求或禁止使用分号代替 ASI
503
- "semi": ["error", "always"],
504
-
505
- // 强制分号之前和之后使用一致的空格
506
- "semi-spacing": ["error", { before: false, after: true }],
507
-
508
- // 强制分号的位置
509
- // https://eslint.org/docs/rules/semi-style
510
- "semi-style": ["error", "last"],
511
-
512
- // requires object keys to be sorted
513
- "sort-keys": ["off", "asc", { caseSensitive: false, natural: true }],
514
-
515
- // sort variables within the same declaration block
516
- "sort-vars": "off",
517
-
518
- // 要求或禁止语句块之前的空格(代码块大括号前面是否需要空格)
519
- // https://eslint.org/docs/latest/rules/space-before-blocks
520
- "space-before-blocks": ["warn", {
521
- functions: "always",
522
- keywords: "always",
523
- classes: "always",
524
- }],
525
-
526
- // 强制在 function 的左括号之前使用一致的空格
527
- // https://eslint.org/docs/rules/space-before-function-paren
528
- "space-before-function-paren": ["warn", {
529
- anonymous: "never",
530
- named: "never",
531
- asyncArrow: "always",
532
- }],
533
-
534
- // 强制在圆括号内使用一致的空格
535
- "space-in-parens": ["warn", "never"],
536
-
537
- // 要求中缀操作符周围有空格(+-*/?| etc.)
538
- "space-infix-ops": "warn",
539
-
540
- // 强制在一元操作符前后使用一致的空格
541
- // https://eslint.org/docs/rules/space-unary-ops
542
- "space-unary-ops": ["warn", {
543
- words: true,
544
- nonwords: false,
545
- }],
546
-
547
- // 要求或禁止在注释前有空白 (space 或 tab)
548
- // require or disallow a space immediately following the // or /* in a comment
549
- // https://eslint.org/docs/rules/spaced-comment
550
- "spaced-comment": "off",
551
- // "spaced-comment": ["error", "always", {
552
- // line: {
553
- // exceptions: ["-", "+"],
554
- // markers: ["=", "!", "/"], // space here to support sprockets directives, slash for TS /// comments
555
- // },
556
- // block: {
557
- // exceptions: ["-", "+"],
558
- // markers: ["=", "!", ":", "::"], // space here to support sprockets directives and flow comment types
559
- // balanced: true,
560
- // }
561
- // }],
562
-
563
- // 强制在 switch 的冒号左右有空格
564
- // https://eslint.org/docs/rules/switch-colon-spacing
565
- "switch-colon-spacing": ["error", { after: true, before: false }],
566
-
567
- // 要求或禁止在模板标记和它们的字面量之间有空格
568
- // https://eslint.org/docs/rules/template-tag-spacing
569
- "template-tag-spacing": ["error", "never"],
570
-
571
- // 要求或禁止 Unicode 字节顺序标记 (BOM)
572
- // https://eslint.org/docs/rules/unicode-bom
573
- "unicode-bom": ["off", "never"],
574
-
575
- // 要求正则表达式被括号括起来
576
- "wrap-regex": "off",
577
- },
578
- };
@@ -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
- };