From 9890b4067700be1f2d045788f4ea5fbf12b5f8bf Mon Sep 17 00:00:00 2001 From: Cain Hall Date: Mon, 2 Mar 2020 16:27:57 +1100 Subject: [PATCH] guide: import/extensions rule documentation --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index ed145f3f17..f18c47b4b7 100644 --- a/README.md +++ b/README.md @@ -1441,6 +1441,23 @@ Other Style Guides import barCss from 'bar.css'; ``` + + - [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