-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
feat!: Start using enhanced-resolve
to improve ts support
#139
Conversation
3ccd883
to
8e0dcb7
Compare
9510597
to
aa800e5
Compare
{ | ||
// name: '.js has a higher priority than .json' | ||
filename: fixture("test.js"), | ||
code: "import './multi'", | ||
output: null, | ||
output: "import './multi.js'", | ||
options: ["always"], | ||
errors: [ | ||
{ messageId: "requireExt", data: { ext: ".cjs or .mjs" } }, | ||
], | ||
errors: [{ messageId: "requireExt", data: { ext: ".js" } }], | ||
}, | ||
{ | ||
filename: fixture("test.js"), | ||
code: "import './multi.js'", | ||
output: null, | ||
options: ["never"], | ||
errors: [{ messageId: "forbidExt", data: { ext: ".js" } }], | ||
}, | ||
{ | ||
filename: fixture("test.js"), | ||
code: "import './multi.cjs'", | ||
code: "import './multi.json'", | ||
output: null, | ||
options: ["never"], | ||
errors: [{ messageId: "forbidExt", data: { ext: ".cjs" } }], | ||
errors: [{ messageId: "forbidExt", data: { ext: ".json" } }], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These multi tests did not make sense, as you cant import .cjs
or .mjs
files without a file extension. (that I know of / found)
I have thus swapped the test to use .js
and .json
.
This means that we can use the correct import priority as a fixer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if suggestion
would be more appropriate: https://eslint.org/docs/latest/extend/custom-rules#providing-suggestions
generally, it's a best practice to not change the runtime behavior in fixers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 We can try to do that!
if (isBuiltin(this.name)) { | ||
return "node" | ||
} | ||
|
||
if (/^(@[\w~-][\w.~-]*\/)?[\w~-][\w.~-]*/.test(this.name)) { | ||
return "npm" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what to do with these when people use the @organisation/package
in path aliases.
enhanced-resolve
to improve ts support
This comment was marked as outdated.
This comment was marked as outdated.
I was waiting for eslint v9 to be released, and to see if there are some other breaking changes needed. It's fine to put it in one PR. I'll review it later, sorry for the delay. :😏 |
Ah cool! That makes complete sense 😁 I was just thinking about this comment #147 (comment). More specifically about trying to implement the You're 100% right, I can hold my horses though, stability is far more important! |
{ | ||
// name: '.js has a higher priority than .json' | ||
filename: fixture("test.js"), | ||
code: "import './multi'", | ||
output: null, | ||
output: "import './multi.js'", | ||
options: ["always"], | ||
errors: [ | ||
{ messageId: "requireExt", data: { ext: ".cjs or .mjs" } }, | ||
], | ||
errors: [{ messageId: "requireExt", data: { ext: ".js" } }], | ||
}, | ||
{ | ||
filename: fixture("test.js"), | ||
code: "import './multi.js'", | ||
output: null, | ||
options: ["never"], | ||
errors: [{ messageId: "forbidExt", data: { ext: ".js" } }], | ||
}, | ||
{ | ||
filename: fixture("test.js"), | ||
code: "import './multi.cjs'", | ||
code: "import './multi.json'", | ||
output: null, | ||
options: ["never"], | ||
errors: [{ messageId: "forbidExt", data: { ext: ".cjs" } }], | ||
errors: [{ messageId: "forbidExt", data: { ext: ".json" } }], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if suggestion
would be more appropriate: https://eslint.org/docs/latest/extend/custom-rules#providing-suggestions
generally, it's a best practice to not change the runtime behavior in fixers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking forward to the improved support!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome work, thanks for doing this!
The changes look good; let's merge them when we are preparing for the v17 release in our development.
looks we have a conflict now. @scagood |
mmmm, its not a simple merge. I will rebase later 😂 |
Co-authored-by: Sebastian Good <[email protected]>
Bumps [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) from 16.6.2 to 17.1.0. - [Release notes](https://github.com/eslint-community/eslint-plugin-n/releases) - [Changelog](https://github.com/eslint-community/eslint-plugin-n/blob/master/CHANGELOG.md) - [Commits](eslint-community/eslint-plugin-n@16.6.2...v17.1.0) --- updated-dependencies: - dependency-name: eslint-plugin-n dependency-type: direct:development update-type: version-update:semver-major ... BREAKING CHANGES: - drop eslint v7 & node.js < 18 (eslint-community/eslint-plugin-n#161) (eslint-community/eslint-plugin-n@41ceed7) - Start using enhanced-resolve to improve ts support (eslint-community/eslint-plugin-n#139) (eslint-community/eslint-plugin-n@dc9f473) - rename rule shebang => hashbang, deprecate rule shebang (eslint-community/eslint-plugin-n#198) Signed-off-by: dependabot[bot] <[email protected]>
Bumps [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) from 16.6.2 to 17.1.0. - [Release notes](https://github.com/eslint-community/eslint-plugin-n/releases) - [Changelog](https://github.com/eslint-community/eslint-plugin-n/blob/master/CHANGELOG.md) - [Commits](eslint-community/eslint-plugin-n@16.6.2...v17.1.0) --- updated-dependencies: - dependency-name: eslint-plugin-n dependency-type: direct:development update-type: version-update:semver-major ... BREAKING CHANGES: - drop eslint v7 & node.js < 18 (eslint-community/eslint-plugin-n#161) (eslint-community/eslint-plugin-n@41ceed7) - Start using enhanced-resolve to improve ts support (eslint-community/eslint-plugin-n#139) (eslint-community/eslint-plugin-n@dc9f473) - rename rule shebang => hashbang, deprecate rule shebang (eslint-community/eslint-plugin-n#198) Signed-off-by: dependabot[bot] <[email protected]>
This PR is going to aim to:
I am going to be making the following changes:
enhanced-resolve
import-target