Skip to content

Commit a1d1d89

Browse files
Added 'eslint-plugin-import' lint rules (#2365)
1 parent bde5e4a commit a1d1d89

File tree

3 files changed

+340
-9
lines changed

3 files changed

+340
-9
lines changed

.eslintrc.yml

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ env:
77
reportUnusedDisableDirectives: true
88
plugins:
99
- flowtype
10+
- import
1011

1112
rules:
13+
##############################################################################
1214
# `eslint-plugin-flowtype` rule list based on `v4.6.x`
1315
# https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype
16+
##############################################################################
1417

1518
flowtype/array-style-complex-type: error
1619
flowtype/array-style-simple-type: error
@@ -55,9 +58,66 @@ rules:
5558
flowtype/space-before-type-colon: off
5659
flowtype/union-intersection-spacing: off
5760

58-
##################################################
61+
##############################################################################
62+
# `eslint-plugin-import` rule list based on `v2.20.x`
63+
# https://github.com/benmosher/eslint-plugin-import
64+
##############################################################################
65+
66+
# Static analysis
67+
# https://github.com/benmosher/eslint-plugin-import#static-analysis
68+
import/no-unresolved: error
69+
import/named: error
70+
import/default: error
71+
import/namespace: error
72+
import/no-restricted-paths: off
73+
import/no-absolute-path: error
74+
import/no-dynamic-require: error
75+
import/no-internal-modules: off
76+
import/no-webpack-loader-syntax: error
77+
import/no-self-import: error
78+
import/no-cycle: off # TODO
79+
import/no-useless-path-segments: off # TODO
80+
import/no-relative-parent-imports: off
81+
82+
# Helpful warnings
83+
# https://github.com/benmosher/eslint-plugin-import#helpful-warnings
84+
import/export: error
85+
import/no-named-as-default: error
86+
import/no-named-as-default-member: error
87+
import/no-deprecated: error
88+
import/no-extraneous-dependencies: error
89+
import/no-mutable-exports: error
90+
import/no-unused-modules: error
91+
92+
# Module systems
93+
# https://github.com/benmosher/eslint-plugin-import#module-systems
94+
import/unambiguous: error
95+
import/no-commonjs: error
96+
import/no-amd: error
97+
import/no-nodejs-modules: error
98+
99+
# Style guide
100+
# https://github.com/benmosher/eslint-plugin-import#style-guide
101+
import/first: off # TODO
102+
import/exports-last: off
103+
import/no-duplicates: error
104+
import/no-namespace: error
105+
import/extensions: [error, never] # TODO: switch to ignorePackages
106+
import/order: off # TODO
107+
import/newline-after-import: error
108+
import/prefer-default-export: off
109+
import/max-dependencies: off
110+
import/no-unassigned-import: error
111+
import/no-named-default: error
112+
import/no-default-export: off
113+
import/no-named-export: off
114+
import/no-anonymous-default-export: error
115+
import/group-exports: off
116+
import/dynamic-import-chunkname: off
117+
118+
##############################################################################
59119
# ESLint builtin rules list based on `v6.8.x`
60-
##################################################
120+
##############################################################################
61121

62122
# Possible Errors
63123
# https://eslint.org/docs/rules/#possible-errors
@@ -361,13 +421,17 @@ rules:
361421
yield-star-spacing: off
362422

363423
overrides:
364-
- files: '**/__tests__/**'
424+
- files: '**/__*__/**'
365425
rules:
426+
import/no-nodejs-modules: off
366427
no-restricted-syntax: off
367428
- files: 'resources/**'
368429
parserOptions:
369430
sourceType: script
370431
rules:
432+
import/no-dynamic-require: off
433+
import/no-nodejs-modules: off
434+
import/no-commonjs: off
371435
no-await-in-loop: off
372436
no-restricted-syntax: off
373437
no-console: off

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"dtslint": "2.0.5",
5656
"eslint": "6.8.0",
5757
"eslint-plugin-flowtype": "4.6.0",
58+
"eslint-plugin-import": "2.20.0",
5859
"flow-bin": "0.116.0",
5960
"mocha": "7.0.0",
6061
"nyc": "15.0.0",

0 commit comments

Comments
 (0)