@houheaven/eslint-config-helper 1.1.0 → 1.2.1
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/README.md +69 -11
- package/format.js +40 -0
- package/html.js +32 -0
- package/index.js +18 -0
- package/lib/configs/eslint-es5.js +24 -0
- package/lib/configs/eslint.js +10 -11
- package/lib/configs/format-html.js +22 -0
- package/lib/configs/format-js.js +134 -0
- package/lib/configs/{prettier.js → format-prettier.js} +19 -18
- package/lib/configs/{vue-format.js → format-vue.js} +184 -221
- package/lib/configs/html.js +20 -0
- package/lib/configs/import-bugfix.js +36 -0
- package/lib/configs/import.js +44 -0
- package/lib/configs/vue2.js +7 -0
- package/lib/configs/vue3.js +7 -0
- package/lib/rules/eslint/best-practices.js +10 -10
- package/lib/rules/eslint/es6.js +1 -2
- package/lib/rules/eslint/possible-errors.js +8 -3
- package/lib/rules/eslint/stylistic-issues.js +18 -20
- package/lib/rules/eslint/variables.js +12 -10
- package/lib/rules/html/accessibility.js +44 -0
- package/lib/rules/html/best-practice.js +64 -0
- package/lib/rules/html/seo.js +24 -0
- package/lib/rules/html/style.js +32 -0
- package/lib/rules/import/helpful-warnings.js +68 -0
- package/lib/rules/import/module-systems.js +34 -0
- package/lib/rules/import/static-analysis.js +69 -0
- package/lib/rules/import/style-guide.js +97 -0
- package/lib/rules/vue/common-eslint.js +17 -6
- package/lib/rules/vue/common-extra.js +5 -4
- package/lib/rules/vue/common-recommended.js +1 -1
- package/lib/rules/vue/common-strongly-recommended.js +2 -2
- package/lib/rules/vuejs-accessibility/index.js +92 -0
- package/package.json +13 -5
- package/vue2.js +30 -0
- package/vue3.js +28 -0
- package/lib/configs/file-bof-eof.js +0 -20
- package/lib/configs/legacy.js +0 -34
- package/lib/configs/vuejs-accessibility.js +0 -20
- package/lib/eslint-fix.js +0 -29
- package/lib/index.js +0 -14
- package/lib/rules/imports.js +0 -279
|
@@ -1,89 +1,68 @@
|
|
|
1
1
|
|
|
2
2
|
// ==========================================================
|
|
3
|
-
//
|
|
3
|
+
// Vue 文件代码格式化
|
|
4
4
|
// ==========================================================
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
+
extends: [
|
|
8
|
+
"../rules/vue/common-base",
|
|
9
|
+
],
|
|
7
10
|
rules: {
|
|
8
|
-
//
|
|
9
|
-
"vue/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
ExportDeclaration: "never",
|
|
11
|
+
// template、script、style 多行显示
|
|
12
|
+
"vue/block-tag-newline": ["warn", {
|
|
13
|
+
"singleline": "always",
|
|
14
|
+
"multiline": "always",
|
|
15
|
+
"maxEmptyLines": 0,
|
|
14
16
|
}],
|
|
15
17
|
|
|
16
|
-
//
|
|
17
|
-
"vue/
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
// 在 <template> 中,强制统一缩进
|
|
19
|
+
"vue/html-indent": ["warn", 2, {
|
|
20
|
+
"attribute": 1,
|
|
21
|
+
"baseIndent": 1,
|
|
22
|
+
"closeBracket": 0,
|
|
23
|
+
"alignAttributesVertically": true,
|
|
24
|
+
"ignores": [],
|
|
20
25
|
}],
|
|
21
26
|
|
|
22
|
-
//
|
|
23
|
-
"vue/
|
|
24
|
-
|
|
27
|
+
// 在 <script> 中,强制统一缩进
|
|
28
|
+
"vue/script-indent": ["warn", 2, {
|
|
29
|
+
"baseIndent": 1,
|
|
30
|
+
"switchCase": 1,
|
|
31
|
+
"ignores": [],
|
|
25
32
|
}],
|
|
33
|
+
|
|
34
|
+
// 在 html 属性中,强制统一引号
|
|
35
|
+
"vue/html-quotes": ["warn", "double", { "avoidEscape": true }],
|
|
26
36
|
|
|
27
|
-
//
|
|
28
|
-
"vue/
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"for": { "after": false },
|
|
34
|
-
"while": { "after": false },
|
|
35
|
-
"switch": { "after": false },
|
|
36
|
-
"case": { "after": true },
|
|
37
|
-
"catch": { "after": false },
|
|
38
|
-
"return": { "after": true },
|
|
39
|
-
"throw": { "after": true },
|
|
37
|
+
// 强制标签自闭合
|
|
38
|
+
"vue/html-self-closing": ["warn", {
|
|
39
|
+
"html": {
|
|
40
|
+
"void": "always",
|
|
41
|
+
"normal": "never",
|
|
42
|
+
"component": "always",
|
|
40
43
|
},
|
|
44
|
+
"svg": "always",
|
|
45
|
+
"math": "always",
|
|
41
46
|
}],
|
|
42
47
|
|
|
43
|
-
//
|
|
44
|
-
"vue/
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"ignoreComments": false,
|
|
49
|
-
"ignoreTrailingComments": true,
|
|
50
|
-
"ignoreUrls": true,
|
|
51
|
-
"ignoreStrings": true,
|
|
52
|
-
"ignoreTemplateLiterals": true,
|
|
53
|
-
"ignoreRegExpLiterals": true,
|
|
54
|
-
}],
|
|
55
|
-
|
|
56
|
-
// 强制在对象字面量的键和值之间使用一致的空格
|
|
57
|
-
"vue/key-spacing": ["warn", {
|
|
58
|
-
beforeColon: false,
|
|
59
|
-
afterColon: true,
|
|
48
|
+
// 规定标签的右尖括号(>)是否有空格
|
|
49
|
+
"vue/html-closing-bracket-spacing": ["warn", {
|
|
50
|
+
"startTag": "never",
|
|
51
|
+
"endTag": "never",
|
|
52
|
+
"selfClosingTag": "always",
|
|
60
53
|
}],
|
|
61
|
-
|
|
62
|
-
// 在数组开括号后和闭括号前强制换行
|
|
63
|
-
"vue/array-bracket-newline": ["warn", "consistent"],
|
|
64
|
-
|
|
65
|
-
// 强制数组方括号中使用一致的空格
|
|
66
|
-
"vue/array-bracket-spacing": ["warn", "never"],
|
|
67
|
-
|
|
54
|
+
|
|
68
55
|
// 要求箭头函数的箭头之前或之后有空格
|
|
69
56
|
"vue/arrow-spacing": ["warn", {
|
|
70
57
|
before: true,
|
|
71
58
|
after: true,
|
|
72
59
|
}],
|
|
73
60
|
|
|
74
|
-
//
|
|
75
|
-
"vue/
|
|
76
|
-
|
|
77
|
-
// template、script、style 多行显示
|
|
78
|
-
"vue/block-tag-newline": ["warn", {
|
|
79
|
-
"singleline": "always",
|
|
80
|
-
"multiline": "always",
|
|
81
|
-
"maxEmptyLines": 0,
|
|
61
|
+
// 标签内不能出现多个空格
|
|
62
|
+
"vue/no-multi-spaces": ["warn", {
|
|
63
|
+
"ignoreProperties": false,
|
|
82
64
|
}],
|
|
83
65
|
|
|
84
|
-
// 强制在代码块中使用一致的大括号风格
|
|
85
|
-
"vue/brace-style": ["warn", "stroustrup", { "allowSingleLine": true }],
|
|
86
|
-
|
|
87
66
|
// 要求或禁止使用拖尾逗号(对象、数组、导入、导出、函数参数的最后一项后面是否允许有逗号)
|
|
88
67
|
"vue/comma-dangle": ["warn", {
|
|
89
68
|
arrays: "always-multiline",
|
|
@@ -99,165 +78,157 @@ module.exports = {
|
|
|
99
78
|
"after": true,
|
|
100
79
|
}],
|
|
101
80
|
|
|
102
|
-
//
|
|
103
|
-
"vue/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
ArrayPattern: false,
|
|
107
|
-
ArrowFunctionExpression: false,
|
|
108
|
-
CallExpression: false,
|
|
109
|
-
FunctionDeclaration: false,
|
|
110
|
-
FunctionExpression: false,
|
|
111
|
-
ImportDeclaration: false,
|
|
112
|
-
ObjectExpression: false,
|
|
113
|
-
ObjectPattern: false,
|
|
114
|
-
VariableDeclaration: false,
|
|
115
|
-
NewExpression: false,
|
|
116
|
-
},
|
|
81
|
+
// 强制在对象字面量的键和值之间使用一致的空格
|
|
82
|
+
"vue/key-spacing": ["warn", {
|
|
83
|
+
beforeColon: false,
|
|
84
|
+
afterColon: true,
|
|
117
85
|
}],
|
|
118
86
|
|
|
119
|
-
//
|
|
120
|
-
"vue/
|
|
87
|
+
// 在 html 注释中,强制统一缩进
|
|
88
|
+
"vue/html-comment-indent": ["warn", 2],
|
|
121
89
|
|
|
122
|
-
//
|
|
123
|
-
"vue/
|
|
124
|
-
"singleline": "ignore",
|
|
125
|
-
"multiline": "below",
|
|
126
|
-
}],
|
|
90
|
+
// 在 mustache 胡须插值中强制统一间距
|
|
91
|
+
"vue/mustache-interpolation-spacing": ["warn", "always"],
|
|
127
92
|
|
|
128
|
-
//
|
|
129
|
-
"vue/
|
|
130
|
-
"singleline": { "max": 4 },
|
|
131
|
-
"multiline": { "max": 1 },
|
|
132
|
-
}],
|
|
93
|
+
// 要求使用 === 和 !==
|
|
94
|
+
// "vue/eqeqeq": ["error", "always", { null: "ignore" }],
|
|
133
95
|
|
|
134
|
-
//
|
|
135
|
-
"vue/
|
|
96
|
+
// 要求使用模板文字进行字符串连接
|
|
97
|
+
"vue/prefer-template": "warn",
|
|
136
98
|
|
|
137
|
-
//
|
|
138
|
-
"vue/
|
|
139
|
-
"
|
|
140
|
-
|
|
99
|
+
// 强制关键字周围空格的一致性
|
|
100
|
+
"vue/keyword-spacing": ["warn", {
|
|
101
|
+
"before": true,
|
|
102
|
+
"after": true,
|
|
103
|
+
"overrides": {
|
|
104
|
+
"if": { "after": true },
|
|
105
|
+
"for": { "after": false },
|
|
106
|
+
"while": { "after": false },
|
|
107
|
+
"switch": { "after": false },
|
|
108
|
+
"case": { "after": true },
|
|
109
|
+
"catch": { "after": false },
|
|
110
|
+
"return": { "after": true },
|
|
111
|
+
"throw": { "after": true },
|
|
112
|
+
},
|
|
141
113
|
}],
|
|
142
114
|
|
|
143
|
-
//
|
|
144
|
-
"vue/
|
|
145
|
-
|
|
115
|
+
// 强制在花括号中使用一致的空格
|
|
116
|
+
"vue/object-curly-spacing": ["warn", "always", {
|
|
117
|
+
arraysInObjects: true,
|
|
118
|
+
objectsInObjects: true,
|
|
146
119
|
}],
|
|
147
120
|
|
|
148
|
-
//
|
|
149
|
-
"vue/
|
|
150
|
-
"
|
|
151
|
-
"
|
|
152
|
-
"
|
|
121
|
+
// 强制大括号内换行符的一致性
|
|
122
|
+
"vue/object-curly-newline": ["warn", {
|
|
123
|
+
ObjectExpression: "never",
|
|
124
|
+
ObjectPattern: "never",
|
|
125
|
+
ImportDeclaration: "never",
|
|
126
|
+
ExportDeclaration: "never",
|
|
153
127
|
}],
|
|
154
128
|
|
|
155
|
-
//
|
|
156
|
-
"vue/
|
|
157
|
-
"singleline": "never",
|
|
158
|
-
"multiline": "always",
|
|
159
|
-
}],
|
|
129
|
+
// 强制数组方括号中使用一致的空格
|
|
130
|
+
"vue/array-bracket-spacing": ["warn", "never"],
|
|
160
131
|
|
|
161
|
-
//
|
|
162
|
-
"vue/
|
|
163
|
-
"
|
|
164
|
-
"
|
|
165
|
-
"selfClosingTag": "always",
|
|
132
|
+
// 为模板中的组件命名样式强制执行特定的大小写
|
|
133
|
+
"vue/component-name-in-template-casing": ["warn", "kebab-case", {
|
|
134
|
+
"registeredComponentsOnly": false,
|
|
135
|
+
// "ignores": ["/^hh-/"],
|
|
166
136
|
}],
|
|
167
|
-
|
|
168
|
-
// 在 html 注释中,强制统一换行
|
|
169
|
-
"vue/html-comment-content-newline": [
|
|
170
|
-
"warn",
|
|
171
|
-
{
|
|
172
|
-
"singleline": "never",
|
|
173
|
-
"multiline": "always",
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
"exceptions": [],
|
|
177
|
-
},
|
|
178
|
-
],
|
|
179
137
|
|
|
180
|
-
//
|
|
181
|
-
"vue/html-comment-content-spacing": ["warn", "always", {
|
|
182
|
-
"exceptions": [],
|
|
183
|
-
}],
|
|
138
|
+
// =================================================================================
|
|
184
139
|
|
|
185
|
-
//
|
|
186
|
-
"vue/
|
|
140
|
+
// // 在数组开括号后和闭括号前强制换行
|
|
141
|
+
// "vue/array-bracket-newline": ["warn", "consistent"],
|
|
187
142
|
|
|
188
|
-
//
|
|
189
|
-
"vue/
|
|
190
|
-
"minLineOfMultilineProperty": 2,
|
|
191
|
-
}],
|
|
143
|
+
// // 禁止或强制在代码块中开括号前和闭括号后有空格
|
|
144
|
+
// "vue/block-spacing": ["warn", "always"],
|
|
192
145
|
|
|
193
|
-
//
|
|
194
|
-
"vue/
|
|
146
|
+
// 强制在代码块中使用一致的大括号风格
|
|
147
|
+
"vue/brace-style": ["warn", "stroustrup", { "allowSingleLine": true }],
|
|
195
148
|
|
|
196
|
-
//
|
|
197
|
-
"vue/
|
|
198
|
-
"allowBinding": false,
|
|
199
|
-
}],
|
|
149
|
+
// // 强制在点号之前和之后一致的换行
|
|
150
|
+
// "vue/dot-location": ["warn", "property"],
|
|
200
151
|
|
|
201
|
-
//
|
|
202
|
-
"vue/
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}],
|
|
152
|
+
// // 强制第一个属性的显示位置
|
|
153
|
+
// "vue/first-attribute-linebreak": ["warn", {
|
|
154
|
+
// "singleline": "ignore",
|
|
155
|
+
// "multiline": "below",
|
|
156
|
+
// }],
|
|
206
157
|
|
|
207
|
-
//
|
|
208
|
-
"vue/
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}],
|
|
158
|
+
// // 强制每行属性的数量
|
|
159
|
+
// "vue/max-attributes-per-line": ["warn", {
|
|
160
|
+
// "singleline": { "max": 4 },
|
|
161
|
+
// "multiline": { "max": 1 },
|
|
162
|
+
// }],
|
|
212
163
|
|
|
213
|
-
//
|
|
214
|
-
"vue/
|
|
164
|
+
// 属性名称使用连字符("-")进行连接
|
|
165
|
+
"vue/attribute-hyphenation": "warn",
|
|
215
166
|
|
|
216
|
-
//
|
|
217
|
-
"vue/
|
|
218
|
-
|
|
219
|
-
// 在 <template> 中,强制统一缩进
|
|
220
|
-
"vue/html-indent": ["warn", 2, {
|
|
221
|
-
"attribute": 1,
|
|
222
|
-
"baseIndent": 1,
|
|
223
|
-
"closeBracket": 0,
|
|
224
|
-
"alignAttributesVertically": true,
|
|
225
|
-
"ignores": [],
|
|
167
|
+
// 强制自定义事件名称的大小写
|
|
168
|
+
"vue/custom-event-name-casing": ["warn", "kebab-case", {
|
|
169
|
+
// "ignores": [],
|
|
226
170
|
}],
|
|
227
171
|
|
|
228
|
-
//
|
|
229
|
-
"vue/
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
172
|
+
// // button 按钮的 type 属性是否可以省略
|
|
173
|
+
// "vue/html-button-has-type": ["off", {
|
|
174
|
+
// "button": true,
|
|
175
|
+
// "submit": true,
|
|
176
|
+
// "reset": true,
|
|
177
|
+
// }],
|
|
178
|
+
|
|
179
|
+
// // 规定标签的右尖括号(>)是否要换行
|
|
180
|
+
// "vue/html-closing-bracket-newline": ["warn", {
|
|
181
|
+
// "singleline": "never",
|
|
182
|
+
// "multiline": "always",
|
|
183
|
+
// }],
|
|
184
|
+
|
|
185
|
+
// // 在 html 注释中,强制统一换行
|
|
186
|
+
// "vue/html-comment-content-newline": [
|
|
187
|
+
// "warn",
|
|
188
|
+
// {
|
|
189
|
+
// "singleline": "never",
|
|
190
|
+
// "multiline": "always",
|
|
191
|
+
// },
|
|
192
|
+
// {
|
|
193
|
+
// "exceptions": [],
|
|
194
|
+
// },
|
|
195
|
+
// ],
|
|
196
|
+
|
|
197
|
+
// 在 html 注释中,强制统一间距
|
|
198
|
+
"vue/html-comment-content-spacing": ["warn", "always", {
|
|
199
|
+
"exceptions": [],
|
|
233
200
|
}],
|
|
234
201
|
|
|
235
|
-
//
|
|
236
|
-
"vue/
|
|
202
|
+
// // 禁止不必要的胡须插值(mustaches)
|
|
203
|
+
// "vue/no-useless-mustaches": ["warn", {
|
|
204
|
+
// "ignoreIncludesComment": false,
|
|
205
|
+
// "ignoreStringEscape": false,
|
|
206
|
+
// }],
|
|
237
207
|
|
|
238
|
-
//
|
|
239
|
-
"vue/
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
"component": "always",
|
|
244
|
-
},
|
|
245
|
-
"svg": "always",
|
|
246
|
-
"math": "always",
|
|
247
|
-
}],
|
|
208
|
+
// // 禁止不必要的 v-bind 指令
|
|
209
|
+
// "vue/no-useless-v-bind": ["warn", {
|
|
210
|
+
// "ignoreIncludesComment": false,
|
|
211
|
+
// "ignoreStringEscape": false,
|
|
212
|
+
// }],
|
|
248
213
|
|
|
249
|
-
//
|
|
250
|
-
"vue/
|
|
214
|
+
// // 要求或禁止块之间的填充线
|
|
215
|
+
// "vue/padding-line-between-blocks": ["warn", "always"],
|
|
216
|
+
|
|
217
|
+
// // 要求 <template> 中的静态类名位于单独的 class 属性中
|
|
218
|
+
// "vue/prefer-separate-static-class": "warn",
|
|
219
|
+
|
|
220
|
+
// // 强制 v-for 指令的分隔符样式(使用 v-for="i in list",而不是 v-for="i of list")
|
|
221
|
+
// "vue/v-for-delimiter-style": ["warn", "in"],
|
|
251
222
|
|
|
252
223
|
// 在 v-on 指令绑定的回调事件中,如果没有参数,需要省略回调事件的括号
|
|
253
224
|
"vue/v-on-function-call": ["warn", "never"],
|
|
254
225
|
|
|
255
|
-
// 在单行元素的内容之前和之后需要换行符
|
|
256
|
-
"vue/singleline-html-element-content-newline": ["off", {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}],
|
|
226
|
+
// // 在单行元素的内容之前和之后需要换行符
|
|
227
|
+
// "vue/singleline-html-element-content-newline": ["off", {
|
|
228
|
+
// "ignoreWhenEmpty": true,
|
|
229
|
+
// "ignoreWhenNoAttributes": true,
|
|
230
|
+
// // "ignores": ["pre", "textarea", ...INLINE_ELEMENTS]
|
|
231
|
+
// }],
|
|
261
232
|
|
|
262
233
|
// 在多行元素的内容之前和之后需要换行符
|
|
263
234
|
"vue/multiline-html-element-content-newline": ["warn", {
|
|
@@ -266,50 +237,42 @@ module.exports = {
|
|
|
266
237
|
// "ignores": ["pre", "textarea", ...INLINE_ELEMENTS],
|
|
267
238
|
}],
|
|
268
239
|
|
|
269
|
-
// 在 mustache 胡须插值中强制统一间距
|
|
270
|
-
"vue/mustache-interpolation-spacing": ["warn", "always"],
|
|
271
|
-
|
|
272
240
|
// 属性中的等号周围不允许有空格
|
|
273
241
|
"vue/no-spaces-around-equal-signs-in-attribute": "warn",
|
|
274
242
|
|
|
275
243
|
// 强制在圆括号内使用一致的空格
|
|
276
244
|
"vue/space-in-parens": ["warn", "never"],
|
|
277
|
-
|
|
245
|
+
|
|
278
246
|
// 要求中缀操作符周围有空格(+-*/?| etc.)
|
|
279
247
|
"vue/space-infix-ops": "warn",
|
|
280
248
|
|
|
281
|
-
// 强制在一元操作符前后使用一致的空格
|
|
282
|
-
"vue/space-unary-ops": ["warn", {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}],
|
|
249
|
+
// // 强制在一元操作符前后使用一致的空格
|
|
250
|
+
// "vue/space-unary-ops": ["warn", {
|
|
251
|
+
// words: true,
|
|
252
|
+
// nonwords: false,
|
|
253
|
+
// }],
|
|
286
254
|
|
|
287
255
|
// 要求或禁止模板字符串中的嵌入表达式周围空格的使用
|
|
288
256
|
"vue/template-curly-spacing": "warn",
|
|
289
257
|
|
|
290
|
-
// 强制操作符使用一致的换行符
|
|
291
|
-
"vue/operator-linebreak": ["off", "before", { overrides: { "=": "none" } }],
|
|
292
|
-
|
|
293
|
-
// 要求或禁止在函数标识符和其调用之间有空格
|
|
294
|
-
"vue/func-call-spacing": ["warn", "never"],
|
|
295
|
-
|
|
296
|
-
// 禁止冗余的括号
|
|
297
|
-
"vue/no-extra-parens": ["off", "all", {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}],
|
|
304
|
-
|
|
305
|
-
//
|
|
306
|
-
"vue/
|
|
307
|
-
|
|
308
|
-
}],
|
|
309
|
-
|
|
310
|
-
// 强制 defineEmits、defineProps 编译器宏的顺序
|
|
311
|
-
"vue/define-macros-order": ["warn", {
|
|
312
|
-
"order": ["defineProps", "defineEmits"],
|
|
313
|
-
}],
|
|
258
|
+
// // 强制操作符使用一致的换行符
|
|
259
|
+
// "vue/operator-linebreak": ["off", "before", { overrides: { "=": "none" } }],
|
|
260
|
+
|
|
261
|
+
// // 要求或禁止在函数标识符和其调用之间有空格
|
|
262
|
+
// "vue/func-call-spacing": ["warn", "never"],
|
|
263
|
+
|
|
264
|
+
// // 禁止冗余的括号
|
|
265
|
+
// "vue/no-extra-parens": ["off", "all", {
|
|
266
|
+
// conditionalAssign: true,
|
|
267
|
+
// nestedBinaryExpressions: false,
|
|
268
|
+
// returnAssign: false,
|
|
269
|
+
// ignoreJSX: "all", // delegate to eslint-plugin-react
|
|
270
|
+
// enforceForArrowConditionals: false,
|
|
271
|
+
// }],
|
|
272
|
+
|
|
273
|
+
// // 强制 defineEmits、defineProps 编译器宏的顺序
|
|
274
|
+
// "vue/define-macros-order": ["warn", {
|
|
275
|
+
// "order": ["defineProps", "defineEmits"],
|
|
276
|
+
// }],
|
|
314
277
|
},
|
|
315
278
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
// ==========================================================
|
|
3
|
+
// @html-eslint
|
|
4
|
+
// ----------------------------------------------------------
|
|
5
|
+
// - seo.js
|
|
6
|
+
// - style.js
|
|
7
|
+
// - accessibility.js
|
|
8
|
+
// - best-practice.js
|
|
9
|
+
// ==========================================================
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
parser: "@html-eslint/parser",
|
|
13
|
+
plugins: ["@html-eslint"],
|
|
14
|
+
extends: [
|
|
15
|
+
"../rules/html/seo.js",
|
|
16
|
+
"../rules/html/style.js",
|
|
17
|
+
"../rules/html/accessibility.js",
|
|
18
|
+
"../rules/html/best-practice.js",
|
|
19
|
+
],
|
|
20
|
+
};
|
|
@@ -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
|
+
};
|
package/lib/configs/vue2.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
// ==========================================================
|
|
3
3
|
// Vue2 全部规则
|
|
4
|
+
// ----------------------------------------------------------
|
|
4
5
|
// - plugin:vue/base
|
|
5
6
|
// - plugin:vue/essential
|
|
6
7
|
// - plugin:vue/strongly-recommended
|
|
@@ -17,5 +18,11 @@ module.exports = {
|
|
|
17
18
|
],
|
|
18
19
|
rules: {
|
|
19
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
|
+
}],
|
|
20
27
|
},
|
|
21
28
|
};
|
package/lib/configs/vue3.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
// ==========================================================
|
|
3
3
|
// Vue3 全部规则
|
|
4
|
+
// ----------------------------------------------------------
|
|
4
5
|
// - plugin:vue/base
|
|
5
6
|
// - plugin:vue/vue3-essential
|
|
6
7
|
// - plugin:vue/vue3-strongly-recommended
|
|
@@ -17,5 +18,11 @@ module.exports = {
|
|
|
17
18
|
],
|
|
18
19
|
rules: {
|
|
19
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
|
+
}],
|
|
20
27
|
},
|
|
21
28
|
};
|