eslint-config-fe 1.4.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/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 -1000
- package/react/index.js +0 -533
- package/ts/index.js +0 -129
package/rules/react.js
ADDED
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
/**
|
|
4
|
+
* 检查hooks规则
|
|
5
|
+
*
|
|
6
|
+
* https://reactjs.org/docs/hooks-rules.html
|
|
7
|
+
*/
|
|
8
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 检查副作用的依赖
|
|
12
|
+
*
|
|
13
|
+
* https://reactjs.org/docs/hooks-rules.html
|
|
14
|
+
*/
|
|
15
|
+
'react-hooks/exhaustive-deps': 'error',
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 关闭默认属性类型定义
|
|
19
|
+
*
|
|
20
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/default-props-match-prop-types.md
|
|
21
|
+
*/
|
|
22
|
+
'react/default-props-match-prop-types': 'off',
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 关闭组件的displayName定义
|
|
26
|
+
*
|
|
27
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md
|
|
28
|
+
*/
|
|
29
|
+
'react/display-name': 'off',
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 关闭限制自定义组件的 className、style 属性
|
|
33
|
+
*
|
|
34
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md
|
|
35
|
+
*/
|
|
36
|
+
// 'react/forbid-component-props': 'off',
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 关闭禁止原生组件使用
|
|
40
|
+
*
|
|
41
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-elements.md
|
|
42
|
+
*/
|
|
43
|
+
'react/forbid-elements': 'off',
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 检查所有的对象确保 propTypes 属性没有被使用
|
|
47
|
+
*
|
|
48
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md
|
|
49
|
+
*/
|
|
50
|
+
'react/forbid-foreign-prop-types': 'warn',
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 关闭检查 propTypes 未被使用
|
|
54
|
+
*
|
|
55
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md
|
|
56
|
+
*/
|
|
57
|
+
'react/forbid-prop-types': 'off',
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 避免使用 true 作为属性值
|
|
61
|
+
*
|
|
62
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
|
|
63
|
+
*/
|
|
64
|
+
'react/jsx-boolean-value': ['error', 'never'],
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 闭合标签和开标签对齐
|
|
68
|
+
*
|
|
69
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
|
|
70
|
+
*/
|
|
71
|
+
'react/jsx-closing-bracket-location': ['error', 'line-aligned'],
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 避免jsx模板大括号里面出现空格
|
|
75
|
+
*
|
|
76
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
|
|
77
|
+
*/
|
|
78
|
+
'react/jsx-curly-spacing': ['error', 'never'],
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 避免jsx模板等号周围出现空格
|
|
82
|
+
*
|
|
83
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
|
|
84
|
+
*/
|
|
85
|
+
'react/jsx-equals-spacing': ['error', 'never'],
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 限制哪些文件支持jsx语法
|
|
89
|
+
*
|
|
90
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
|
|
91
|
+
*/
|
|
92
|
+
'react/jsx-filename-extension': [
|
|
93
|
+
'error',
|
|
94
|
+
{
|
|
95
|
+
extensions: ['.js', '.jsx', '.es', '.tsx']
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 限制多行属性换行
|
|
101
|
+
*
|
|
102
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
|
|
103
|
+
*/
|
|
104
|
+
'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 关闭组件中的事件属性前加上on
|
|
108
|
+
*
|
|
109
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
|
|
110
|
+
*/
|
|
111
|
+
'react/jsx-handler-names': 'off',
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 限制jsx中的属性换行缩进为2
|
|
115
|
+
*
|
|
116
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
|
|
117
|
+
*/
|
|
118
|
+
'react/jsx-indent-props': ['error', 2],
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 限制jsx中的属性换行缩进为2
|
|
122
|
+
*
|
|
123
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md
|
|
124
|
+
*/
|
|
125
|
+
'react/jsx-indent': ['error', 2],
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 避免缺少 key 属性
|
|
129
|
+
*
|
|
130
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
|
|
131
|
+
*
|
|
132
|
+
*/
|
|
133
|
+
'react/jsx-key': 'error',
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 限制超过一个属性就换行
|
|
137
|
+
*
|
|
138
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
|
|
139
|
+
*/
|
|
140
|
+
'react/jsx-max-props-per-line': [
|
|
141
|
+
'error',
|
|
142
|
+
{
|
|
143
|
+
when: 'multiline'
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 限制使用 bind 方法
|
|
149
|
+
*
|
|
150
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
|
|
151
|
+
*/
|
|
152
|
+
'react/jsx-no-bind': [
|
|
153
|
+
'warn',
|
|
154
|
+
{
|
|
155
|
+
ignoreRefs: true,
|
|
156
|
+
allowArrowFunctions: true,
|
|
157
|
+
allowBind: false,
|
|
158
|
+
ignoreDOMComponents: true
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* 限制文本节点使用注释
|
|
164
|
+
*
|
|
165
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
|
|
166
|
+
*/
|
|
167
|
+
'react/jsx-no-comment-textnodes': 'warn',
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 避免出现重复的 prop
|
|
171
|
+
*
|
|
172
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
|
|
173
|
+
*/
|
|
174
|
+
'react/jsx-no-duplicate-props': [
|
|
175
|
+
'error',
|
|
176
|
+
{
|
|
177
|
+
ignoreCase: true
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* 关闭文本字符串转成模板字面量
|
|
183
|
+
*
|
|
184
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md
|
|
185
|
+
*/
|
|
186
|
+
'react/jsx-no-literals': 'off',
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 限制需要rel='noreferrer'
|
|
190
|
+
*
|
|
191
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
|
|
192
|
+
*/
|
|
193
|
+
'react/jsx-no-target-blank': 'error',
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 不允许jsx中出现未声明的变量
|
|
197
|
+
*
|
|
198
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
|
|
199
|
+
*/
|
|
200
|
+
'react/jsx-no-undef': 'error',
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* 限制驼峰jsx标签名,忽略全大写加下划线
|
|
204
|
+
*
|
|
205
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
|
|
206
|
+
*/
|
|
207
|
+
'react/jsx-pascal-case': [
|
|
208
|
+
'error',
|
|
209
|
+
{
|
|
210
|
+
allowAllCaps: true
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* 关闭检查属性顺序
|
|
216
|
+
*
|
|
217
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
|
|
218
|
+
*/
|
|
219
|
+
'react/jsx-sort-props': 'off',
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* 限制开标签结束前有空格
|
|
223
|
+
*
|
|
224
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md
|
|
225
|
+
*/
|
|
226
|
+
'react/jsx-tag-spacing': [
|
|
227
|
+
'error',
|
|
228
|
+
{
|
|
229
|
+
closingSlash: 'never',
|
|
230
|
+
beforeSelfClosing: 'always',
|
|
231
|
+
beforeClosing: 'never',
|
|
232
|
+
afterOpening: 'never'
|
|
233
|
+
}
|
|
234
|
+
],
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* 限制定义 React 全局变量
|
|
238
|
+
*/
|
|
239
|
+
'react/jsx-uses-react': 'error',
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* 避免jsx中变量未被使用
|
|
243
|
+
*
|
|
244
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
|
|
245
|
+
*/
|
|
246
|
+
'react/jsx-uses-vars': 'error',
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* 限制用括号包裹jsx,并且jsx需要换行
|
|
250
|
+
*
|
|
251
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md
|
|
252
|
+
*/
|
|
253
|
+
'react/jsx-wrap-multilines': [
|
|
254
|
+
'error',
|
|
255
|
+
{
|
|
256
|
+
declaration: 'parens-new-line',
|
|
257
|
+
assignment: 'parens-new-line',
|
|
258
|
+
return: 'parens-new-line',
|
|
259
|
+
arrow: 'parens-new-line'
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* 限制结束标签和开始标签对齐
|
|
265
|
+
*
|
|
266
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
|
|
267
|
+
*/
|
|
268
|
+
'react/jsx-closing-tag-location': 'error',
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* 避免属性间出现多空格
|
|
272
|
+
*
|
|
273
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-multi-spaces.md
|
|
274
|
+
*/
|
|
275
|
+
'react/jsx-props-no-multi-spaces': 'error',
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* 避免使用 index 作为 key
|
|
279
|
+
*
|
|
280
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
|
|
281
|
+
*/
|
|
282
|
+
'react/no-array-index-key': 'error',
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* 避免出现 children 作为 prop
|
|
286
|
+
*
|
|
287
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md
|
|
288
|
+
*/
|
|
289
|
+
'react/no-children-prop': 'error',
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* 避免 dangerouslySetInnerHTML 属性和 children 共存
|
|
293
|
+
*
|
|
294
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md
|
|
295
|
+
*/
|
|
296
|
+
'react/no-danger-with-children': 'error',
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* 避免使用过时的方法
|
|
300
|
+
*
|
|
301
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
|
|
302
|
+
*/
|
|
303
|
+
'react/no-deprecated': 'warn',
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* 关闭不允许 componentDidMount 中使用 setState
|
|
307
|
+
*
|
|
308
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
|
|
309
|
+
*/
|
|
310
|
+
'react/no-did-mount-set-state': 'off',
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* 关闭不允许 componentDidUpdate 中使用 setState
|
|
314
|
+
*
|
|
315
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
|
|
316
|
+
*/
|
|
317
|
+
'react/no-did-update-set-state': 'off',
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* 避免在 componentWillUpdate 使用 setState
|
|
321
|
+
*
|
|
322
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md
|
|
323
|
+
*/
|
|
324
|
+
'react/no-will-update-set-state': 'error',
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* 避免直接对 this.state 赋值
|
|
328
|
+
*
|
|
329
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
|
|
330
|
+
*/
|
|
331
|
+
'react/no-direct-mutation-state': 'error',
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* 警告使用 findDOMNode
|
|
335
|
+
*
|
|
336
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
|
|
337
|
+
*/
|
|
338
|
+
'react/no-find-dom-node': 'warn',
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* 避免使用 isMounted
|
|
342
|
+
*
|
|
343
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
|
|
344
|
+
*/
|
|
345
|
+
'react/no-is-mounted': 'error',
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* 限制一个文件里面定义一个class组件
|
|
349
|
+
*
|
|
350
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
|
|
351
|
+
*/
|
|
352
|
+
'react/no-multi-comp': [
|
|
353
|
+
'error',
|
|
354
|
+
{
|
|
355
|
+
ignoreStateless: true
|
|
356
|
+
}
|
|
357
|
+
],
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* 避免使用 ReactDOM.render 返回值
|
|
361
|
+
*
|
|
362
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md
|
|
363
|
+
*/
|
|
364
|
+
'react/no-render-return-value': 'error',
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* 关闭使用不必要的 setState
|
|
368
|
+
*
|
|
369
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md
|
|
370
|
+
*/
|
|
371
|
+
'react/no-set-state': 'off',
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* 避免 ref 绑定一个字符串
|
|
375
|
+
*
|
|
376
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
|
|
377
|
+
*/
|
|
378
|
+
'react/no-string-refs': 'error',
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* 避免标签中出现没有转义的符号
|
|
382
|
+
*
|
|
383
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
|
|
384
|
+
*/
|
|
385
|
+
'react/no-unescaped-entities': 'error',
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* 避免DOM标签出现未知属性
|
|
389
|
+
*
|
|
390
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
|
|
391
|
+
*/
|
|
392
|
+
'react/no-unknown-property': 'error',
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* 关闭检查proptypes定义
|
|
396
|
+
*
|
|
397
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md
|
|
398
|
+
*/
|
|
399
|
+
'react/no-unused-prop-types': 'off',
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* 限制使用 class 语法定义类组件
|
|
403
|
+
*
|
|
404
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
|
|
405
|
+
*/
|
|
406
|
+
'react/prefer-es6-class': ['error', 'always'],
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* 限制没有state的情况下使用函数组件代替类组件
|
|
410
|
+
*
|
|
411
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
|
|
412
|
+
*/
|
|
413
|
+
'react/prefer-stateless-function': 'error',
|
|
414
|
+
/**
|
|
415
|
+
* 关闭声明 propTypes
|
|
416
|
+
*
|
|
417
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md
|
|
418
|
+
*/
|
|
419
|
+
'react/prop-types': 'off',
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* 关闭使用jsx语法时需要导入React
|
|
423
|
+
*
|
|
424
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
|
|
425
|
+
*/
|
|
426
|
+
'react/react-in-jsx-scope': 'off',
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* 关闭强制定义defaultProps
|
|
430
|
+
*
|
|
431
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
|
|
432
|
+
*/
|
|
433
|
+
'react/require-default-props': 'off',
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* 关闭强制类组件需要有 shouldComponentUpdate 方法
|
|
437
|
+
*
|
|
438
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md
|
|
439
|
+
*/
|
|
440
|
+
'react/require-optimization': 'off',
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* 限制 render 方法中需要返回值
|
|
444
|
+
*
|
|
445
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md
|
|
446
|
+
*/
|
|
447
|
+
'react/require-render-return': 'error',
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* 限制没有 children 的组件存在关闭标签
|
|
451
|
+
*
|
|
452
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
|
|
453
|
+
*/
|
|
454
|
+
'react/self-closing-comp': [
|
|
455
|
+
'error',
|
|
456
|
+
{
|
|
457
|
+
component: true,
|
|
458
|
+
html: false
|
|
459
|
+
}
|
|
460
|
+
],
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* 关闭 propTypes 排序
|
|
464
|
+
*
|
|
465
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
|
|
466
|
+
*/
|
|
467
|
+
'react/sort-prop-types': 'off',
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* 限制 style 属性绑定一个对象
|
|
471
|
+
*
|
|
472
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
|
|
473
|
+
*/
|
|
474
|
+
'react/style-prop-object': 'error',
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* 避免部分DOM节点包含 children
|
|
478
|
+
*/
|
|
479
|
+
'react/void-dom-elements-no-children': 'error',
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* 关闭组件方法排序
|
|
483
|
+
*
|
|
484
|
+
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
|
|
485
|
+
*/
|
|
486
|
+
'react/sort-comp': [
|
|
487
|
+
'off',
|
|
488
|
+
{
|
|
489
|
+
order: [
|
|
490
|
+
'static-properties',
|
|
491
|
+
'static-methods',
|
|
492
|
+
'state',
|
|
493
|
+
'properties',
|
|
494
|
+
'lifecycle',
|
|
495
|
+
'everything-else',
|
|
496
|
+
'render'
|
|
497
|
+
],
|
|
498
|
+
groups: {
|
|
499
|
+
'static-properties': [
|
|
500
|
+
'displayName',
|
|
501
|
+
'propTypes',
|
|
502
|
+
'contextTypes',
|
|
503
|
+
'childContextTypes',
|
|
504
|
+
'mixins',
|
|
505
|
+
'statics'
|
|
506
|
+
],
|
|
507
|
+
lifecycle: [
|
|
508
|
+
'getDefaultProps',
|
|
509
|
+
'getInitialState',
|
|
510
|
+
'constructor',
|
|
511
|
+
'getChildContext',
|
|
512
|
+
'componentWillMount',
|
|
513
|
+
'componentDidMount',
|
|
514
|
+
'componentWillReceiveProps',
|
|
515
|
+
'shouldComponentUpdate',
|
|
516
|
+
'componentWillUpdate',
|
|
517
|
+
'componentDidUpdate',
|
|
518
|
+
'componentDidCatch',
|
|
519
|
+
'componentWillUnmount'
|
|
520
|
+
]
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
]
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
|
package/rules/ts.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
4
|
+
'@typescript-eslint/array-type': [
|
|
5
|
+
'error',
|
|
6
|
+
{
|
|
7
|
+
default: 'array-simple',
|
|
8
|
+
readonly: 'array-simple'
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
'@typescript-eslint/await-thenable': 'warn',
|
|
12
|
+
'@typescript-eslint/ban-types': 'error',
|
|
13
|
+
'@typescript-eslint/naming-convention': 'off',
|
|
14
|
+
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
|
|
15
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
16
|
+
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
|
|
17
|
+
'func-call-spacing': 'off',
|
|
18
|
+
'@typescript-eslint/func-call-spacing': 'error',
|
|
19
|
+
'@typescript-eslint/indent': 'off',
|
|
20
|
+
'@typescript-eslint/member-delimiter-style': [
|
|
21
|
+
'error',
|
|
22
|
+
{
|
|
23
|
+
multiline: {
|
|
24
|
+
delimiter: 'semi',
|
|
25
|
+
requireLast: true
|
|
26
|
+
},
|
|
27
|
+
singleline: {
|
|
28
|
+
delimiter: 'comma',
|
|
29
|
+
requireLast: false
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
'@typescript-eslint/member-ordering': 'warn',
|
|
34
|
+
'@typescript-eslint/no-array-constructor': 'error',
|
|
35
|
+
'no-empty-function': 'off',
|
|
36
|
+
// 编辑器可以检查出空函数
|
|
37
|
+
'@typescript-eslint/no-empty-function': 'off',
|
|
38
|
+
'@typescript-eslint/no-empty-interface': 'warn',
|
|
39
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
40
|
+
'no-extra-parens': 'off',
|
|
41
|
+
'@typescript-eslint/no-extra-parens': 'off',
|
|
42
|
+
'@typescript-eslint/no-extraneous-class': 'error',
|
|
43
|
+
'@typescript-eslint/no-floating-promises': 'off',
|
|
44
|
+
'@typescript-eslint/no-for-in-array': 'error',
|
|
45
|
+
'@typescript-eslint/no-inferrable-types': 'off',
|
|
46
|
+
'@typescript-eslint/no-magic-numbers': 'off',
|
|
47
|
+
'@typescript-eslint/no-misused-new': 'error',
|
|
48
|
+
'@typescript-eslint/no-namespace': 'error',
|
|
49
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
50
|
+
'@typescript-eslint/consistent-type-assertions': 'error',
|
|
51
|
+
'@typescript-eslint/no-parameter-properties': 'off',
|
|
52
|
+
'@typescript-eslint/no-require-imports': 'error',
|
|
53
|
+
'@typescript-eslint/no-this-alias': 'off',
|
|
54
|
+
'@typescript-eslint/no-type-alias': 'off',
|
|
55
|
+
'@typescript-eslint/no-unnecessary-qualifier': 'error',
|
|
56
|
+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
|
57
|
+
'no-unused-vars': 'off',
|
|
58
|
+
'@typescript-eslint/no-unused-vars': [
|
|
59
|
+
'error',
|
|
60
|
+
{ vars: 'all', args: 'after-used', ignoreRestSiblings: true }
|
|
61
|
+
],
|
|
62
|
+
// 'init-declarations': 'off',
|
|
63
|
+
// '@typescript-eslint/init-declarations': 'off',
|
|
64
|
+
'@typescript-eslint/no-use-before-define': 'error',
|
|
65
|
+
'@typescript-eslint/no-useless-constructor': 'error',
|
|
66
|
+
'@typescript-eslint/no-var-requires': 'error',
|
|
67
|
+
'@typescript-eslint/no-dupe-class-members': 'error',
|
|
68
|
+
// '@typescript-eslint/no-duplicate-imports': 'error', 兼容 @typescript-eslint/eslint-plugin@6
|
|
69
|
+
'@typescript-eslint/no-extra-non-null-assertion': 'error',
|
|
70
|
+
'@typescript-eslint/prefer-for-of': 'error',
|
|
71
|
+
'@typescript-eslint/prefer-function-type': 'error',
|
|
72
|
+
// '@typescript-eslint/prefer-includes': 'warn',
|
|
73
|
+
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
|
74
|
+
'@typescript-eslint/prefer-readonly': 'error',
|
|
75
|
+
'@typescript-eslint/prefer-regexp-exec': 'warn',
|
|
76
|
+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
|
|
77
|
+
'@typescript-eslint/promise-function-async': 'off',
|
|
78
|
+
'@typescript-eslint/require-array-sort-compare': 'off',
|
|
79
|
+
'@typescript-eslint/restrict-plus-operands': 'warn',
|
|
80
|
+
'@typescript-eslint/dot-notation': ['error', {
|
|
81
|
+
allowIndexSignaturePropertyAccess: true
|
|
82
|
+
}],
|
|
83
|
+
semi: 'off',
|
|
84
|
+
'@typescript-eslint/semi': 'error',
|
|
85
|
+
'@typescript-eslint/strict-boolean-expressions': 'off',
|
|
86
|
+
'@typescript-eslint/triple-slash-reference': 'error',
|
|
87
|
+
'@typescript-eslint/type-annotation-spacing': 'error',
|
|
88
|
+
'@typescript-eslint/unbound-method': 'off',
|
|
89
|
+
'@typescript-eslint/unified-signatures': 'warn',
|
|
90
|
+
'@typescript-eslint/ban-ts-comment': [
|
|
91
|
+
'warn',
|
|
92
|
+
{
|
|
93
|
+
'ts-expect-error': 'allow-with-description',
|
|
94
|
+
'ts-ignore': 'allow-with-description',
|
|
95
|
+
'ts-nocheck': 'allow-with-description',
|
|
96
|
+
'ts-check': 'allow-with-description'
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
'@typescript-eslint/quotes': [
|
|
100
|
+
'error',
|
|
101
|
+
'single',
|
|
102
|
+
{ avoidEscape: true }
|
|
103
|
+
],
|
|
104
|
+
quotes: 'off',
|
|
105
|
+
|
|
106
|
+
// 和TS的规则冲突
|
|
107
|
+
'no-undef': 'off',
|
|
108
|
+
'require-await': 'off',
|
|
109
|
+
'no-use-before-define': 'off',
|
|
110
|
+
'no-dupe-class-members': 'off',
|
|
111
|
+
'no-duplicate-imports': 'off',
|
|
112
|
+
'no-useless-constructor': 'off',
|
|
113
|
+
'no-redeclare': 'off',
|
|
114
|
+
'dot-notation': 'off'
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
package/ts.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const merge = require('lodash/merge');
|
|
2
|
+
const tsConfig = require('./rules/ts');
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
overrides: [
|
|
6
|
+
merge({
|
|
7
|
+
files: ['*.ts', '*.tsx'],
|
|
8
|
+
parser: '@typescript-eslint/parser',
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaFeatures: {
|
|
11
|
+
jsx: true
|
|
12
|
+
},
|
|
13
|
+
project: './**/tsconfig.json'
|
|
14
|
+
},
|
|
15
|
+
plugins: ['@typescript-eslint']
|
|
16
|
+
}, tsConfig)
|
|
17
|
+
]
|
|
18
|
+
};
|