-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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: support TypeScript config using importx
#18440
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for docs-eslint canceled.
|
Co-authored-by: aryaemami59 <[email protected]>
Marking as a draft to avoid accidental merging, as there is an RFC being discussed. |
Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update. |
importx
Thanks for this PR, @antfu! In order to move forward with this pull request, we will need some unit tests to verify that TypeScript config files are being loaded as expected. My suggestion would be to start looking at these tests and add similar tests to check the behavior with packages that have config files with |
Oh, and can you have a look at the lint problems? You can run |
"./hash": hashStub | ||
}); | ||
const newLintResultCache = new NewLintResultCache(cacheFileLocation, "metadata"); | ||
const versionStub = sandbox.stub(process, "version").value(version); |
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.
This wasn't correctly restored, causing process.version
to always be the mocked value for sub-sequence tests.
const config = (await import(fileURL)).default; | ||
let config; | ||
|
||
if (isFileTS(filePath)) { |
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.
Because Node.js is the only runtime that can't load TypeScript natively, maybe we can also check that globalThis.Deno
and globalThis.Bun
are undefined before loading importx
?
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.
With register/module-loader like ts-node
or tsx
(the cli), or testing frameworks like Vitest, Node.js can load TypeScript - the goal for importx
is to cover those details, where ESLint or other users can be agnostic to runtime like Deno and Bun, while also could automatically work if we have yet another runtime in the future.
importx
already doing lazying loading internally - so importing importx
itself should be fairly lightweight.
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
importx
instead ofjiti
Support loading
eslint.config.ts
eslint.config.mts
eslint.config.cts
files powered byimportx
. The support is opt-in by users, where they need to installimportx
explicitly (we include it as optional peer deps instead ofdependencies
)Based on my previous experiments with
eslint-ts-patch
(which supports swapping different loaders likejiti
tsx
bundle-require
, feel free to try them out).importx
is a package trying to ease out the differences between them and the complexity of the pros/cons hidden from ESLint.The only downside is thattsx
uses Node's API, which has only been available sincev20.8.0
andv18.19.0
. But considering this is an opt-in feature, it should be fine, and the ecosystem should catch up soon.importx
ease out that will auto fallback tojiti
on unsupported node version.Is there anything you'd like reviewers to focus on?