Skip to content
This repository was archived by the owner on Mar 7, 2019. It is now read-only.

Commit 47ac08e

Browse files
EPIC: Add eslint-plugin-imports 💪
1 parent 2c05172 commit 47ac08e

File tree

5 files changed

+68
-4
lines changed

5 files changed

+68
-4
lines changed

‎coding-styles/base.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ module.exports = {
377377
'wrap-iife': [1, 'inside'],
378378

379379
// Enforce spacing around the * in `yield*` expressions
380-
'yield-star-spacing': [1, 'after']
380+
'yield-star-spacing': [1, 'after'],
381+
382+
// Enforces having an empty line after the last top-level import statement or require call
383+
'import/newline-after-import': 1
381384
}
382385
}

‎environments/react/known-errors.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ module.exports = {
6161
// Prevent missing React when using JSX
6262
// When using JSX, <a /> expands to React.createElement("a"). Therefore the React variable must
6363
// be in scope.
64-
'react/react-in-jsx-scope': 2
64+
'react/react-in-jsx-scope': 2,
65+
66+
// Forbid Webpack loader syntax in imports
67+
// This syntax is non-standard, so it couples the code to Webpack. The recommended way to
68+
// specify Webpack loader configuration is in a Webpack configuration file.
69+
'import/no-webpack-loader-syntax': 2
6570
}
6671
}

‎package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
},
99
"contributors": [],
1010
"dependencies": {
11+
"eslint-plugin-import": "^2.0.0",
1112
"eslint-plugin-react": "^6.3.0"
1213
},
1314
"engines": {},

‎standard/best-practices.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,23 @@ module.exports = {
278278
// While there are no performance differences between the two approaches, the byte savings and
279279
// conciseness of the object literal form is what has made it the de facto way of creating new
280280
// objects.
281-
'no-new-object': 1
281+
'no-new-object': 1,
282+
283+
// Reports use of an exported name as the locally imported name of a default export
284+
'import/no-named-as-default': 1,
285+
286+
// Reports use of an exported name as a property on the default export
287+
// Accessing a property that has a name that is shared by an exported name from the same module
288+
// is likely to be a mistake.
289+
'import/no-named-as-default-member': 1,
290+
291+
// This rule reports any imports that come after non-import statements
292+
'import/first': 1,
293+
294+
// Reports if a resolved path is imported more than once
295+
'import/no-duplicates': 1,
296+
297+
// Ensure consistent use of file extension within the import path
298+
'import/extensions': [1, 'never']
282299
}
283300
}

‎standard/known-errors.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
'use strict'
1010

1111
module.exports = {
12+
plugins: [
13+
'import'
14+
],
15+
16+
settings: {
17+
'import/extensions': ['.js', 'jsx', '.es']
18+
},
19+
1220
rules: {
1321
// Disallow Assignment in Conditional Statements
1422
// This rule is aimed at eliminating ambiguous assignments in for, if, while, and do...while
@@ -327,6 +335,36 @@ module.exports = {
327335
}],
328336

329337
// Disallow generator functions that do not have yield
330-
'require-yield': 2
338+
'require-yield': 2,
339+
340+
// Ensure an imported module can be resolved to a module on the local filesystem
341+
'import/no-unresolved': [2, {
342+
commonjs: true
343+
}],
344+
345+
// Verifies that all named imports are part of the set of named exports in the referenced module
346+
'import/named': 2,
347+
348+
// If a default import is requested, this rule will report if there is no default export in the
349+
// imported module
350+
'import/default': 2,
351+
352+
// Enforces names exist at the time they are dereferenced, when imported as a full namespace
353+
'import/namespace': 2,
354+
355+
// Forbid import of modules using absolute paths
356+
// Node.js allows the import of modules using an absolute path such as */home/xyz/file.js*. That
357+
// is a bad practice as it ties the code using it to your computer.
358+
'import/no-absolute-path': 2,
359+
360+
// Reports funny business with exports, like repeated exports of names or defaults
361+
'import/export': 2,
362+
363+
// Forbid the use of extraneous packages
364+
// Forbid the import of external modules that are not declared in package.json.
365+
'import/no-extraneous-dependencies': 2,
366+
367+
// Forbid the use of mutable exports with var or let
368+
'import/no-mutable-exports': 2
331369
}
332370
}

0 commit comments

Comments
 (0)