mirror of
https://github.com/airbnb/javascript.git
synced 2026-04-25 03:00:19 -04:00
guide: import/extensions rule documentation
This commit is contained in:
committed by
Jordan Harband
parent
3493b060ec
commit
9890b40677
17
README.md
17
README.md
@@ -1441,6 +1441,23 @@ Other Style Guides
|
||||
import barCss from 'bar.css';
|
||||
```
|
||||
|
||||
<a name="modules--import-extensions"></a>
|
||||
- [10.10](#modules--import-extensions) Do not include JavaScript filename extensions
|
||||
eslint: [`import/extensions`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md)
|
||||
> Why? Including extensions inhibits refactoring, and inappropriately hardcodes implementation details of the module you're importing in every consumer.
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
import foo from './foo.js';
|
||||
import bar from './bar.jsx';
|
||||
import baz from './baz/index.jsx';
|
||||
|
||||
// good
|
||||
import foo from './foo';
|
||||
import bar from './bar';
|
||||
import baz from './baz';
|
||||
```
|
||||
|
||||
**[⬆ back to top](#table-of-contents)**
|
||||
|
||||
## Iterators and Generators
|
||||
|
||||
Reference in New Issue
Block a user