-
-
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
Conversation
✅ Deploy Preview for docs-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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 |
Sorry for the long due - with the great help from @privatenumber on I will further make sure everything works well in the future on |
Thanks. We still need to decide between this approach and #18134. @aryaemami59 what do you think of this PR? Also, we'll need this functionality to be behind a feature flag ( |
@nzakas I haven't worked with |
@antfu @aryaemami59 @fasttime I'd just like everyone to get on the same page before two people keep building the same feature. What is the key decision here? Jiti vs importx? How can we make that decision? |
It looks like Jiti 2 would support a similar set of test cases as importx, so the choice of the underlying tool seems to be more an implementation detail than a feature at this point. I wouldn't be opposed to merging both PRs and updating the logic to use whichever tool is available (if importx is installed, use it; otherwise use Jiti 2 if it's installed). Then maybe we could get user feedback about both tools, and we could always simplify the logic later to use just one tool for easier maintenance. But that's just an option. I'm fine with having just one implementation if there are any advantages. |
@nzakas I'm obviously biased but I think we should go with import { someConfig } from 'somePackage';
module.exports = someConfig; Or something like this: const { someConfig } = require('somePackage');
export default someConfig; It also doesn't care at all about |
I personally have no stake in either implementation, but importx already uses jiti under the hood where required, so it seems strange to me merge both a tool that uses jiti, or jiti directly. This is in response to @fasttime floating the idea of merging both tools. It'd make more sense to pick one or the other rather than allowing both. If jiti provides everything required then a tool like importx shouldn't be needed as a middleman. If it doesn't offer enough flexibility and importx can cover those shortfalls, then that would make more sense as a choice. The advantage I can see to importx (today) is that as antfu mentioned, once jiti v2 comes out of beta, importx can upgrade to it internally without the need for any changes on the eslint side. The issue with jiti v2 today is that we're unlikely to support jiti directly until v2 comes out officially, and there's no hard-eta on that. importx would allow these changes to (likely) go through sooner, unless eslint is willing to support technology that is not currently officialy released. |
@aryaemami59 my understanding is that @fasttime we should pick one to start. I don't see any benefit to making people choose a transitive dependency to try this out.
This doesn't seem like any real, tangible advantage to me. Either we directly update jiti or we need to update importx in order to get an updated jiti. My opinion: I think we should go with jiti for the initial feature. It's been around a while, and although it doesn't support top-level |
The advantage of importx is: it automatically selects the appropriate loader and not necessarily So if the user is already using one of the ts compilers (e.g. |
@nzakas The other PR #18134 was updated to use Jiti 2 beta which does support top-level await. The roadmap issue for Jiti v2 is already closed, and it suggests that Jiti 2 stable is nearly ready. Do you recommend to revert to Jiti 1 stable or should we stay with Jiti 2? |
@aladdin-add thanks for explaining. Still, I don't think that's a big enough difference. @fasttime if jiti v2 is close, I'd say let's wait until next week and see where we are. |
Can't the same argument be used against a major release of Jiti v2? I'm still interested in seeing if we can respect the user's TS compiler preference. Like many agreed in the RFC, I wouldn't want to be forced to install a second TS compiler if I already have one (especially by such a popular tool). And being able to choose would support users who have use-cases for TLA or native Node integration. Could we try a simple fallback approach like postcss-load-config? |
@privatenumber This is an experimental feature, so we can continue to iterate. I'm mostly interested in landing the feature so we can start having people try it out and give us feedback. It doesn't have to be perfect, but I prefer starting with a package that has some lineage. |
I can get onboard with iterating. Would you mind elaborating on what you mean by "lineage" in this context? |
Hi all 👋 It's been a wish of the team to have only one PR to implement RFC eslint/rfcs#117. It wasn't clear from the beginning how the implementations with different tools would work, but now that there are well-tested prototypes, it's better to concentrate all efforts in the same direction. We would like to keep #18134 because it was created first and it is from the author of the RFC. Of course, we are aware of the mutual exchange of ideas and code that's been going on so far, and we would like to give credit to @antfu for contributing to the implementation. Thanks also to everybody who provided feedback and helped reviewing this PR. As for the tool to use, the current preference is for Jiti, which we hope to get set up in version 2 soon. This is a choice that we may reconsider later depending on the feedback we receive when the feature is out. Please, take time to review #18134 if you would like to contribute to adding TypeScript config support to ESLint. |
I really like that idea, we can check for |
I'm curious, isn't that more or less what |
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?