Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Add node ESM behaviour in import/extensions #2748

Merged
merged 1 commit into from Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.