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