[eslint config] [breaking] add no-duplicate-imports rule.

This commit is contained in:
Jordan Harband
2016-03-26 22:42:29 -07:00
parent 5ce6fb1eae
commit 24565121c1
2 changed files with 24 additions and 0 deletions

View File

@@ -1075,6 +1075,27 @@ Other Style Guides
export default es6;
```
<a name="modules--no-duplicate-imports"></a>
- [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

View File

@@ -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,