1 | module.exports = {
|
2 | env: {
|
3 | es6: true,
|
4 | },
|
5 | parserOptions: {
|
6 | ecmaVersion: 6,
|
7 | sourceType: 'module',
|
8 | },
|
9 | plugins: [
|
10 | 'import',
|
11 | ],
|
12 |
|
13 | settings: {
|
14 | 'import/resolver': {
|
15 | node: {
|
16 | extensions: ['.js', '.json'],
|
17 | },
|
18 | },
|
19 | 'import/extensions': [
|
20 | '.js',
|
21 | '.jsx',
|
22 | ],
|
23 | 'import/core-modules': [
|
24 | ],
|
25 | 'import/ignore': [
|
26 | 'node_modules',
|
27 | '\\.(coffee|scss|css|less|hbs|svg|json)$',
|
28 | ],
|
29 | },
|
30 |
|
31 | rules: {
|
32 | // Static analysis:
|
33 |
|
34 | // ensure imports point to files/modules that can be resolved
|
35 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
|
36 | 'import/no-unresolved': ['error', { commonjs: true, caseSensitive: true }],
|
37 |
|
38 | // ensure named imports coupled with named exports
|
39 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it
|
40 | 'import/named': 'off',
|
41 |
|
42 | // ensure default import coupled with default export
|
43 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it
|
44 | 'import/default': 'off',
|
45 |
|
46 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md
|
47 | 'import/namespace': 'off',
|
48 |
|
49 | // Helpful warnings:
|
50 |
|
51 | // disallow invalid exports, e.g. multiple defaults
|
52 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md
|
53 | 'import/export': 'error',
|
54 |
|
55 | // do not allow a default import name to match a named export
|
56 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
|
57 | 'import/no-named-as-default': 'error',
|
58 |
|
59 | // warn on accessing default export property names that are also named exports
|
60 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
|
61 | 'import/no-named-as-default-member': 'error',
|
62 |
|
63 | // disallow use of jsdoc-marked-deprecated imports
|
64 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
|
65 | 'import/no-deprecated': 'off',
|
66 |
|
67 | // Forbid the use of extraneous packages
|
68 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
|
69 | // paths are treated both as absolute paths, and relative to process.cwd()
|
70 | 'import/no-extraneous-dependencies': ['error', {
|
71 | devDependencies: [
|
72 | // tape, common npm pattern
|
73 | 'test/**',
|
74 | // also common npm pattern
|
75 | 'tests/**',
|
76 | // mocha, rspec-like pattern
|
77 | 'spec/**',
|
78 | // jest pattern
|
79 | '**/__tests__/**',
|
80 | // repos with a single test file
|
81 | 'test.js',
|
82 | // repos with multiple top-level test files
|
83 | 'test-*.js',
|
84 | // tests where the extension denotes that it is a test
|
85 | '**/*.test.js',
|
86 | // webpack config
|
87 | '**/webpack.config.js',
|
88 | // webpack config
|
89 | '**/webpack.config.*.js',
|
90 | // rollup config
|
91 | '**/rollup.config.js',
|
92 | // gulp config
|
93 | '**/gulpfile.js',
|
94 | // gulp config
|
95 | '**/gulpfile.*.js',
|
96 | // grunt config
|
97 | '**/Gruntfile',
|
98 | ],
|
99 | optionalDependencies: false,
|
100 | }],
|
101 |
|
102 | // Forbid mutable exports
|
103 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
|
104 | 'import/no-mutable-exports': 'error',
|
105 |
|
106 | // Module systems:
|
107 |
|
108 | // disallow require()
|
109 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
|
110 | 'import/no-commonjs': 'off',
|
111 |
|
112 | // disallow AMD require/define
|
113 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md
|
114 | 'import/no-amd': 'error',
|
115 |
|
116 | // No Node.js builtin modules
|
117 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
|
118 | 'import/no-nodejs-modules': 'off',
|
119 |
|
120 | // Style guide:
|
121 |
|
122 | // disallow non-import statements appearing before import statements
|
123 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md
|
124 | 'import/first': ['error', 'absolute-first'],
|
125 |
|
126 | // disallow non-import statements appearing before import statements
|
127 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md
|
128 | // deprecated: use `import/first`
|
129 | 'import/imports-first': 'off',
|
130 |
|
131 | // disallow duplicate imports
|
132 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
|
133 | 'import/no-duplicates': 'error',
|
134 |
|
135 | // disallow namespace imports
|
136 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md
|
137 | 'import/no-namespace': 'error',
|
138 |
|
139 | // Ensure consistent use of file extension within the import path
|
140 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
|
141 | 'import/extensions': ['error', 'always', {
|
142 | js: 'never',
|
143 | jsx: 'never',
|
144 | }],
|
145 |
|
146 | // Enforce a convention in module import order
|
147 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
|
148 | 'import/order': ['warn', {
|
149 | groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
|
150 | 'newlines-between': 'always-and-inside-groups',
|
151 | }],
|
152 |
|
153 | // Require a newline after the last import/require in a group
|
154 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
|
155 | 'import/newline-after-import': 'error',
|
156 |
|
157 | // Require modules with a single export to use a default export
|
158 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
|
159 | 'import/prefer-default-export': 'error',
|
160 |
|
161 | // Restrict which files can be imported in a given folder
|
162 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md
|
163 | 'import/no-restricted-paths': 'off',
|
164 |
|
165 | // Forbid modules to have too many dependencies
|
166 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md
|
167 | 'import/max-dependencies': ['off', { max: 10 }],
|
168 |
|
169 | // Forbid import of modules using absolute paths
|
170 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md
|
171 | 'import/no-absolute-path': 'error',
|
172 |
|
173 | // Forbid require() calls with expressions
|
174 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
|
175 | 'import/no-dynamic-require': 'warn',
|
176 |
|
177 | // prevent importing the submodules of other modules
|
178 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md
|
179 | 'import/no-internal-modules': ['off', {
|
180 | allow: [],
|
181 | }],
|
182 |
|
183 | // Warn if a module could be mistakenly parsed as a script by a consumer
|
184 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/unambiguous.md
|
185 | 'import/unambiguous': 'off',
|
186 |
|
187 | // Forbid Webpack loader syntax in imports
|
188 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md
|
189 | 'import/no-webpack-loader-syntax': 'error',
|
190 |
|
191 | // Prevent unassigned imports
|
192 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md
|
193 | // importing for side effects is perfectly acceptable, if you need side effects.
|
194 | 'import/no-unassigned-import': 'off',
|
195 |
|
196 | // Prevent importing the default as if it were named
|
197 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md
|
198 | 'import/no-named-default': 'error',
|
199 | },
|
200 | };
|