8000 guide: import/extensions rule documentation · odongohcoder2019/javascript@9890b40 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9890b40

Browse files
cainljharb
authored andcommitted
guide: import/extensions rule documentation
1 parent 3493b06 commit 9890b40

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,23 @@ Other Style Guides
14411441
import barCss from 'bar.css';
14421442
```
14431443

1444+
<a name="modules--import-extensions"></a>
1445+
- [10.10](#modules--import-extensions) Do not include JavaScript filename extensions
1446+
eslint: [`import/extensions`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md)
1447+
> Why? Including extensions inhibits refactoring, and inappropriately hardcodes implementation details of the module you're importing in every consumer.
1448+
1449+
```javascript
1450+
// bad
1451+
import foo from './foo.js';
1452+
import bar from './bar.jsx';
1453+
import baz from './baz/index.jsx';
1454+
1455+
// good
1456+
import foo from './foo';
1457+
import bar from './bar';
1458+
import baz from './baz';
1459+
```
1460+
14441461
**[⬆ back to top](#table-of-contents)**
14451462
14461463
## Iterators and Generators

0 commit comments

Comments
 (0)
0