diff --git a/README.md b/README.md index 6013998b..8233e491 100644 --- a/README.md +++ b/README.md @@ -1075,6 +1075,27 @@ Other Style Guides export default es6; ``` + + - [10.4](#modules--no-duplicate-imports) Only import from a path in one place. + eslint: [`no-duplicate-imports`](http://eslint.org/docs/rules/no-duplicate-imports) + > Why? Having multiple lines that import from the same path can make code harder to maintain. + + ```javascript + // bad + import foo from 'foo'; + // … some other imports … // + import { named1, named2 } from 'foo'; + + // good + import foo, { named1, named2 } from 'foo'; + + // good + import foo, { + named1, + named2, + } from 'foo'; + ``` + **[⬆ back to top](#table-of-contents)** ## Iterators and Generators diff --git a/packages/eslint-config-airbnb/rules/es6.js b/packages/eslint-config-airbnb/rules/es6.js index a26e49d9..78a43b94 100644 --- a/packages/eslint-config-airbnb/rules/es6.js +++ b/packages/eslint-config-airbnb/rules/es6.js @@ -35,6 +35,9 @@ module.exports = { }], // disallow modifying variables that are declared using const 'no-const-assign': 2, + // disallow importing from the same path more than once + // http://eslint.org/docs/rules/no-duplicate-imports + 'no-duplicate-imports': 2, // disallow symbol constructor // http://eslint.org/docs/rules/no-new-symbol 'no-new-symbol': 2,