@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.
- package/LICENSE +21 -21
- package/README.md +155 -28
- package/lib/format-es5.js +23 -0
- package/lib/format-es6.js +25 -0
- package/lib/format-html.js +23 -0
- package/lib/format-import.js +23 -0
- package/lib/format-typescript.js +28 -0
- package/lib/format-vue2.js +23 -0
- package/lib/format-vue3.js +23 -0
- package/lib/html.js +13 -22
- package/lib/import.js +23 -0
- package/lib/javascript-es5.js +23 -0
- package/lib/javascript-es6.js +25 -0
- package/lib/rules/eslint/_deprecated.js +132 -0
- package/lib/rules/eslint/_removed.js +25 -0
- package/lib/rules/eslint/es6.js +279 -110
- package/lib/rules/eslint/layout-formatting.js +441 -0
- package/lib/rules/eslint/possible-errors.js +140 -131
- package/lib/rules/eslint/suggestions.js +666 -0
- package/lib/rules/html/accessibility.js +47 -23
- package/lib/rules/html/best-practice.js +122 -36
- package/lib/rules/html/seo.js +16 -11
- package/lib/rules/html/style.js +53 -15
- package/lib/rules/import/helpful-warnings.js +23 -18
- package/lib/rules/import/module-systems.js +16 -17
- package/lib/rules/import/static-analysis.js +54 -38
- package/lib/rules/import/style-guide.js +89 -61
- package/lib/rules/typescript/_deprecated.js +57 -0
- package/lib/rules/typescript/conflict.js +16 -0
- package/lib/rules/typescript/deprecated.js +41 -0
- package/lib/rules/typescript/extension.js +207 -0
- package/lib/rules/typescript/fixable.js +215 -0
- package/lib/rules/typescript/other.js +125 -0
- package/lib/rules/typescript/stylistic.js +34 -0
- package/lib/rules/typescript/suggestion.js +53 -0
- package/lib/rules/typescript/type-checked.js +263 -0
- package/lib/rules/vue/_deprecated.js +37 -0
- package/lib/rules/vue/common-base.js +1 -11
- package/lib/rules/vue/common-essential.js +25 -38
- package/lib/rules/vue/common-extension.js +321 -0
- package/lib/rules/vue/common-recommended.js +64 -31
- package/lib/rules/vue/common-strongly-recommended.js +37 -20
- package/lib/rules/vue/{common-extra.js → common-uncategorized.js} +141 -52
- package/lib/rules/vue/vue2-essential.js +16 -14
- package/lib/rules/vue/vue2-uncategorized.js +15 -0
- package/lib/rules/vue/vue3-essential.js +54 -24
- package/lib/rules/vue/vue3-strongly-recommended.js +8 -10
- package/lib/rules/vue/vue3-uncategorized.js +115 -0
- package/lib/support/es5-support.js +29 -0
- package/lib/support/es6-support.js +39 -0
- package/lib/support/html-support.js +38 -0
- package/lib/support/import-bugfix.js +65 -0
- package/lib/support/import-support.js +25 -0
- package/lib/support/typescript-support.js +27 -0
- package/lib/support/vue2-support.js +43 -0
- package/lib/support/vue3-support.js +43 -0
- package/lib/support/vue3-ts-support.js +51 -0
- package/lib/typescript.js +37 -0
- package/lib/utils/utils.js +160 -0
- package/lib/vue2.js +16 -22
- package/lib/vue3-ts.js +31 -0
- package/lib/vue3.js +13 -17
- package/package.json +39 -20
- package/lib/configs/eslint-es5.js +0 -24
- package/lib/configs/eslint.js +0 -23
- package/lib/configs/format-html.js +0 -22
- package/lib/configs/format-js.js +0 -134
- package/lib/configs/format-vue.js +0 -278
- package/lib/configs/html.js +0 -20
- package/lib/configs/import-bugfix.js +0 -36
- package/lib/configs/import.js +0 -44
- package/lib/configs/vue2.js +0 -28
- package/lib/configs/vue3.js +0 -28
- package/lib/eslint.js +0 -18
- package/lib/format.js +0 -40
- package/lib/rules/eslint/best-practices.js +0 -422
- package/lib/rules/eslint/node.js +0 -48
- package/lib/rules/eslint/strict-mode.js +0 -12
- package/lib/rules/eslint/stylistic-issues.js +0 -577
- package/lib/rules/eslint/variables.js +0 -73
- package/lib/rules/vue/common-eslint.js +0 -220
- package/lib/rules/vue/vue2-recommended.js +0 -17
- package/lib/rules/vue/vue2-strongly-recommended.js +0 -16
- package/lib/rules/vue/vue3-recommended.js +0 -17
|
@@ -6,185 +6,194 @@
|
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
8
|
rules: {
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
// "for-direction": "error",
|
|
9
|
+
// 防止死循环,执行“for”循环更新子句,使计数器朝着正确的方向移动
|
|
10
|
+
"for-direction": "error",
|
|
12
11
|
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
|
|
12
|
+
// 禁止与-0进行比较
|
|
13
|
+
// 这条规则应该对试图与 -0 比较的代码提出警告,因为这不会像预期的那样工作。也就是说,像 x === -0 这样的代码对于 +0 和 -0 都会通过。作者可能想要的是 Object.is(x, -0)。
|
|
14
|
+
"no-compare-neg-zero": "error",
|
|
16
15
|
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
16
|
+
// 禁止在条件表达式中使用赋值运算符
|
|
17
|
+
// 在条件语句中,很容易把比较运算符(如 ==)误打成赋值运算符(如 =)
|
|
18
|
+
// 使用此规则禁用 if、for、while 和 do...while 测试条件中的模糊赋值运算符
|
|
19
|
+
"no-cond-assign": ["error", "always"],
|
|
20
20
|
|
|
21
|
-
// Disallow
|
|
22
|
-
// https://eslint.org/docs/rules/no-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// Disallow comparisons to negative zero
|
|
26
|
-
// https://eslint.org/docs/rules/no-compare-neg-zero
|
|
27
|
-
// "no-compare-neg-zero": "error",
|
|
28
|
-
|
|
29
|
-
// disallow assignment in conditional expressions
|
|
30
|
-
// "no-cond-assign": ["error", "always"],
|
|
31
|
-
|
|
32
|
-
// 禁用 console
|
|
33
|
-
"no-console": "off",
|
|
21
|
+
// Disallow expressions where the operation doesn't affect the value
|
|
22
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-constant-binary-expression
|
|
23
|
+
"no-constant-binary-expression": "error",
|
|
34
24
|
|
|
35
25
|
// 禁止条件中的常量表达式
|
|
36
|
-
|
|
26
|
+
// 这条规则不允许在以下测试条件中使用常量表达式:
|
|
27
|
+
// - if、for、while 或 do...while 语句
|
|
28
|
+
// - ?: 三元表达式
|
|
29
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-constant-condition
|
|
30
|
+
"no-constant-condition": ["error", {
|
|
31
|
+
// 默认为 true。将此选项设置为 false 允许在循环中使用常量表达式。
|
|
32
|
+
checkLoops: true,
|
|
33
|
+
}],
|
|
37
34
|
|
|
38
|
-
//
|
|
39
|
-
//
|
|
35
|
+
// 禁止在正则表达式中使用控制字符
|
|
36
|
+
// 控制字符是 ASCII 范围内 0-31 的特殊、不可见的字符。这些字符在 JavaScript 字符串中很少使用,所以一个包含明确匹配这些字符的元素的正则表达式很可能是一个错误。
|
|
37
|
+
// 这条规则不允许使用控制字符和一些转义序列与正则表达式中的控制字符匹配。
|
|
38
|
+
"no-control-regex": "error",
|
|
40
39
|
|
|
41
40
|
// 禁用 debugger
|
|
42
41
|
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
|
|
43
42
|
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
// Disallow duplicate conditions in if-else-if chains
|
|
48
|
-
// https://eslint.org/docs/rules/no-dupe-else-if
|
|
49
|
-
// "no-dupe-else-if": "error",
|
|
43
|
+
// 禁止函数参数名称重复
|
|
44
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-dupe-args
|
|
45
|
+
"no-dupe-args": "error",
|
|
50
46
|
|
|
51
|
-
//
|
|
52
|
-
//
|
|
47
|
+
// 禁止在 if-else-if 中存在重复条件
|
|
48
|
+
// 这条规则不允许在同一个 if-else-if 链中出现重复的条件。
|
|
49
|
+
"no-dupe-else-if": "error",
|
|
53
50
|
|
|
54
|
-
//
|
|
55
|
-
|
|
51
|
+
// 禁止对象字面中的键名重复
|
|
52
|
+
"no-dupe-keys": "error",
|
|
56
53
|
|
|
57
|
-
//
|
|
58
|
-
|
|
54
|
+
// 禁止在 switch 的 case 子句中重复测试表达式
|
|
55
|
+
"no-duplicate-case": "error",
|
|
59
56
|
|
|
60
|
-
//
|
|
61
|
-
//
|
|
57
|
+
// 禁止在正则表达式中使用空字符类
|
|
58
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-empty-character-class
|
|
59
|
+
"no-empty-character-class": "error",
|
|
62
60
|
|
|
63
61
|
// disallow assigning to the exception in a catch block
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
conditionalAssign: true,
|
|
74
|
-
nestedBinaryExpressions: false,
|
|
75
|
-
returnAssign: false,
|
|
76
|
-
ignoreJSX: "all", // delegate to eslint-plugin-react
|
|
77
|
-
enforceForArrowConditionals: false,
|
|
62
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-ex-assign
|
|
63
|
+
"no-ex-assign": "error",
|
|
64
|
+
|
|
65
|
+
// 禁止条件语句中的“穿透”行为
|
|
66
|
+
// case 语句中需要有 break,防止穿透到下一个 case 语句
|
|
67
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-fallthrough
|
|
68
|
+
"no-fallthrough": ["error", {
|
|
69
|
+
commentPattern: "",
|
|
70
|
+
allowEmptyCase: true,
|
|
78
71
|
}],
|
|
79
72
|
|
|
80
|
-
//
|
|
81
|
-
|
|
73
|
+
// 禁止对函数赋值
|
|
74
|
+
// 这条规则不允许重新分配 function 的声明
|
|
75
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-func-assign
|
|
76
|
+
"no-func-assign": "error",
|
|
82
77
|
|
|
83
|
-
//
|
|
84
|
-
//
|
|
78
|
+
// 禁止在嵌套块中声明变量或函数
|
|
79
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-inner-declarations
|
|
80
|
+
"no-inner-declarations": ["error", "functions"],
|
|
85
81
|
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// disallow function or variable declarations in nested blocks
|
|
90
|
-
// "no-inner-declarations": "error",
|
|
91
|
-
|
|
92
|
-
// disallow invalid regular expression strings in the RegExp constructor
|
|
93
|
-
// "no-invalid-regexp": "error",
|
|
82
|
+
// 禁止在 RegExp 构造函数中使用无效的正则表达式字符串
|
|
83
|
+
"no-invalid-regexp": "error",
|
|
94
84
|
|
|
95
85
|
// 禁止不规则的空格
|
|
86
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-irregular-whitespace
|
|
96
87
|
"no-irregular-whitespace": ["error", {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
88
|
+
skipStrings: false,
|
|
89
|
+
skipComments: false,
|
|
90
|
+
skipRegExps: false,
|
|
91
|
+
skipTemplates: false,
|
|
101
92
|
}],
|
|
102
93
|
|
|
103
94
|
// 禁止失去精度的文字数字
|
|
104
|
-
// https://eslint.org/docs/rules/no-loss-of-precision
|
|
95
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-loss-of-precision
|
|
105
96
|
"no-loss-of-precision": "error",
|
|
106
97
|
|
|
107
98
|
// Disallow characters which are made with multiple code points in character class syntax
|
|
108
|
-
// https://eslint.org/docs/rules/no-misleading-character-class
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// disallow the use of object properties of the global object (Math and JSON) as functions
|
|
112
|
-
// "no-obj-calls": "error",
|
|
99
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-misleading-character-class
|
|
100
|
+
"no-misleading-character-class": "error",
|
|
113
101
|
|
|
114
|
-
//
|
|
115
|
-
// https://eslint.org/docs/rules/no-
|
|
116
|
-
|
|
102
|
+
// 这条规则不允许将 Math、JSON、Reflect、Atomics 和 Intl 对象作为函数调用
|
|
103
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-obj-calls
|
|
104
|
+
"no-obj-calls": "error",
|
|
117
105
|
|
|
118
|
-
//
|
|
119
|
-
// https://eslint.org/docs/rules/no-prototype-builtins
|
|
120
|
-
|
|
106
|
+
// 不允许直接在对象上调用某些 Object.prototype 方法
|
|
107
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-prototype-builtins
|
|
108
|
+
"no-prototype-builtins": "error",
|
|
121
109
|
|
|
122
|
-
//
|
|
123
|
-
//
|
|
110
|
+
// 禁止将变量赋值给它自己
|
|
111
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-self-assign
|
|
112
|
+
"no-self-assign": ["error", {
|
|
113
|
+
props: true,
|
|
114
|
+
}],
|
|
124
115
|
|
|
125
|
-
//
|
|
126
|
-
// https://eslint.org/docs/rules/no-
|
|
127
|
-
|
|
116
|
+
// 禁止将变量与自身进行比较
|
|
117
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-self-compare
|
|
118
|
+
"no-self-compare": "error",
|
|
128
119
|
|
|
129
|
-
//
|
|
120
|
+
// 禁止使用稀疏数组
|
|
121
|
+
// 稀疏数组包含空槽,最常见的原因是在数组字面中使用了多个逗号(比如:[,,])
|
|
122
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-sparse-arrays
|
|
130
123
|
"no-sparse-arrays": "error",
|
|
131
124
|
|
|
132
|
-
//
|
|
133
|
-
|
|
134
|
-
|
|
125
|
+
// 禁止未定义的变量
|
|
126
|
+
"no-undef": ["error", {
|
|
127
|
+
typeof: true,
|
|
128
|
+
}],
|
|
135
129
|
|
|
136
130
|
// 禁止出现令人困惑的多行表达式
|
|
137
|
-
//
|
|
131
|
+
// 这条规则不允许出现混乱的多行表达式,即换行看起来像是在结束一个语句,但实际上不是。
|
|
132
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-unexpected-multiline
|
|
138
133
|
"no-unexpected-multiline": "error",
|
|
139
134
|
|
|
140
|
-
//
|
|
141
|
-
//
|
|
135
|
+
// 不允许未修改的循环条件
|
|
136
|
+
// 经常会循环中修改循环条件中的变量。 如果没有,那可能是个错误。
|
|
137
|
+
// 这条规则会找到位于循环条件内的引用,然后检查是否有在循环中修改这些引用的变量。
|
|
138
|
+
"no-unmodified-loop-condition": "error",
|
|
142
139
|
|
|
143
|
-
//
|
|
144
|
-
// https://eslint.org/docs/rules/no-unreachable
|
|
145
|
-
|
|
146
|
-
// ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
|
|
147
|
-
// }],
|
|
140
|
+
// 不允许在 return、throw、continue、break 语句后出现无法访问的代码
|
|
141
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-unreachable
|
|
142
|
+
"no-unreachable": "error",
|
|
148
143
|
|
|
149
|
-
//
|
|
150
|
-
// https://eslint.org/docs/rules/no-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// https://eslint.org/docs/rules/no-unsafe-negation
|
|
155
|
-
// "no-unsafe-negation": "error",
|
|
156
|
-
|
|
157
|
-
// disallow use of optional chaining in contexts where the undefined value is not allowed
|
|
158
|
-
// https://eslint.org/docs/rules/no-unsafe-optional-chaining
|
|
159
|
-
// "no-unsafe-optional-chaining": ["error", { disallowArithmeticOperators: true }],
|
|
144
|
+
// 禁止只允许一次迭代的循环体
|
|
145
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-unreachable-loop
|
|
146
|
+
"no-unreachable-loop": ["error", {
|
|
147
|
+
ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
|
|
148
|
+
}],
|
|
160
149
|
|
|
161
|
-
//
|
|
162
|
-
// https://eslint.org/docs/rules/no-
|
|
163
|
-
|
|
164
|
-
// "no-unused-private-class-members": "off",
|
|
150
|
+
// 禁止在finally块中使用控制流语句
|
|
151
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-unsafe-finally
|
|
152
|
+
"no-unsafe-finally": "error",
|
|
165
153
|
|
|
166
|
-
//
|
|
167
|
-
// https://eslint.org/docs/rules/no-
|
|
168
|
-
|
|
154
|
+
// 禁止对关系操作符的左操作数取反
|
|
155
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-unsafe-negation
|
|
156
|
+
"no-unsafe-negation": ["error", {
|
|
157
|
+
enforceForOrderingRelations: false,
|
|
158
|
+
}],
|
|
169
159
|
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
|
|
160
|
+
// 禁止定义变量后不使用
|
|
161
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-unused-vars
|
|
162
|
+
"no-unused-vars": ["error", {
|
|
163
|
+
vars: "all",
|
|
164
|
+
varsIgnorePattern: "",
|
|
165
|
+
args: "after-used", // 参数相关
|
|
166
|
+
argsIgnorePattern: "^_|^(evt|err)\\d*$|^(resolve|reject)$", // 指定了不检查使用情况的例外情况:参数的名称与 regexp 模式相匹配。例如,名称以下划线开头的变量。
|
|
167
|
+
caughtErrors: "none",
|
|
168
|
+
caughtErrorsIgnorePattern: "^_|^(e|err|error)\\d*$", // try-catch 代码块
|
|
169
|
+
destructuredArrayIgnorePattern: "", // 数组解构相关
|
|
170
|
+
ignoreRestSiblings: true,
|
|
171
|
+
}],
|
|
173
172
|
|
|
174
|
-
//
|
|
175
|
-
// https://eslint.org/docs/rules/
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
// 禁止定义前使用
|
|
174
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-use-before-define
|
|
175
|
+
"no-use-before-define": ["error", {
|
|
176
|
+
functions: false,
|
|
177
|
+
classes: true,
|
|
178
|
+
variables: true,
|
|
179
|
+
allowNamedExports: false,
|
|
180
|
+
}],
|
|
178
181
|
|
|
179
|
-
//
|
|
180
|
-
//
|
|
182
|
+
// Disallow useless backreferences in regular expressions
|
|
183
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-useless-backreference
|
|
184
|
+
"no-useless-backreference": "error",
|
|
181
185
|
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
|
|
186
|
+
// 要求使用 isNaN() 检测 NaN
|
|
187
|
+
"use-isnan": ["error", {
|
|
188
|
+
enforceForSwitchCase: true, // 不允许在 switch 语句中使用 case NaN 和 switch(NaN)
|
|
189
|
+
enforceForIndexOf: true, // 不允许使用 indexOf(NaN) 或 lastIndexOf(NaN)
|
|
190
|
+
}],
|
|
185
191
|
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
//
|
|
192
|
+
// 这条规则强制将 typeof 表达式与有效的字符串字面量进行比较。
|
|
193
|
+
// 有效的字符串字面量:"undefined", "object", "boolean", "number", "string", "function", "symbol", and "bigint"
|
|
194
|
+
// https://zh-hans.eslint.org/docs/latest/rules/valid-typeof
|
|
195
|
+
"valid-typeof": ["error", {
|
|
196
|
+
requireStringLiterals: true,
|
|
197
|
+
}],
|
|
189
198
|
},
|
|
190
199
|
};
|