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