-
-
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 <aryaemami59@users.noreply.github.com>
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.
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.
Oh my gosh, thank you so much for figuring this one out, I was banging my head on the wall for quite some time trying to figure this one out.
PR is still blocking due to a |
"eslint.config.cjs", | ||
"eslint.config.ts", | ||
"eslint.config.mts", | ||
"eslint.config.cts" |
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.
What about eslint.config.tsx
? It's a legitimate file extension that some frontend-area projects enforce all files adhere to for consistency.
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.
Can you give some examples?
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 am not sure about it personally. To me, TSX is a DSL specific to some frontend frameworks. And if we going to have .tsx
, one could argue to have .jsx
- which is not supported by Node.js without transpiling. I am not sure what's the use case of having TSX in the config file, and such a convension does not seem to widely supported by other tools.
@@ -918,6 +918,112 @@ describe("ESLint", () => { | |||
assert.strictEqual(results[0].messages[0].ruleId, "no-undef"); | |||
}); | |||
}); | |||
|
|||
describe("TypeScript config files", () => { |
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.
[Testing] What do you think about including a test file that includes the not-very-friendly-to-transpilation TypeScript features?
const enum
namespace
@
experimentalDecorators
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.
Interesting, I personally would never use them because they are not transpilation friendly 😇 But good points - I will try to do a matrix tests in importx first to see how each solution works with them
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
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?