@houheaven/eslint-config-helper 1.0.0 → 1.2.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 (52) hide show
  1. package/README.md +112 -53
  2. package/format.js +40 -0
  3. package/html.js +32 -0
  4. package/index.js +18 -0
  5. package/lib/configs/eslint-es5.js +24 -0
  6. package/lib/configs/eslint.js +23 -0
  7. package/lib/configs/format-html.js +22 -0
  8. package/lib/configs/format-js.js +134 -0
  9. package/{eslint/prettier.js → lib/configs/format-prettier.js} +109 -45
  10. package/lib/configs/format-vue.js +278 -0
  11. package/lib/configs/html.js +20 -0
  12. package/lib/configs/import-bugfix.js +36 -0
  13. package/lib/configs/import.js +44 -0
  14. package/lib/configs/vue2.js +28 -0
  15. package/lib/configs/vue3.js +28 -0
  16. package/{eslint/rules → lib/rules/eslint}/best-practices.js +19 -19
  17. package/{eslint/rules → lib/rules/eslint}/es6.js +8 -9
  18. package/{eslint/rules → lib/rules/eslint}/node.js +0 -0
  19. package/{eslint/rules → lib/rules/eslint}/possible-errors.js +16 -11
  20. package/{eslint/rules → lib/rules/eslint}/strict-mode.js +0 -0
  21. package/{eslint/rules → lib/rules/eslint}/stylistic-issues.js +60 -59
  22. package/{eslint/rules → lib/rules/eslint}/variables.js +13 -11
  23. package/lib/rules/html/accessibility.js +44 -0
  24. package/lib/rules/html/best-practice.js +64 -0
  25. package/lib/rules/html/seo.js +24 -0
  26. package/lib/rules/html/style.js +32 -0
  27. package/lib/rules/import/helpful-warnings.js +68 -0
  28. package/lib/rules/import/module-systems.js +34 -0
  29. package/lib/rules/import/static-analysis.js +69 -0
  30. package/lib/rules/import/style-guide.js +97 -0
  31. package/lib/rules/vue/common-base.js +29 -0
  32. package/lib/rules/vue/common-eslint.js +220 -0
  33. package/lib/rules/vue/common-essential.js +267 -0
  34. package/lib/rules/vue/common-extra.js +282 -0
  35. package/lib/rules/vue/common-recommended.js +96 -0
  36. package/lib/rules/vue/common-strongly-recommended.js +138 -0
  37. package/lib/rules/vue/vue2-essential.js +41 -0
  38. package/lib/rules/vue/vue2-recommended.js +17 -0
  39. package/lib/rules/vue/vue2-strongly-recommended.js +16 -0
  40. package/lib/rules/vue/vue3-essential.js +129 -0
  41. package/lib/rules/vue/vue3-recommended.js +17 -0
  42. package/lib/rules/vue/vue3-strongly-recommended.js +24 -0
  43. package/lib/rules/vuejs-accessibility/index.js +92 -0
  44. package/package.json +37 -28
  45. package/vue2.js +30 -0
  46. package/vue3.js +28 -0
  47. package/eslint/eslint-fix.js +0 -29
  48. package/eslint/file-bof-eof.js +0 -22
  49. package/eslint/index.js +0 -18
  50. package/eslint/legacy.js +0 -34
  51. package/eslint/rules/imports.js +0 -279
  52. package/eslint/rules/vue.js +0 -23
