@huangjunsen/eslint-config 1.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.
Files changed (57) hide show
  1. package/.editorconfig +17 -0
  2. package/.eslintignore +17 -0
  3. package/.eslintrc.js +5 -0
  4. package/LICENSE +21 -0
  5. package/README.md +286 -0
  6. package/__tests__/fixtures/es5.js +4 -0
  7. package/__tests__/fixtures/index.js +3 -0
  8. package/__tests__/fixtures/node.js +24 -0
  9. package/__tests__/fixtures/react-display-name.js +7 -0
  10. package/__tests__/fixtures/react.jsx +132 -0
  11. package/__tests__/fixtures/ts-import-a.ts +3 -0
  12. package/__tests__/fixtures/ts-import-b.ts +3 -0
  13. package/__tests__/fixtures/ts-node.ts +20 -0
  14. package/__tests__/fixtures/ts-react.tsx +27 -0
  15. package/__tests__/fixtures/ts-vue.vue +36 -0
  16. package/__tests__/fixtures/ts.ts +17 -0
  17. package/__tests__/fixtures/tsconfig.json +8 -0
  18. package/__tests__/fixtures/use-babel-eslint.jsx +170 -0
  19. package/__tests__/fixtures/vue.vue +16 -0
  20. package/__tests__/use-babel-eslint.test.js +47 -0
  21. package/__tests__/validate-js-configs.test.js +259 -0
  22. package/__tests__/validate-ts-configs.test.js +263 -0
  23. package/es5.js +10 -0
  24. package/essential/es5.js +12 -0
  25. package/essential/index.js +12 -0
  26. package/essential/react.js +76 -0
  27. package/essential/rules/blacklist.js +48 -0
  28. package/essential/rules/es6-blacklist.js +62 -0
  29. package/essential/rules/set-style-to-warn.js +30 -0
  30. package/essential/rules/ts-blacklist.js +15 -0
  31. package/essential/typescript/index.js +7 -0
  32. package/essential/typescript/react.js +7 -0
  33. package/essential/typescript/vue.js +9 -0
  34. package/essential/vue.js +8 -0
  35. package/index.js +23 -0
  36. package/jsx-a11y.js +5 -0
  37. package/node.js +6 -0
  38. package/package.json +48 -0
  39. package/react.js +11 -0
  40. package/rules/base/best-practices.js +284 -0
  41. package/rules/base/es6.js +168 -0
  42. package/rules/base/possible-errors.js +126 -0
  43. package/rules/base/strict.js +6 -0
  44. package/rules/base/style.js +445 -0
  45. package/rules/base/variables.js +48 -0
  46. package/rules/es5.js +11 -0
  47. package/rules/imports.js +167 -0
  48. package/rules/jsx-a11y.js +23 -0
  49. package/rules/node.js +11 -0
  50. package/rules/react.js +354 -0
  51. package/rules/typescript.js +807 -0
  52. package/rules/vue.js +96 -0
  53. package/typescript/index.js +6 -0
  54. package/typescript/node.js +6 -0
  55. package/typescript/react.js +6 -0
  56. package/typescript/vue.js +10 -0
  57. package/vue.js +10 -0
