Skip to content

Commit

Permalink
[Docs] extensions: reference node ESM behavior
Browse files Browse the repository at this point in the history
This behavior largely didn't change despite the functionality becoming more widely adopted. Even though the document assumes CJS, It's probably worth including at least a footnote about the resolver behaving differently for ESM.

See: #2043
  • Loading branch information
xM8WVqaG authored and ljharb committed Mar 25, 2023
1 parent 6be042b commit d2b10ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
### Changed
- [Docs] [`no-duplicates`]: fix example schema ([#2684], thanks [@simmo])
- [Docs] [`group-exports`]: fix syntax highlighting ([#2699], thanks [@devinrhode2])
- [Docs] [`extensions`]: reference node ESM behavior ([#2748], thanks [@xM8WVqaG])

## [2.27.5] - 2023-01-16

Expand Down Expand Up @@ -1067,6 +1068,7 @@ for info on changes for earlier releases.
[`memo-parser`]: ./memo-parser/README.md

[#2754]: https://github.com/import-js/eslint-plugin-import/pull/2754
[#2748]: https://github.com/import-js/eslint-plugin-import/pull/2748
[#2699]: https://github.com/import-js/eslint-plugin-import/pull/2699
[#2664]: https://github.com/import-js/eslint-plugin-import/pull/2664
[#2613]: https://github.com/import-js/eslint-plugin-import/pull/2613
Expand Down Expand Up @@ -1853,6 +1855,7 @@ for info on changes for earlier releases.
[@wKich]: https://github.com/wKich
[@wschurman]: https://github.com/wschurman
[@wtgtybhertgeghgtwtg]: https://github.com/wtgtybhertgeghgtwtg
[@xM8WVqaG]: https://github.com/xM8WVqaG
[@xpl]: https://github.com/xpl
[@yordis]: https://github.com/yordis
[@zloirock]: https://github.com/zloirock
4 changes: 3 additions & 1 deletion docs/rules/extensions.md
Expand Up @@ -2,7 +2,7 @@

<!-- end auto-generated rule header -->

Some file resolve algorithms allow you to omit the file extension within the import source path. For example the `node` resolver can resolve `./foo/bar` to the absolute path `/User/someone/foo/bar.js` because the `.js` extension is resolved automatically by default. Depending on the resolver you can configure more extensions to get resolved automatically.
Some file resolve algorithms allow you to omit the file extension within the import source path. For example the `node` resolver (which does not yet support ESM/`import`) can resolve `./foo/bar` to the absolute path `/User/someone/foo/bar.js` because the `.js` extension is resolved automatically by default in CJS. Depending on the resolver you can configure more extensions to get resolved automatically.

In order to provide a consistent use of file extensions across your code base, this rule can enforce or disallow the use of certain file extensions.

Expand Down Expand Up @@ -170,3 +170,5 @@ import foo from '@/foo';
## When Not To Use It

If you are not concerned about a consistent usage of file extension.

In the future, when this rule supports native node ESM resolution, and the plugin is configured to use native rather than transpiled ESM (a config option that is not yet available) - setting this to `always` will have no effect.

0 comments on commit d2b10ae

Please sign in to comment.