@@ -0,0 +1,36 @@
1
+
2
+ // ===============================================================================
3
+ // 修复 Vue 中设置的别名(比如 @)无法被 import/no-unresolved 规则解析的问题
4
+ // -------------------------------------------------------------------------------
5
+ // Vue2
6
+ // 方案:设置解析器("import/resolver"),用来解析 Vue - webpack 中设置的别名
7
+ // 依赖:eslint-import-resolver-node、eslint-import-resolver-webpack
8
+ // -------------------------------------------------------------------------------
9
+ // Vue3
10
+ // 方案:设置解析器("import/resolver"),用来解析 Vue - vite 中设置的别名
11
+ // 依赖:eslint-import-resolver-alias
12
+ // ===============================================================================
13
+
14
+ const importResolver = {
15
+ [require.resolve("eslint-import-resolver-node")]: {},
16
+ };
17
+
18
+ try {
19
+ const vueCliConfig = require.resolve("@vue/cli-service/webpack.config.js");
20
+ importResolver[require.resolve("eslint-import-resolver-webpack")] = {
21
+ config: vueCliConfig,
22
+ };
23
+ }
24
+ catch(e) {
25
+ // ignore
26
+ }
27
+
28
+ // Vue3 Vite alias
29
+ const path = require("path");
30
+ importResolver["alias"] = {
31
+ map: [
32
+ ["@", path.resolve(process.cwd(), "src")],
33
+ ],
34
+ };
35
+
36
+ module.exports = importResolver;
@@ -0,0 +1,44 @@
1
+
2
+ // ===============================================================================
3
+ // import/export 规则
4
+ // -------------------------------------------------------------------------------
5
+ // 包名:eslint-plugin-import
6
+ // 文档:https://www.npmjs.com/package/eslint-plugin-import
7
+ // ===============================================================================
8
+
9
+ const importResolver = require("./import-bugfix.js");
10
+
11
+ module.exports = {
12
+ env: {
13
+ es6: true,
14
+ },
15
+ parserOptions: {
16
+ ecmaVersion: 6,
17
+ sourceType: "module",
18
+ },
19
+ extends: [
20
+ "../rules/import/static-analysis.js",
21
+ "../rules/import/helpful-warnings.js",
22
+ "../rules/import/module-systems.js",
23
+ "../rules/import/style-guide.js",
24
+ ],
25
+ plugins: [
26
+ "import",
27
+ ],
28
+ settings: {
29
+ "import/resolver": {
30
+ ...importResolver,
31
+ },
32
+ "import/extensions": [
33
+ ".js",
34
+ ".jsx",
35
+ ".mjs",
36
+ ".ts",
37
+ ".tsx",
38
+ ],
39
+ "import/ignore": [
40
+ "node_modules",
41
+ "\\.(coffee|scss|css|less|hbs|svg|json)$",
42
+ ],
43
+ },
44
+ };
@@ -0,0 +1,28 @@
1
+
2
+ // ==========================================================
3
+ // Vue2 全部规则
4
+ // ----------------------------------------------------------
5
+ // - plugin:vue/base
6
+ // - plugin:vue/essential
7
+ // - plugin:vue/strongly-recommended
8
+ // - plugin:vue/recommended
9
+ // - common-extra
10
+ // - common-eslint
11
+ // ==========================================================
12
+
13
+ module.exports = {
14
+ extends: [
15
+ "../rules/vue/vue2-recommended.js",
16
+ "../rules/vue/common-extra.js",
17
+ "../rules/vue/common-eslint.js",
18
+ ],
19
+ rules: {
20
+ "indent": "off",
21
+ "max-len": "off",
22
+ "no-irregular-whitespace": "off",
23
+ "vue/no-unsupported-features": ["error", {
24
+ "version": "^2.6.0",
25
+ "ignores": [],
26
+ }],
27
+ },
28
+ };
@@ -0,0 +1,28 @@
1
+
2
+ // ==========================================================
3
+ // Vue3 全部规则
4
+ // ----------------------------------------------------------
5
+ // - plugin:vue/base
6
+ // - plugin:vue/vue3-essential
7
+ // - plugin:vue/vue3-strongly-recommended
8
+ // - plugin:vue/vue3-recommended
9
+ // - common-extra
10
+ // - common-eslint
11
+ // ==========================================================
12
+
13
+ module.exports = {
14
+ extends: [
15
+ "../rules/vue/vue3-recommended.js",
16
+ "../rules/vue/common-extra.js",
17
+ "../rules/vue/common-eslint.js",
18
+ ],
19
+ rules: {
20
+ "indent": "off",
21
+ "max-len": "off",
22
+ "no-irregular-whitespace": "off",
23
+ "vue/no-unsupported-features": ["error", {
24
+ "version": "^3.2.0",
25
+ "ignores": [],
26
+ }],
27
+ },
28
+ };
@@ -6,15 +6,15 @@
6
6
 
