mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-14 03:48:00 -05:00
[eslint config] [breaking] add no-duplicate-imports rule.
This commit is contained in:
21
README.md
21
README.md
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user