Compatibility with planned node.js native ESM import resolution
See original GitHub issueIt appears that the node.js plan for native ESM is that file extensions will be mandatory. This directly conflicts with current xo
rules import/extensions
and unicorn/import-index
. I’m opening this ticket to start the discussion about how/when xo
should deal with this.
It appears that import/extensions only applies to import
statements and not require
. If/when proposal-pkg-exports sees progress import/extensions
may need to be updated. unicorn/import-index applies to both import
and require
, might need an option so it can be applied to require
only if that is desired. Might also need/want a rule that forbids direct import of the package main source.
In one of my private projects that is targeting ESM I have the following xo.rules in my package.json:
"import/extensions": [
"error",
"always",
{
"ignorePackages": true
}
],
"unicorn/import-index": "off"
Personally I’m not a fan of this but I feel like the decision has already been made.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:12 (9 by maintainers)
Hello! Is there a tool that can be used to automatically patch existing codebases by resolving old node syntax and replace it with mandatory file extensions?
Ideally XO should automatically disable those rules on modules (i.e.
type: "module"
directories and.mjs
files)