7
7
  module.exports = {
8
8
  rules: {
9
- // enforces getter/setter pairs in objects
9
+ // 强制对象中的 getter/setter 成对出现
10
10
  // https://eslint.org/docs/rules/accessor-pairs
11
11
  "accessor-pairs": "off",
12
12
 
13
- // enforces return statements in callbacks of array's methods
13
+ // 强制在数组方法的回调中要有 return
14
14
  // https://eslint.org/docs/rules/array-callback-return
15
15
  "array-callback-return": ["error", { allowImplicit: true }],
16
16
 
17
- // treat var statements as if they were block scoped
17
+ // 在定义的范围内强制使用变量
18
18
  // https://eslint.org/docs/rules/block-scoped-var
19
19
  "block-scoped-var": "error",
20
20
 
@@ -41,22 +41,22 @@ module.exports = {
41
41
  "default-case": "off",
42
42
  // 'default-case': ['error', { commentPattern: '^no default$' }],
43
43
 
44
- // Enforce default clauses in switch statements to be last
44
+ // 强制 switch 语句中的 default 子句放在最后
45
45
  // https://eslint.org/docs/rules/default-case-last
46
- "default-case-last": "error",
46
+ "default-case-last": "off",
47
47
 
48
48
  // https://eslint.org/docs/rules/default-param-last
49
49
  "default-param-last": "error",
50
50
 
51
- // encourages use of dot notation whenever possible
52
- // https://eslint.org/docs/rules/dot-notation
53
- "dot-notation": ["error", { allowKeywords: true }],
54
-
55
51
  // 强制在点号之前和之后一致的换行
56
52
  // https://eslint.org/docs/rules/dot-location
57
53
  "dot-location": ["warn", "property"],
58
54
 
59
- // require the use of === and !==
55
+ // 尽可能的使用点符号
56
+ // https://eslint.org/docs/rules/dot-notation
57
+ "dot-notation": ["warn", { allowKeywords: true }],
58
+
59
+ // 要求使用 === 和 !==
60
60
  // https://eslint.org/docs/rules/eqeqeq
61
61
  "eqeqeq": ["error", "always", { null: "ignore" }],
62
62
 
@@ -106,11 +106,11 @@ module.exports = {
106
106
  allow: [
107
107
  "arrowFunctions",
108
108
  "functions",
109
- "methods"
109
+ "methods",
110
110
  ],
111
111
  }],
112
112
 
113
- // disallow empty destructuring patterns
113
+ // 禁止空的解构模式
114
114
  // https://eslint.org/docs/rules/no-empty-pattern
115
115
  "no-empty-pattern": "error",
116
116
 
@@ -144,7 +144,7 @@ module.exports = {
144
144
 
145
145
  // disallow reassignments of native objects or read-only globals
146
146
  // https://eslint.org/docs/rules/no-global-assign
147
- "no-global-assign": ["error", { exceptions: []}],
147
+ "no-global-assign": ["error", { exceptions: [] }],
148
148
 
149
149
  // deprecated in favor of no-global-assign
150
150
  // https://eslint.org/docs/rules/no-native-reassign
@@ -356,13 +356,13 @@ module.exports = {
356
356
  // https://eslint.org/docs/rules/no-useless-catch
357
357
  "no-useless-catch": "error",
358
358
 
359
- // disallow useless string concatenation
359
+ // 禁止不必要的文字或模板文字串联
360
360
  // https://eslint.org/docs/rules/no-useless-concat
361
- "no-useless-concat": "error",
361
+ "no-useless-concat": "warn",
362
362
 
363
- // disallow unnecessary string escaping
363
+ // 禁止不必要的转义字符
364
364
  // https://eslint.org/docs/rules/no-useless-escape
365
- "no-useless-escape": "error",
365
+ "no-useless-escape": "warn",
366
366
 
367
367
  // disallow redundant return; keywords
368
368
  // https://eslint.org/docs/rules/no-useless-return
@@ -406,9 +406,9 @@ module.exports = {
406
406
  // https://eslint.org/docs/rules/require-unicode-regexp
407
407
  "require-unicode-regexp": "off",
408
408
 
409
- // requires to declare all vars on top of their containing scope
409
+ // 要求在包裹作用域的最上方使用 var 定义变量
410
410
  // https://eslint.org/docs/rules/vars-on-top
411
- "vars-on-top": "error",
411
+ "vars-on-top": "off",
412
412
 
413
413
  // 要求 IIFE 使用括号括起来
414
414
  // https://eslint.org/docs/rules/wrap-iife.html
@@ -17,9 +17,8 @@ module.exports = {
17
17
  },
18
18
  },
19
19
  rules: {
20
- // enforces no braces where they can be omitted
20
+ // 箭头函数体周围的大括号风格
21
21
  // https://eslint.org/docs/rules/arrow-body-style
22
- // TODO: enable requireReturnForObjectLiteral?
23
22
  "arrow-body-style": ["error", "as-needed", {
24
23
  requireReturnForObjectLiteral: false,
25
24
  }],
@@ -76,7 +75,7 @@ module.exports = {
76
75
  "no-restricted-exports": ["error", {
77
76
  restrictedNamedExports: [
78
77
  "default", // use `export default` to provide a default export
79
- "then" // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
78
+ "then", // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
80
79
  ],
81
80
  }],
82
81
 
@@ -110,9 +109,9 @@ module.exports = {
110
109
  // require let or const instead of var
111
110
  "no-var": "error",
112
111
 
113
- // require method and property shorthand syntax for object literals
112
+ // 要求或禁止对象字面量的方法和属性简写语法
114
113
  // https://eslint.org/docs/rules/object-shorthand
115
- "object-shorthand": ["error", "always", {
114
+ "object-shorthand": ["warn", "always", {
116
115
  ignoreConstructors: false,
117
116
  avoidQuotes: true,
118
117
  }],
@@ -161,9 +160,9 @@ module.exports = {
161
160
  // https://eslint.org/docs/rules/prefer-spread
162
161
  "prefer-spread": "error",
163
162
 
164
- // suggest using template literals instead of string concatenation
163
+ // 要求使用模板文字进行字符串连接
165
164
  // https://eslint.org/docs/rules/prefer-template
166
- "prefer-template": "error",
165
+ "prefer-template": "warn",
167
166
 
168
167
  // disallow generator functions that do not have yield
169
168
  // https://eslint.org/docs/rules/require-yield
@@ -188,10 +187,10 @@ module.exports = {
188
187
 
189
188
  // 要求或禁止模板字符串中的嵌入表达式周围空格的使用
190
189
  // https://eslint.org/docs/rules/template-curly-spacing
191
- "template-curly-spacing": "error",
190
+ "template-curly-spacing": "warn",
192
191
 
193
192
  // 强制在 yield* 表达式中 * 周围使用空格
194
193
  // https://eslint.org/docs/rules/yield-star-spacing
195
- "yield-star-spacing": ["error", "after"],
194
+ "yield-star-spacing": ["warn", "after"],
196
195
  },
197
196
  };
File without changes
@@ -30,10 +30,10 @@ module.exports = {
30
30
  // "no-cond-assign": ["error", "always"],
31
31
 
32
32
  // 禁用 console
33
- "no-console": "error",
33
+ "no-console": "off",
34
34
 
35
- // disallow use of constant expressions in conditions
36
- // "no-constant-condition": "warn",
35
+ // 禁止条件中的常量表达式
36
+ "no-constant-condition": "warn",
37
37
 
38
38
  // disallow control characters in regular expressions
39
39
  // "no-control-regex": "error",
@@ -92,12 +92,17 @@ module.exports = {
92
92
  // disallow invalid regular expression strings in the RegExp constructor
93
93
  // "no-invalid-regexp": "error",
94
94
 
95
- // disallow irregular whitespace outside of strings and comments
96
- // "no-irregular-whitespace": "error",
95
+ // 禁止不规则的空格
96
+ "no-irregular-whitespace": ["error", {
97
+ "skipStrings": true,
98
+ "skipComments": false,
99
+ "skipRegExps": false,
100
+ "skipTemplates": false,
101
+ }],
97
102
 
98
- // Disallow Number Literals That Lose Precision
103
+ // 禁止失去精度的文字数字
99
104
  // https://eslint.org/docs/rules/no-loss-of-precision
100
- // "no-loss-of-precision": "error",
105
+ "no-loss-of-precision": "error",
101
106
 
102
107
  // Disallow characters which are made with multiple code points in character class syntax
103
108
  // https://eslint.org/docs/rules/no-misleading-character-class
@@ -121,12 +126,12 @@ module.exports = {
121
126
  // https://eslint.org/docs/rules/no-setter-return
122
127
  // "no-setter-return": "error",
123
128
 
124
- // disallow sparse arrays
125
- // "no-sparse-arrays": "error",
129
+ // 禁止稀疏数组
130
+ "no-sparse-arrays": "error",
126
131
 
127
- // Disallow template literal placeholder syntax in regular strings
132
+ // 禁止在字符串中使用模板文字占位符语法
128
133
  // https://eslint.org/docs/rules/no-template-curly-in-string
129
- // "no-template-curly-in-string": "error",
134
+ "no-template-curly-in-string": "error",
130
135
 
131
136
  // 禁止出现令人困惑的多行表达式
132
137
  // https://eslint.org/docs/rules/no-unexpected-multiline
@@ -15,7 +15,7 @@ module.exports = {
15
15
  "array-element-newline": ["warn", "consistent"],
16
16
 
17
17
  // 强制数组方括号中使用一致的空格
18
- "array-bracket-spacing": ["error", "never"],
18
+ "array-bracket-spacing": ["warn", "never"],
19
19
 
20
20
  // 禁止或强制在代码块中开括号前和闭括号后有空格
21
21
  // https://eslint.org/docs/rules/block-spacing
@@ -25,8 +25,10 @@ module.exports = {
25
25
  "brace-style": ["warn", "stroustrup", { "allowSingleLine": true }],
26
26
 
27
27
  // 要求使用骆驼拼写法
28
- "camelcase": "off",
29
- // camelcase: ["error", { properties: "never", ignoreDestructuring: false }],
28
+ "camelcase": ["off", {
29
+ properties: "never",
30
+ ignoreDestructuring: false,
31
+ }],
30
32
 
31
33
  // enforce or disallow capitalization of the first letter of a comment
32
34
  // https://eslint.org/docs/rules/capitalized-comments
@@ -43,19 +45,19 @@ module.exports = {
43
45
  },
44
46
  }],
45
47
 
46
- // 要求或禁止使用拖尾逗号(对象、数组、函数参数的最后一项后面是否允许有逗号)
48
+ // 要求或禁止使用拖尾逗号(对象、数组、导入、导出、函数参数的最后一项后面是否允许有逗号)
47
49
  "comma-dangle": ["warn", {
48
- arrays: "never",
50
+ arrays: "always-multiline",
49
51
  objects: "always-multiline",
50
- imports: "never",
51
- exports: "never",
52
+ imports: "always-multiline",
53
+ exports: "always-multiline",
52
54
  functions: "never",
53
55
  }],
54
56
 
55
57
  // 强制在逗号前后使用一致的空格
56
58
  "comma-spacing": ["warn", {
57
- "before": false,
58
- "after": true,
59
+ before: false,
60
+ after: true,
59
61
  }],
60
62
 
61
63
  // 强制使用一致的逗号风格
@@ -100,9 +102,9 @@ module.exports = {
100
102
  considerPropertyDescriptor: true,
101
103
  }],
102
104
 
103
- // require function expressions to have a name
105
+ // 要求函数表达式要有一个函数名称
104
106
  // https://eslint.org/docs/rules/func-names
105
- "func-names": "warn",
107
+ "func-names": "off",
106
108
 
107
109
  // enforces use of function declarations or expressions
108
110
  // https://eslint.org/docs/rules/func-style
@@ -167,7 +169,7 @@ module.exports = {
167
169
  "JSXClosingFragment",
168
170
  "JSXText",
169
171
  "JSXEmptyExpression",
170
- "JSXSpreadChild"
172
+ "JSXSpreadChild",
171
173
  ],
172
174
  ignoreComments: false,
173
175
  }],
@@ -177,14 +179,17 @@ module.exports = {
177
179
  "jsx-quotes": ["warn", "prefer-double"],
178
180
 
179
181
  // 强制在对象字面量的键和值之间使用一致的空格
180
- "key-spacing": ["warn", { beforeColon: false, afterColon: true }],
182
+ "key-spacing": ["warn", {
183
+ beforeColon: false,
184
+ afterColon: true,
185
+ }],
181
186
 
182
187
  // 强制关键字周围空格的一致性
183
188
  "keyword-spacing": ["warn", {
184
189
  "before": true,
185
190
  "after": true,
186
191
  "overrides": {
187
- "if": { "after": false },
192
+ "if": { "after": true },
188
193
  "for": { "after": false },
189
194
  "while": { "after": false },
190
195
  "switch": { "after": false },
@@ -231,7 +236,7 @@ module.exports = {
231
236
  // https://eslint.org/docs/rules/max-len
232
237
  "max-len": ["warn", {
233
238
  "code": 200,
234
- "tabWidth": 4,
239
+ "tabWidth": 2,
235
240
  "comments": 200,
236
241
  "ignoreComments": false,
237
242
  "ignoreTrailingComments": true,
@@ -325,21 +330,21 @@ module.exports = {
325
330
  // 禁止混合使用不同的操作符
326
331
  // https://eslint.org/docs/rules/no-mixed-operators
327
332
  "no-mixed-operators": [
328
- "error",
333
+ "off",
329
334
  {
330
335
  "groups": [
331
336
  ["+", "-", "*", "/", "%", "**"],
332
337
  ["&", "|", "^", "~", "<<", ">>", ">>>"],
333
338
  ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
334
339
  ["&&", "||"],
335
- ["in", "instanceof"]
340
+ ["in", "instanceof"],
336
341
  ],
337
342
  "allowSamePrecedence": true,
338
- }
343
+ },
339
344
  ],
340
345
 
341
346
  // 禁止空格和 tab 的混合缩进
342
- "no-mixed-spaces-and-tabs": "error",
347
+ "no-mixed-spaces-and-tabs": "warn",
343
348
 
344
349
  // 禁止连续赋值
345
350
  // https://eslint.org/docs/rules/no-multi-assign
@@ -372,32 +377,28 @@ module.exports = {
372
377
 
373
378
  // 禁用特定的语法
374
379
  // 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",
380
+ "no-restricted-syntax": [
381
+ "off",
382
+ {
383
+ selector: "ForInStatement",
384
+ 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.",
385
+ },
386
+ {
387
+ selector: "ForOfStatement",
388
+ 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.",
389
+ },
390
+ {
391
+ selector: "LabeledStatement",
392
+ message: "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
393
+ },
394
+ {
395
+ selector: "WithStatement",
396
+ message: "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
397
+ },
398
+ ],
398
399
 
399
400
  // 禁用 tab
400
- "no-tabs": "error",
401
+ "no-tabs": "warn",
401
402
 
402
403
  // disallow the use of ternary operators
403
404
  "no-ternary": "off",
@@ -433,23 +434,23 @@ module.exports = {
433
434
 
434
435
  // 强制在花括号中使用一致的空格
435
436
  "object-curly-spacing": ["warn", "always", {
436
- "arraysInObjects": false,
437
- "objectsInObjects": true,
437
+ arraysInObjects: true,
438
+ objectsInObjects: true,
438
439
  }],
439
440
 
440
441
  // 强制大括号内换行符的一致性
441
442
  // 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 },
443
+ "object-curly-newline": ["warn", {
444
+ ObjectExpression: { minProperties: 40, multiline: true, consistent: true },
445
+ ObjectPattern: "never",
446
+ ImportDeclaration: "never",
447
+ ExportDeclaration: "always",
447
448
  }],
448
449
 
449
450
  // 强制将对象的属性放在不同的行上
450
451
  // https://eslint.org/docs/rules/object-property-newline
451
452
  "object-property-newline": ["off", {
452
- allowAllPropertiesOnSameLine: true,
453
+ allowAllPropertiesOnSameLine: false,
453
454
  }],
454
455
 
455
456
  // 强制函数中的变量要么一起声明要么分开声明
@@ -513,28 +514,28 @@ module.exports = {
513
514
 
514
515
  // 要求或禁止语句块之前的空格(代码块大括号前面是否需要空格)
515
516
  "space-before-blocks": ["warn", {
516
- "functions": "always",
517
- "keywords": "always",
518
- "classes": "always",
517
+ functions: "always",
518
+ keywords: "always",
519
+ classes: "always",
519
520
  }],
520
521
 
521
522
  // 强制在 function 的左括号之前使用一致的空格
522
523
  // https://eslint.org/docs/rules/space-before-function-paren
523
- "space-before-function-paren": ["error", {
524
- anonymous: "always",
524
+ "space-before-function-paren": ["warn", {
525
+ anonymous: "never",
525
526
  named: "never",
526
527
  asyncArrow: "always",
527
528
  }],
528
529
 
529
530
  // 强制在圆括号内使用一致的空格
530
- "space-in-parens": ["error", "never"],
531
+ "space-in-parens": ["warn", "never"],
531
532
 
532
533
  // 要求中缀操作符周围有空格(+-*/?| etc.)
533
- "space-infix-ops": "error",
534
+ "space-infix-ops": "warn",
534
535
 
535
536
  // 强制在一元操作符前后使用一致的空格
536
537
  // https://eslint.org/docs/rules/space-unary-ops
537
- "space-unary-ops": ["error", {
538
+ "space-unary-ops": ["warn", {
538
539
  words: true,
539
540
  nonwords: false,
540
541
  }],
@@ -4,7 +4,7 @@
4
4
  // 这些规则与变量声明有关
5
5
  // ==========================================================
6
6
 
7
- const confusingBrowserGlobals = require("confusing-browser-globals");
7
+ // const confusingBrowserGlobals = require("confusing-browser-globals");
8
8
 
9
9
  module.exports = {
10
10
  rules: {
@@ -55,17 +55,19 @@ module.exports = {
55
55
  // TODO: enable?
56
56
  "no-undefined": "off",
57
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 }],
58
+ // 禁止定义变量后不使用
59
+ "no-unused-vars": ["error", {
60
+ vars: "all",
61
+ args: "none",
62
+ ignoreRestSiblings: true,
63
+ caughtErrors: "none",
64
+ }],
60
65
 
61
66
  // 禁止定义前使用
62
- "no-use-before-define": [
63
- "error",
64
- {
65
- "functions": false,
66
- "classes": true,
67
- "variables": true,
68
- }
69
- ],
67
+ "no-use-before-define": ["error", {
68
+ functions: false,
69
+ classes: true,
70
+ variables: true,
71
+ }],
70
72
  },
71
73
  };