eslint-config-fe 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.
- package/base.js +32 -0
- package/commitlint.config.js +1 -0
- package/index.js +7 -364
- package/package.json +10 -9
- package/react.js +11 -0
- package/rules/base-babel.js +34 -0
- package/rules/base-extra.js +34 -0
- package/rules/base.js +944 -0
- package/rules/index.js +367 -0
- package/rules/react.js +526 -0
- package/rules/ts.js +117 -0
- package/ts.js +18 -0
- package/less.js +0 -994
- package/react/index.js +0 -533
- package/ts/index.js +0 -105
package/base.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: [
|
|
3
|
+
'./rules/base',
|
|
4
|
+
'./rules/base-babel'
|
|
5
|
+
].map(require.resolve),
|
|
6
|
+
parser: '@babel/eslint-parser',
|
|
7
|
+
parserOptions: {
|
|
8
|
+
sourceType: 'module',
|
|
9
|
+
ecmaFeatures: {
|
|
10
|
+
jsx: true
|
|
11
|
+
},
|
|
12
|
+
requireConfigFile: false
|
|
13
|
+
},
|
|
14
|
+
plugins: [
|
|
15
|
+
'@babel'
|
|
16
|
+
],
|
|
17
|
+
env: {
|
|
18
|
+
browser: true,
|
|
19
|
+
node: true,
|
|
20
|
+
es6: true
|
|
21
|
+
},
|
|
22
|
+
overrides: [
|
|
23
|
+
{
|
|
24
|
+
files: ['**/*.test.js', '**/*.spec.js'],
|
|
25
|
+
env: {
|
|
26
|
+
es6: true,
|
|
27
|
+
jest: true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = { extends: ['@commitlint/config-conventional'] };
|
package/index.js
CHANGED
|
@@ -1,366 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
const base = require('./base');
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
rules
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* https://eslint.org/docs/rules/unicode-bom
|
|
10
|
-
*/
|
|
11
|
-
'unicode-bom': 'warn',
|
|
3
|
+
base.extends = [
|
|
4
|
+
'./rules/base',
|
|
5
|
+
'./rules/base-babel',
|
|
6
|
+
'./rules/index'
|
|
7
|
+
].map(require.resolve);
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
* 限制使用剩余参数代替 arguments
|
|
15
|
-
*
|
|
16
|
-
* https://eslint.org/docs/rules/prefer-rest-params
|
|
17
|
-
*/
|
|
18
|
-
'prefer-rest-params': 'error',
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 限制函数最多定义6个参数
|
|
22
|
-
*
|
|
23
|
-
* https://eslint.org/docs/rules/max-params
|
|
24
|
-
*/
|
|
25
|
-
'max-params': ['warn', 6],
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 限制块语句最大可嵌套6层
|
|
29
|
-
*
|
|
30
|
-
* https://eslint.org/docs/rules/max-depth
|
|
31
|
-
*/
|
|
32
|
-
'max-depth': ['warn', 6],
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 限制回调函数最大可嵌套3层
|
|
36
|
-
*
|
|
37
|
-
* https://eslint.org/docs/rules/max-nested-callbacks
|
|
38
|
-
*/
|
|
39
|
-
'max-nested-callbacks': ['warn', 3],
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 限制在条件语句中出现赋值操作符被括号括起来
|
|
43
|
-
*
|
|
44
|
-
* https://eslint.org/docs/rules/no-cond-assign
|
|
45
|
-
*/
|
|
46
|
-
'no-cond-assign': ['error', 'except-parens'],
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 避免在 Promise executor 返回值
|
|
50
|
-
*
|
|
51
|
-
* https://eslint.org/docs/rules/no-promise-executor-return
|
|
52
|
-
*/
|
|
53
|
-
'no-promise-executor-return': 'error',
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* 避免在 setter 中返回值
|
|
57
|
-
*
|
|
58
|
-
* https://eslint.org/docs/rules/no-setter-return
|
|
59
|
-
*/
|
|
60
|
-
'no-setter-return': 'error',
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* 避免在常规字符串中出现模板字面量占位符语法
|
|
64
|
-
*
|
|
65
|
-
* https://eslint.org/docs/rules/no-template-curly-in-string
|
|
66
|
-
*/
|
|
67
|
-
'no-template-curly-in-string': 'error',
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* 避免不安全的使用可选链
|
|
71
|
-
*
|
|
72
|
-
* https://eslint.org/docs/rules/no-unsafe-optional-chaining
|
|
73
|
-
*/
|
|
74
|
-
'no-unsafe-optional-chaining': 'error',
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* 避免不必要的 catch 子句
|
|
78
|
-
*
|
|
79
|
-
* https://eslint.org/docs/rules/no-useless-catch
|
|
80
|
-
*/
|
|
81
|
-
'no-useless-catch': 'error',
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* 限制在点号之前换行
|
|
85
|
-
*
|
|
86
|
-
* https://eslint.org/docs/rules/dot-location
|
|
87
|
-
*/
|
|
88
|
-
'dot-location': ['error', 'property'],
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 限制数组方法的回调函数中有 return 语句
|
|
92
|
-
*
|
|
93
|
-
* https://eslint.org/docs/rules/array-callback-return
|
|
94
|
-
*/
|
|
95
|
-
'array-callback-return': [
|
|
96
|
-
'error',
|
|
97
|
-
{ allowImplicit: true }
|
|
98
|
-
],
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* 限制在 JSX 属性中使用一致的双引号
|
|
102
|
-
* 默认选项 'prefer-double'
|
|
103
|
-
*
|
|
104
|
-
* https://eslint.org/docs/rules/jsx-quotes
|
|
105
|
-
*/
|
|
106
|
-
'jsx-quotes': 'error',
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* 限制使用一致的换行符风格
|
|
110
|
-
* 默认选项 'unix'
|
|
111
|
-
*
|
|
112
|
-
* https://eslint.org/docs/rules/linebreak-style
|
|
113
|
-
*/
|
|
114
|
-
// 'linebreak-style': 'error',
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* 警告使用 alert()
|
|
118
|
-
*
|
|
119
|
-
* https://eslint.org/docs/rules/no-alert
|
|
120
|
-
*/
|
|
121
|
-
'no-alert': 'warn',
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* 警告使用 Buffer() 构造函数
|
|
125
|
-
*
|
|
126
|
-
* https://eslint.org/docs/rules/no-buffer-constructor
|
|
127
|
-
*/
|
|
128
|
-
'no-buffer-constructor': 'warn',
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* 避免使用 caller 或 callee
|
|
132
|
-
*
|
|
133
|
-
* https://eslint.org/docs/rules/no-caller
|
|
134
|
-
*/
|
|
135
|
-
'no-caller': 'error',
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 避免与 -0 进行比较
|
|
139
|
-
*
|
|
140
|
-
* https://eslint.org/docs/rules/no-compare-neg-zero
|
|
141
|
-
*/
|
|
142
|
-
'no-compare-neg-zero': 'error',
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* 避免在正则表达式中使用在 ASCII 中 0-31 范围内的特殊和不可见的字符
|
|
146
|
-
*
|
|
147
|
-
* https://eslint.org/docs/rules/no-control-regex
|
|
148
|
-
*/
|
|
149
|
-
'no-control-regex': 'error',
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* 避免对关系运算符的左操作数使用否定操作符
|
|
153
|
-
*
|
|
154
|
-
* https://eslint.org/docs/rules/no-unsafe-negation
|
|
155
|
-
*/
|
|
156
|
-
'no-unsafe-negation': 'error',
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* 避免出现空块语句,catch 语句除外
|
|
160
|
-
*
|
|
161
|
-
* https://eslint.org/docs/rules/no-empty
|
|
162
|
-
*/
|
|
163
|
-
'no-empty': [
|
|
164
|
-
'error',
|
|
165
|
-
{ 'allowEmptyCatch': true }
|
|
166
|
-
],
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* 避免出现空函数
|
|
170
|
-
*
|
|
171
|
-
* https://eslint.org/docs/rules/no-empty-function
|
|
172
|
-
*/
|
|
173
|
-
'no-empty-function': 'error',
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* 避免使用不必要的标签
|
|
177
|
-
*
|
|
178
|
-
* https://eslint.org/docs/rules/no-extra-label
|
|
179
|
-
*/
|
|
180
|
-
'no-extra-label': 'error',
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* 避免使用不必要的分号
|
|
184
|
-
*
|
|
185
|
-
* https://eslint.org/docs/rules/no-extra-semi
|
|
186
|
-
*/
|
|
187
|
-
'no-extra-semi': 'error',
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* 避免使用浮点小数
|
|
191
|
-
*
|
|
192
|
-
* https://eslint.org/docs/rules/no-floating-decimal
|
|
193
|
-
*/
|
|
194
|
-
'no-floating-decimal': 'error',
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* 避免 if 语句作为唯一语句出现在 else 语句块中
|
|
198
|
-
*
|
|
199
|
-
* https://eslint.org/docs/rules/no-lonely-if
|
|
200
|
-
*/
|
|
201
|
-
'no-lonely-if': 'error',
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* 警告连续赋值
|
|
205
|
-
*
|
|
206
|
-
* https://eslint.org/docs/rules/no-multi-assign
|
|
207
|
-
*/
|
|
208
|
-
'no-multi-assign': 'warn',
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* 警告出现多个空行
|
|
212
|
-
*
|
|
213
|
-
* https://eslint.org/docs/rules/no-multiple-empty-lines
|
|
214
|
-
*/
|
|
215
|
-
'no-multiple-empty-lines': 'warn',
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* 避免使用 new require
|
|
219
|
-
*
|
|
220
|
-
* https://eslint.org/docs/rules/no-new-require
|
|
221
|
-
*/
|
|
222
|
-
'no-new-require': 'error',
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* 避免在返回语句中赋值
|
|
226
|
-
* 默认选项 'except-parens'
|
|
227
|
-
*
|
|
228
|
-
* https://eslint.org/docs/rules/no-return-assign
|
|
229
|
-
*/
|
|
230
|
-
'no-return-assign': 'error',
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* 避免 Script URL
|
|
234
|
-
*
|
|
235
|
-
* https://eslint.org/docs/rules/no-script-url
|
|
236
|
-
*/
|
|
237
|
-
'no-script-url': 'warn',
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* 限制 Error 对象可以被抛出
|
|
241
|
-
*
|
|
242
|
-
* https://eslint.org/docs/rules/no-throw-literal
|
|
243
|
-
*/
|
|
244
|
-
'no-throw-literal': 'warn',
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* 避免出现未使用过的表达式
|
|
248
|
-
*
|
|
249
|
-
* https://eslint.org/docs/rules/no-unused-expressions
|
|
250
|
-
*/
|
|
251
|
-
'no-unused-expressions': ['warn', { allowShortCircuit: true }],
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* 避免出现未使用过的标签
|
|
255
|
-
*
|
|
256
|
-
* https://eslint.org/docs/rules/no-unused-labels
|
|
257
|
-
*/
|
|
258
|
-
'no-unused-labels': 'error',
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* 避免出现解构重命名后的变量名跟原来一样
|
|
262
|
-
*
|
|
263
|
-
* https://eslint.org/docs/rules/no-unused-labels
|
|
264
|
-
*/
|
|
265
|
-
'no-useless-rename': 'error',
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* 避免出现多余的 return 语句
|
|
269
|
-
*
|
|
270
|
-
* https://eslint.org/docs/rules/no-useless-return
|
|
271
|
-
*/
|
|
272
|
-
'no-useless-return': 'error',
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* 限制在花括号内使用一致的换行符
|
|
276
|
-
*
|
|
277
|
-
* https://eslint.org/docs/rules/object-curly-newline
|
|
278
|
-
*/
|
|
279
|
-
'object-curly-newline': ['error', { consistent: true, multiline: true }],
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* 限制对象字面量的简写或非简写一致性,但尽可能的全部使用简写
|
|
283
|
-
*
|
|
284
|
-
* https://eslint.org/docs/rules/object-shorthand
|
|
285
|
-
*/
|
|
286
|
-
'object-shorthand': ['off', 'consistent-as-needed'],
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* 限制每个变量初始化语句换行
|
|
290
|
-
* 默认选项 'initializations'
|
|
291
|
-
*
|
|
292
|
-
* https://eslint.org/docs/rules/one-var-declaration-per-line
|
|
293
|
-
*/
|
|
294
|
-
'one-var-declaration-per-line': 'error',
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* 限制使用箭头函数作为回调函数
|
|
298
|
-
*
|
|
299
|
-
* https://eslint.org/docs/rules/prefer-arrow-callback
|
|
300
|
-
*/
|
|
301
|
-
'prefer-arrow-callback': 'warn',
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* 限制一个变量不会被重新赋值,使用const
|
|
305
|
-
*
|
|
306
|
-
* https://eslint.org/docs/rules/prefer-const
|
|
307
|
-
*/
|
|
308
|
-
'prefer-const': 'error',
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* 限制使用 Error 对象作为 Promise 拒绝的原因
|
|
312
|
-
*
|
|
313
|
-
* https://eslint.org/docs/rules/prefer-promise-reject-errors
|
|
314
|
-
*/
|
|
315
|
-
'prefer-promise-reject-errors': 'warn',
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* 警告使用扩展语法而非.apply()
|
|
319
|
-
*
|
|
320
|
-
* https://eslint.org/docs/rules/prefer-spread
|
|
321
|
-
*/
|
|
322
|
-
'prefer-spread': 'warn',
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* 避免剩余和扩展运算符及其表达式之间有空格
|
|
326
|
-
*
|
|
327
|
-
* https://eslint.org/docs/rules/rest-spread-spacing
|
|
328
|
-
*/
|
|
329
|
-
'rest-spread-spacing': ['error', 'never'],
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* 限制分号出现在句子末尾
|
|
333
|
-
*
|
|
334
|
-
* https://eslint.org/docs/rules/semi-style
|
|
335
|
-
*/
|
|
336
|
-
'semi-style': ['error', 'last'],
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* 限制创建 Symbol 实例需要一个参数
|
|
340
|
-
*
|
|
341
|
-
* https://eslint.org/docs/rules/symbol-description
|
|
342
|
-
*/
|
|
343
|
-
'symbol-description': 'warn',
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* 避免模板字符串中花括号内出现空格
|
|
347
|
-
*
|
|
348
|
-
* https://eslint.org/docs/rules/template-curly-spacing
|
|
349
|
-
*/
|
|
350
|
-
'template-curly-spacing': ['error', 'never'],
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* 避免在模板标记和它们的字面量之间出现空格
|
|
354
|
-
*
|
|
355
|
-
* https://eslint.org/docs/rules/template-tag-spacing
|
|
356
|
-
*/
|
|
357
|
-
'template-tag-spacing': ['error', 'never'],
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* 限制条件比较时,变量在左边,常量在右边
|
|
361
|
-
*
|
|
362
|
-
* https://eslint.org/docs/rules/yoda
|
|
363
|
-
*/
|
|
364
|
-
'yoda': 'warn'
|
|
365
|
-
}
|
|
366
|
-
};
|
|
9
|
+
module.exports = base;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-fe",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "ESLint config for Front End.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,19 +9,20 @@
|
|
|
9
9
|
"author": "Jesse Feng <fxm0016@126.com>",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@babel/core": "^7.
|
|
13
|
-
"@babel/eslint-parser": "^7.
|
|
14
|
-
"@babel/eslint-plugin": "^7.
|
|
15
|
-
"@commitlint/cli": "^
|
|
16
|
-
"
|
|
12
|
+
"@babel/core": "^7.14.0",
|
|
13
|
+
"@babel/eslint-parser": "^7.13.14",
|
|
14
|
+
"@babel/eslint-plugin": "^7.13.16",
|
|
15
|
+
"@commitlint/cli": "^17.6.1",
|
|
16
|
+
"@commitlint/config-conventional": "^17.6.1",
|
|
17
|
+
"eslint": "^8.48.0",
|
|
17
18
|
"husky": "^4.3.0",
|
|
18
|
-
"lint-staged": "^
|
|
19
|
+
"lint-staged": "^13.2.1"
|
|
19
20
|
},
|
|
20
21
|
"peerDependencies": {
|
|
21
22
|
"@babel/core": "^7.13.16",
|
|
22
23
|
"@babel/eslint-parser": "^7.11.0",
|
|
23
24
|
"@babel/eslint-plugin": "^7.11.0",
|
|
24
|
-
"eslint": "
|
|
25
|
+
"eslint": ">=6.2.0"
|
|
25
26
|
},
|
|
26
27
|
"repository": {
|
|
27
28
|
"type": "git",
|
|
@@ -48,4 +49,4 @@
|
|
|
48
49
|
"git add"
|
|
49
50
|
]
|
|
50
51
|
}
|
|
51
|
-
}
|
|
52
|
+
}
|
package/react.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
/**
|
|
4
|
+
* 限制构造函数首字母大写
|
|
5
|
+
*
|
|
6
|
+
* https://eslint.org/docs/rules/new-cap
|
|
7
|
+
*/
|
|
8
|
+
'@babel/new-cap': [
|
|
9
|
+
'error',
|
|
10
|
+
{
|
|
11
|
+
capIsNewExceptions: [
|
|
12
|
+
'Vue',
|
|
13
|
+
'React'
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 限制在花括号中使用一致的空格
|
|
20
|
+
*
|
|
21
|
+
* https://eslint.org/docs/rules/object-curly-spacing
|
|
22
|
+
*/
|
|
23
|
+
'@babel/object-curly-spacing': ['error', 'always'],
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 限制语句末尾使用分号
|
|
27
|
+
* 默认选项为 'always'
|
|
28
|
+
*
|
|
29
|
+
* https://eslint.org/docs/rules/semi
|
|
30
|
+
*/
|
|
31
|
+
'@babel/semi': 'error'
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
/**
|
|
4
|
+
* 限制构造函数首字母大写
|
|
5
|
+
*
|
|
6
|
+
* https://eslint.org/docs/rules/new-cap
|
|
7
|
+
*/
|
|
8
|
+
'new-cap': [
|
|
9
|
+
'error',
|
|
10
|
+
{
|
|
11
|
+
capIsNewExceptions: [
|
|
12
|
+
'Vue',
|
|
13
|
+
'React'
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 限制在花括号中使用一致的空格
|
|
20
|
+
*
|
|
21
|
+
* https://eslint.org/docs/rules/object-curly-spacing
|
|
22
|
+
*/
|
|
23
|
+
'object-curly-spacing': ['error', 'always'],
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 限制语句末尾使用分号
|
|
27
|
+
* 默认选项为 'always'
|
|
28
|
+
*
|
|
29
|
+
* https://eslint.org/docs/rules/semi
|
|
30
|
+
*/
|
|
31
|
+
semi: 'error'
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|