eslint-config-fe 1.4.1 → 2.1.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/.github/workflows/npm-publish.yml +24 -0
- package/README.md +5 -5
- package/base.js +36 -0
- package/index.js +7 -364
- package/package.json +16 -24
- package/react.js +19 -0
- package/rules/base-babel.js +33 -0
- package/rules/base-extra.js +33 -0
- package/rules/base.js +944 -0
- package/rules/index.js +367 -0
- package/rules/react.js +526 -0
- package/rules/ts.js +116 -0
- package/ts.js +18 -0
- package/less.js +0 -1000
- package/react/index.js +0 -533
- package/ts/index.js +0 -129
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
+
|
|
4
|
+
name: Node.js Package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [main]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [main]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
publish-npm:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v3
|
|
17
|
+
- uses: actions/setup-node@v3
|
|
18
|
+
with:
|
|
19
|
+
node-version: 14
|
|
20
|
+
registry-url: https://registry.npmjs.org/
|
|
21
|
+
- run: npm i
|
|
22
|
+
- run: npm publish
|
|
23
|
+
env:
|
|
24
|
+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
package/README.md
CHANGED
|
@@ -27,15 +27,15 @@ npm install --save-dev eslint @babel/core @babel/eslint-parser @babel/eslint-plu
|
|
|
27
27
|
|
|
28
28
|
[learn more](https://github.com/fengxinming/eslint-config-fe/blob/main/index.js)
|
|
29
29
|
|
|
30
|
-
####
|
|
30
|
+
#### Base rules .eslintrc
|
|
31
31
|
|
|
32
32
|
```js
|
|
33
33
|
{
|
|
34
|
-
extends: ["fe/
|
|
34
|
+
extends: ["fe/base"]
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
[learn more](https://github.com/fengxinming/eslint-config-fe/blob/main/
|
|
38
|
+
[learn more](https://github.com/fengxinming/eslint-config-fe/blob/main/base.js)
|
|
39
39
|
|
|
40
40
|
### React eslint config
|
|
41
41
|
|
|
@@ -62,7 +62,7 @@ module.exports = {
|
|
|
62
62
|
}
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
[learn more](https://github.com/fengxinming/eslint-config-fe/blob/main/react
|
|
65
|
+
[learn more](https://github.com/fengxinming/eslint-config-fe/blob/main/react.js)
|
|
66
66
|
|
|
67
67
|
### TS eslint config
|
|
68
68
|
|
|
@@ -81,4 +81,4 @@ npm install --save-dev @typescript-eslint/parser @typescript-eslint/eslint-plugi
|
|
|
81
81
|
}
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
[learn more](https://github.com/fengxinming/eslint-config-fe/blob/main/ts
|
|
84
|
+
[learn more](https://github.com/fengxinming/eslint-config-fe/blob/main/ts.js)
|
package/base.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
babelOptions: {
|
|
14
|
+
babelrc: false,
|
|
15
|
+
configFile: false,
|
|
16
|
+
presets: ['@babel/preset-env']
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
plugins: [
|
|
20
|
+
'@babel'
|
|
21
|
+
],
|
|
22
|
+
env: {
|
|
23
|
+
browser: true,
|
|
24
|
+
node: true,
|
|
25
|
+
es6: true
|
|
26
|
+
},
|
|
27
|
+
overrides: [
|
|
28
|
+
{
|
|
29
|
+
files: ['**/*.test.js', '**/*.spec.js'],
|
|
30
|
+
env: {
|
|
31
|
+
es6: true,
|
|
32
|
+
jest: true
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
};
|
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": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "ESLint config for Front End.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,20 +8,23 @@
|
|
|
8
8
|
},
|
|
9
9
|
"author": "Jesse Feng <fxm0016@126.com>",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"
|
|
12
|
-
"@babel/core": "^7.11.
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@babel/core": "^7.11.0",
|
|
13
13
|
"@babel/eslint-parser": "^7.11.0",
|
|
14
14
|
"@babel/eslint-plugin": "^7.11.0",
|
|
15
|
-
"@
|
|
16
|
-
"eslint": "^
|
|
17
|
-
"
|
|
18
|
-
"
|
|
15
|
+
"@babel/preset-env": "^7.11.0",
|
|
16
|
+
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
17
|
+
"@typescript-eslint/parser": "^5.62.0",
|
|
18
|
+
"lodash": "^4.17.21"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"eslint": "^8.0.0"
|
|
19
22
|
},
|
|
20
23
|
"peerDependencies": {
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
24
|
+
"eslint": ">=6.2.0"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": "^14.18.0 || >=16.0.0"
|
|
25
28
|
},
|
|
26
29
|
"repository": {
|
|
27
30
|
"type": "git",
|
|
@@ -36,16 +39,5 @@
|
|
|
36
39
|
"bugs": {
|
|
37
40
|
"url": "https://github.com/fengxinming/eslint-config-fe/issues"
|
|
38
41
|
},
|
|
39
|
-
"homepage": "https://github.com/fengxinming/eslint-config-fe#readme"
|
|
40
|
-
|
|
41
|
-
"hooks": {
|
|
42
|
-
"pre-commit": "lint-staged"
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
"lint-staged": {
|
|
46
|
-
"*.js": [
|
|
47
|
-
"eslint --fix",
|
|
48
|
-
"git add"
|
|
49
|
-
]
|
|
50
|
-
}
|
|
51
|
-
}
|
|
42
|
+
"homepage": "https://github.com/fengxinming/eslint-config-fe#readme"
|
|
43
|
+
}
|
package/react.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: [
|
|
3
|
+
'./rules/react'
|
|
4
|
+
].map(require.resolve),
|
|
5
|
+
plugins: [
|
|
6
|
+
'react',
|
|
7
|
+
'react-hooks'
|
|
8
|
+
],
|
|
9
|
+
parserOptions: {
|
|
10
|
+
babelOptions: {
|
|
11
|
+
presets: ['@babel/preset-react']
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
settings: {
|
|
15
|
+
react: {
|
|
16
|
+
version: 'detect'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
};
|