@@ -0,0 +1,445 @@
1
+ module.exports = {
2
+ rules: {
3
+ // 强制在数组开括号后和闭括号前换行
4
+ 'array-bracket-newline': 'off',
5
+
6
+ // 方括号内部两侧无空格-数组
7
+ 'array-bracket-spacing': ['error', 'never'],
8
+
9
+ // 强制数组元素间换行
10
+ 'array-element-newline': 'off',
11
+
12
+ // 单行代码块的大括号内部两侧有空格
13
+ 'block-spacing': ['error', 'always'],
14
+
15
+ // 大括号换行风格:one true brace style 风格,且单行代码块可不换行
16
+ 'brace-style': ['error', '1tbs', { allowSingleLine: true }],
17
+
18
+ // 使用小驼峰命名风格
19
+ camelcase: 'off',
20
+
21
+ // 强制或禁止对注释的第一个字母大写
22
+ 'capitalized-comments': 'off',
23
+
24
+ // 用逗号分隔的多行结构,始终加上最后一个逗号(单行不用)
25
+ 'comma-dangle': ['error', 'always-multiline'],
26
+
27
+ // 逗号的前面无空格,后面有空格
28
+ 'comma-spacing': ['error', { before: false, after: true }],
29
+
30
+ // 用逗号分隔的多行结构,将逗号放到行尾
31
+ 'comma-style': ['error', 'last'],
32
+
33
+ // 方括号内部两侧无空格-计算属性
34
+ 'computed-property-spacing': ['error', 'never'],
35
+
36
+ // 使用一致的 this 别名
37
+ 'consistent-this': 'off',
38
+
39
+ // 在文件末尾保留一行空行
40
+ 'eol-last': ['warn', 'always'],
41
+
42
+ // 函数名与调用它的括号间无空格
43
+ 'func-call-spacing': ['error', 'never'],
44
+
45
+ // 要求函数名与赋值给它们的变量名或属性名相匹配
46
+ 'func-name-matching': [
47
+ 'off',
48
+ 'always',
49
+ {
50
+ includeCommonJSModuleExports: false,
51
+ },
52
+ ],
53
+
54
+ // 要求或禁止命名的函数表达式
55
+ 'func-names': 'off',
56
+
57
+ // 强制只能使用函数声明或函数表达式
58
+ 'func-style': 'off',
59
+
60
+ // 在函数的小括号内使用一致的换行风格
61
+ 'function-paren-newline': ['error', 'consistent'],
62
+
63
+ // 禁用指定的标识符
64
+ 'id-blacklist': 'off',
65
+
66
+ // 强制标识符的最小和最大长度
67
+ 'id-length': 'off',
68
+
69
+ // 要求标识符匹配一个指定的正则表达式
70
+ 'id-match': 'off',
71
+
72
+ // 隐式返回的箭头函数体不要换行
73
+ // @reason 同 prettier 有冲突
74
+ 'implicit-arrow-linebreak': ['off', 'beside'],
75
+
76
+ // 使用 2 个空格缩进
77
+ // @unessential
78
+ indent: [
79
+ 'error',
80
+ 2,
81
+ {
82
+ SwitchCase: 1,
83
+ VariableDeclarator: 1,
84
+ outerIIFEBody: 1,
85
+ // MemberExpression: null,
86
+ FunctionDeclaration: {
87
+ parameters: 1,
88
+ body: 1,
89
+ },
90
+ FunctionExpression: {
91
+ parameters: 1,
92
+ body: 1,
93
+ },
94
+ CallExpression: {
95
+ arguments: 1,
96
+ },
97
+ ArrayExpression: 1,
98
+ ObjectExpression: 1,
99
+ ImportDeclaration: 1,
100
+ flatTernaryExpressions: false,
101
+ // list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js
102
+ ignoredNodes: [
103
+ 'JSXElement',
104
+ 'JSXElement > *',
105
+ 'JSXAttribute',
106
+ 'JSXIdentifier',
107
+ 'JSXNamespacedName',
108
+ 'JSXMemberExpression',
109
+ 'JSXSpreadAttribute',
110
+ 'JSXExpressionContainer',
111
+ 'JSXOpeningElement',
112
+ 'JSXClosingElement',
113
+ 'JSXText',
114
+ 'JSXEmptyExpression',
115
+ 'JSXSpreadChild',
116
+ ],
117
+ ignoreComments: false,
118
+ },
119
+ ],
120
+
121
+ // JSX 属性使用双引号,不要使用单引号
122
+ // @unessential
123
+ 'jsx-quotes': ['error', 'prefer-double'],
124
+
125
+ // 定义对象字面量时,key, value 之间有且只有一个空格
126
+ 'key-spacing': ['error', { beforeColon: false, afterColon: true }],
127
+
128
+ // 关键字前后各一个空格
129
+ 'keyword-spacing': [
130
+ 'error',
131
+ {
132
+ before: true,
133
+ after: true,
134
+ overrides: {
135
+ return: { after: true },
136
+ throw: { after: true },
137
+ case: { after: true },
138
+ },
139
+ },
140
+ ],
141
+
142
+ // 单行注释应单独一行写在被注释对象的上方,不要追加在某条语句的后面
143
+ 'line-comment-position': [
144
+ 'off',
145
+ {
146
+ position: 'above',
147
+ ignorePattern: '',
148
+ applyDefaultPatterns: true,
149
+ },
150
+ ],
151
+
152
+ // 指定 unix 或 windows 风格的换行符
153
+ 'linebreak-style': 'off',
154
+
155
+ // 类成员之间保留一个空行
156
+ 'lines-between-class-members': ['off', 'always', { exceptAfterSingleLine: false }],
157
+
158
+ // 要求在注释周围有空行
159
+ 'lines-around-comment': 'off',
160
+
161
+ // 控制语句的嵌套层级不要过深,不要超过 4 级
162
+ // @reason 适合做后置检查
163
+ 'max-depth': ['off', 4],
164
+
165
+ // 单行最大字符数:100
166
+ 'max-len': [
167
+ 'warn',
168
+ 100,
169
+ 2,
170
+ {
171
+ ignoreUrls: true,
172
+ ignoreComments: false,
173
+ ignoreRegExpLiterals: true,
174
+ ignoreStrings: true,
175
+ ignoreTemplateLiterals: true,
176
+ },
177
+ ],
178
+
179
+ // 文件最大行数:1000
180
+ // @reason 适合做后置检查
181
+ 'max-lines': [
182
+ 'off',
183
+ {
184
+ max: 1000,
185
+ skipBlankLines: true,
186
+ skipComments: true,
187
+ },
188
+ ],
189
+
190
+ // 函数最大行数:80
191
+ // @reason 适合做后置检查
192
+ 'max-lines-per-function': [
193
+ 'off',
194
+ {
195
+ max: 80,
196
+ skipBlankLines: true,
197
+ skipComments: true,
198
+ IIFEs: true,
199
+ },
200
+ ],
201
+
202
+ // 回调函数最大嵌套深度
203
+ 'max-nested-callbacks': 'off',
204
+
205
+ // 函数参数数量上限
206
+ 'max-params': ['off', 3],
207
+
208
+ // 函数块最多允许的的语句数量
209
+ 'max-statements': ['off', 10],
210
+
211
+ // 每一行中所允许的最大语句数量
212
+ 'max-statements-per-line': ['off', { max: 1 }],
213
+
214
+ // 多行注释的风格
215
+ 'multiline-comment-style': ['off', 'starred-block'],
216
+
217
+ // 要求或禁止在三元操作数中间换行
218
+ 'multiline-ternary': ['off', 'never'],
219
+
220
+ // 使用大驼峰风格命名类和构造函数
221
+ 'new-cap': [
222
+ 'error',
223
+ {
224
+ newIsCap: true,
225
+ newIsCapExceptions: [],
226
+ capIsNew: false,
227
+ capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'],
228
+ },
229
+ ],
230
+
231
+ // 禁止在调用构造函数时省略小括号
232
+ 'new-parens': 'error',
233
+
234
+ // 在长方法链式调用时进行换行
235
+ 'newline-per-chained-call': ['warn', { ignoreChainWithDepth: 4 }],
236
+
237
+ // 不要使用 new Array() 和 Array() 创建数组,除非为了构造某一长度的空数组。
238
+ 'no-array-constructor': 'error',
239
+
240
+ // 不要使用按位操作符
241
+ 'no-bitwise': 'warn',
242
+
243
+ // 禁用 continue 语句
244
+ 'no-continue': 'off',
245
+
246
+ // 禁止行内注释
247
+ 'no-inline-comments': 'off',
248
+
249
+ // 禁止 if 作为唯一语句出现在 else 中,此时应写成 else if
250
+ 'no-lonely-if': 'error',
251
+
252
+ // 混合使用多种操作符时,用小括号包裹分组
253
+ 'no-mixed-operators': [
254
+ 'error',
255
+ {
256
+ groups: [
257
+ ['%', '**'],
258
+ ['%', '+'],
259
+ ['%', '-'],
260
+ ['%', '*'],
261
+ ['%', '/'],
262
+ ['**', '+'],
263
+ ['**', '-'],
264
+ ['**', '*'],
265
+ ['**', '/'],
266
+ ['&', '|', '^', '~', '<<', '>>', '>>>'],
267
+ ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
268
+ ['&&', '||'],
269
+ ['in', 'instanceof'],
270
+ ],
271
+ allowSamePrecedence: false,
272
+ },
273
+ ],
274
+
275
+ // 不要混用空格和 tab
276
+ 'no-mixed-spaces-and-tabs': 'error',
277
+
278
+ // 禁止连续赋值
279
+ 'no-multi-assign': ['error'],
280
+
281
+ // 禁止出现多个(大于 2 个)连续空行
282
+ 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }],
283
+
284
+ // 禁用否定的表达式
285
+ 'no-negated-condition': 'off',
286
+
287
+ // 不要使用嵌套的三元表达式
288
+ 'no-nested-ternary': 'error',
289
+
290
+ // 使用字面量创建对象
291
+ 'no-new-object': 'error',
292
+
293
+ // 不要使用一元自增自减运算符
294
+ 'no-plusplus': ['off', { allowForLoopAfterthoughts: true }],
295
+
296
+ // 禁用特定的语法
297
+ 'no-restricted-syntax': 'off',
298
+
299
+ // 禁止使用 tab
300
+ 'no-tabs': 'error',
301
+
302
+ // 禁用三元操作符
303
+ 'no-ternary': 'off',
304
+
305
+ // 行尾不要留有空格
306
+ 'no-trailing-spaces': [
307
+ 'error',
308
+ {
309
+ skipBlankLines: false,
310
+ ignoreComments: false,
311
+ },
312
+ ],
313
+
314
+ // 命名不要以下划线开头或结尾
315
+ 'no-underscore-dangle': 'off',
316
+
317
+ // 避免不必要的三元表达式
318
+ 'no-unneeded-ternary': ['error', { defaultAssignment: false }],
319
+
320
+ // 禁止属性调用前有空格
321
+ 'no-whitespace-before-property': 'error',
322
+
323
+ // 省略大括号的单行语句前不要换行
324
+ 'nonblock-statement-body-position': ['error', 'beside', { overrides: {} }],
325
+
326
+ // 强制大括号内换行符的一致性
327
+ 'object-curly-newline': 'off',
328
+
329
+ // 大括号内部两侧有空格
330
+ 'object-curly-spacing': ['error', 'always'],
331
+
332
+ // 对象的属性需遵循一致的换行风格:即所有属性要么都换行,要么都写在一行
333
+ 'object-property-newline': [
334
+ 'error',
335
+ {
336
+ allowAllPropertiesOnSameLine: true,
337
+ },
338
+ ],
339
+
340
+ // 一条声明语句声明一个变量
341
+ 'one-var': ['error', 'never'],
342
+
343
+ // 一行声明一个变量
344
+ 'one-var-declaration-per-line': ['error', 'always'],
345
+
346
+ // 尽可能使用简写形式的赋值操作符
347
+ 'operator-assignment': ['warn', 'always'],
348
+
349
+ // 强制操作符使用一致的换行符
350
+ 'operator-linebreak': 'off',
351
+
352
+ // 块的开始和结束不能是空行
353
+ 'padded-blocks': ['warn', { blocks: 'never', classes: 'never', switches: 'never' }],
354
+
355
+ // 要求或禁止在语句间填充空行
356
+ 'padding-line-between-statements': 'off',
357
+
358
+ // 使用扩展运算符替代 Object.assign
359
+ 'prefer-object-spread': 'off',
360
+
361
+ // 对象字面量的属性名不要用引号包裹,除非包含特殊字符
362
+ 'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }],
363
+
364
+ // 字符串优先使用单引号
365
+ quotes: ['error', 'single', { avoidEscape: true }],
366
+
367
+ // 使用 JSDoc 注释
368
+ 'require-jsdoc': 'off',
369
+
370
+ // 使用分号
371
+ // @unessential
372
+ semi: ['error', 'always'],
373
+
374
+ // 分号的前面无空格,后面有空格
375
+ 'semi-spacing': ['error', { before: false, after: true }],
376
+
377
+ // 分号必须写在行尾
378
+ // @unessential
379
+ 'semi-style': ['error', 'last'],
380
+
381
+ // 要求对对象属性名排序
382
+ 'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }],
383
+
384
+ // 要求对变量声明排序
385
+ 'sort-vars': 'off',
386
+
387
+ // 块的左大括号前有一个空格
388
+ 'space-before-blocks': 'error',
389
+
390
+ // 函数声明时,对于命名函数,参数的小括号前无空格;对于匿名函数和 async 箭头函数,参数的小括号前有空格
391
+ 'space-before-function-paren': [
392
+ 'error',
393
+ {
394
+ anonymous: 'always',
395
+ named: 'never',
396
+ asyncArrow: 'always',
397
+ },
398
+ ],
399
+
400
+ // 小括号内部两侧无空格
401
+ 'space-in-parens': ['error', 'never'],
402
+
403
+ // 中缀操作符两侧有空格
404
+ 'space-infix-ops': 'error',
405
+
406
+ // 一元操作符两侧无空格,包括 -、+、--、++、!、!!
407
+ 'space-unary-ops': [
408
+ 'error',
409
+ {
410
+ words: true,
411
+ nonwords: false,
412
+ overrides: {},
413
+ },
414
+ ],
415
+
416
+ // 注释内容和注释符之间需留有一个空格
417
+ 'spaced-comment': [
418
+ 'error',
419
+ 'always',
420
+ {
421
+ line: {
422
+ exceptions: ['-', '+'],
423
+ markers: ['=', '!', '/'],
424
+ },
425
+ block: {
426
+ exceptions: ['-', '+'],
427
+ markers: ['=', '!'],
428
+ balanced: true,
429
+ },
430
+ },
431
+ ],
432
+
433
+ // switch 的 case 和 default 子句冒号前面无空格,后面有空格
434
+ 'switch-colon-spacing': ['error', { after: true, before: false }],
435
+
436
+ // 模板字符串的 tag 后面无空格
437
+ 'template-tag-spacing': ['error', 'never'],
438
+
439
+ // 要求或禁止 Unicode 字节顺序标记 (BOM)
440
+ 'unicode-bom': ['off', 'never'],
441
+
442
+ // 要求正则表达式被括号括起来
443
+ 'wrap-regex': 'off',
444
+ },
445
+ };
@@ -0,0 +1,48 @@
1
+ module.exports = {
2
+ // 预设的环境,使用这些环境中的全局变量不会被 no-undef 报错
3
+ // @link https://eslint.org/docs/user-guide/configuring#specifying-environments
4
+ env: {
5
+ browser: true,
6
+ es6: true,
7
+ jasmine: true,
8
+ jest: true,
9
+ jquery: true,
10
+ mocha: true,
11
+ node: true,
12
+ },
13
+ rules: {
14
+ // 强制或禁止在变量声明时进行赋值
15
+ 'init-declarations': 'off',
16
+
17
+ // 禁止 delete 变量
18
+ 'no-delete-var': 'error',
19
+
20
+ // 禁止标签与变量同名
21
+ 'no-label-var': 'error',
22
+
23
+ // 禁用使用特定的全局变量
24
+ 'no-restricted-globals': 'off',
25
+
26
+ // 禁止变量与外层作用域已存在的变量同名
27
+ // @unessential
28
+ 'no-shadow': 'error',
29
+
30
+ // 禁止使用保留字命名变量
31
+ 'no-shadow-restricted-names': 'error',
32
+
33
+ // 禁止使用未声明的变量
34
+ 'no-undef': 'error',
35
+
36
+ // 不要将变量初始化成 undefined
37
+ 'no-undef-init': 'error',
38
+
39
+ // 禁止使用 undefined
40
+ 'no-undefined': 'off',
41
+
42
+ // 声明的变量必须被使用
43
+ 'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
44
+
45
+ // 不要在声明前就使用变量
46
+ 'no-use-before-define': ['error', { functions: false, classes: false, variables: false }],
47
+ },
48
+ };
package/rules/es5.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * 本文件用于覆盖掉个别 ES5 与 ES6 不同的规则
3
+ */
4
+
5
+ module.exports = {
6
+ rules: {
7
+ // 逗号风格 - ES5 中不加最后一个逗号
8
+ // @unessential
9
+ 'comma-dangle': ['error', 'never'],
10
+ },
11
+ };
@@ -0,0 +1,167 @@
1
+ /**
2
+ * 本文件的规则由 eslint-plugin-import 提供
3
+ * 与 eslint-plugin-import 推荐配置对齐
4
+ * @see https://github.com/import-js/eslint-plugin-import
5
+ * @see https://github.com/import-js/eslint-plugin-import/blob/main/config/recommended.js
6
+ */
7
+
8
+ module.exports = {
9
+ plugins: [
10
+ 'import',
11
+ ],
12
+ settings: {
13
+ 'import/ignore': [
14
+ 'node_modules',
15
+ '\\.(coffee|scss|css|less|hbs|svg|json)$',
16
+ ],
17
+ },
18
+ rules: {
19
+ /**
20
+ * Static analysis
21
+ */
22
+
23
+ // ensure imports point to files/modules that can be resolved
24
+ 'import/no-unresolved': 'error',
25
+
26
+ // ensure named imports coupled with named exports
27
+ 'import/named': 'error',
28
+
29
+ // ensure default import coupled with default export
30
+ 'import/default': 'error',
31
+
32
+ // ensure imported namespaces contain dereferenced properties as they are dereferenced
33
+ 'import/namespace': 'error',
34
+
35
+ /**
36
+ * Helpful warnings
37
+ */
38
+
39
+ // disallow invalid exports, e.g. multiple defaults
40
+ 'import/export': 'error',
41
+
42
+ // import 一个文件时,禁止 default import 的名字跟文件内的命名 export 相同
43
+ 'import/no-named-as-default': 'error',
44
+
45
+ // 访问 default export 的属性时,如果该文件有与属性同名的命名 export,则给出警告
46
+ 'import/no-named-as-default-member': 'warn',
47
+
48
+ // disallow use of jsdoc-marked-deprecated imports
49
+ 'import/no-deprecated': 'off',
50
+
51
+ // Forbid the use of extraneous packages
52
+ 'import/no-extraneous-dependencies': 'off',
53
+
54
+ // Forbid mutable exports
55
+ 'import/no-mutable-exports': 'off',
56
+
57
+ /**
58
+ * Module systems
59
+ */
60
+
61
+ // Report potentially ambiguous parse goal (script vs. module)
62
+ 'import/unambiguous': 'off',
63
+
64
+ // disallow require()
65
+ 'import/no-commonjs': 'off',
66
+
67
+ // disallow AMD require/define
68
+ 'import/no-amd': 'warn',
69
+
70
+ // No Node.js builtin modules
71
+ 'import/no-nodejs-modules': 'off',
72
+
73
+ /**
74
+ * Style guide
75
+ */
76
+
77
+ // import 语句需要放到模块的最上方
78
+ // @unessential
79
+ 'import/first': 'error',
80
+
81
+ // 不要用多个 import 引入同一模块
82
+ 'import/no-duplicates': 'error',
83
+
84
+ // disallow namespace imports
85
+ 'import/no-namespace': 'off',
86
+
87
+ // Ensure consistent use of file extension within the import path
88
+ 'import/extensions': 'off',
89
+
90
+ // import 语句的排序
91
+ 'import/order': ['off', {
92
+ groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
93
+ 'newlines-between': 'never',
94
+ }],
95
+
96
+ // 在最后一个 import / require 语句后保留一个空行
97
+ 'import/newline-after-import': 'warn',
98
+
99
+ // 当模块内只有一个 export 时,使用 default export
100
+ 'import/prefer-default-export': 'off',
101
+
102
+ // Restrict which files can be imported in a given folder
103
+ 'import/no-restricted-paths': 'off',
104
+
105
+ // Forbid modules to have too many dependencies
106
+ 'import/max-dependencies': ['off', { max: 10 }],
107
+
108
+ // Forbid import of modules using absolute paths
109
+ 'import/no-absolute-path': 'off',
110
+
111
+ // Forbid require() calls with expressions
112
+ 'import/no-dynamic-require': 'off',
113
+
114
+ // prevent importing the submodules of other modules
115
+ 'import/no-internal-modules': ['off', {
116
+ allow: [],
117
+ }],
118
+
119
+ // Forbid Webpack loader syntax in imports
120
+ 'import/no-webpack-loader-syntax': 'off',
121
+
122
+ // Prevent unassigned imports
123
+ // importing for side effects is perfectly acceptable, if you need side effects.
124
+ 'import/no-unassigned-import': 'off',
125
+
126
+ // 禁止 import { default as foo } from './foo.js'
127
+ // 应写成 import foo from './foo.js'
128
+ 'import/no-named-default': 'off',
129
+
130
+ // Reports if a module's default export is unnamed
131
+ 'import/no-anonymous-default-export': ['off', {
132
+ allowArray: false,
133
+ allowArrowFunction: false,
134
+ allowAnonymousClass: false,
135
+ allowAnonymousFunction: false,
136
+ allowLiteral: false,
137
+ allowObject: false,
138
+ }],
139
+
140
+ // This rule enforces that all exports are declared at the bottom of the file.
141
+ 'import/exports-last': 'off',
142
+
143
+ // Prefer named exports to be grouped together in a single export declaration
144
+ 'import/group-exports': 'off',
145
+
146
+ // forbid default exports. this is a terrible rule, do not use it.
147
+ 'import/no-default-export': 'off',
148
+
149
+ // 不要产生自引用
150
+ 'import/no-self-import': 'error',
151
+
152
+ // 不要产生循环引用
153
+ 'import/no-cycle': ['error', { maxDepth: Infinity }],
154
+
155
+ // Ensures that there are no useless path segments
156
+ 'import/no-useless-path-segments': 'off',
157
+
158
+ // dynamic imports require a leading comment with a webpackChunkName
159
+ 'import/dynamic-import-chunkname': ['off', {
160
+ importFunctions: [],
161
+ webpackChunknameFormat: '[0-9a-zA-Z-_/.]+',
162
+ }],
163
+
164
+ // Use this rule to prevent imports to folders in relative parent paths.
165
+ 'import/no-relative-parent-imports': 'off',
166
+ },
167
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 本文件的规则由 eslint-plugin-jsx-a11y 提供
3
+ * @link https://github.com/evcohen/eslint-plugin-jsx-a11y
4
+ */
5
+
6
+ module.exports = {
7
+ plugins: ['jsx-a11y'],
8
+ rules: {
9
+ 'jsx-a11y/alt-text': 'warn',
10
+ 'jsx-a11y/img-redundant-alt': 'warn',
11
+ 'jsx-a11y/anchor-has-content': 'warn',
12
+ 'jsx-a11y/aria-props': 'warn',
13
+ 'jsx-a11y/aria-proptypes': 'warn',
14
+ 'jsx-a11y/aria-unsupported-elements': 'warn',
15
+ 'jsx-a11y/aria-role': ['warn', { ignoreNonDOM: true }], // ignoreNonDom 为 true 时不检查用户自定义元素
16
+ 'jsx-a11y/role-has-required-aria-props': 'warn',
17
+ 'jsx-a11y/role-supports-aria-props': 'warn',
18
+ 'jsx-a11y/iframe-has-title': 'warn',
19
+ 'jsx-a11y/no-access-key': 'warn',
20
+ 'jsx-a11y/no-distracting-elements': 'warn',
21
+ 'jsx-a11y/scope': 'warn',
22
+ },
23
+ };