Skip to content
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

[Feature Request] Add a few API for eslint-import-resolver-typescript and eslint-plugin-import-x to migrate to tsconfck #183

Closed
SukkaW opened this issue Jul 27, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@SukkaW
Copy link

SukkaW commented Jul 27, 2024

Describe the feature

I recently became the co-maintainer of the eslint-import-resolver-typescript and the eslint-plugin-import-x projects, and I am working on replacing get-tsconfig w/ tsconfck. I have faced a few difficulties in implementing that because of the lack of the following features:

  • Synchronous API
  • Paths matcher / resolver

A Usecase

ESLint rules are synchronous, so we need a synchronous API to get the tsconfig file.

We also need a resolver that implements a module resolver interface that implements the TypeScript resolving algorithm (https://github.com/microsoft/TypeScript/blob/3ccbe804f850f40d228d3c875be952d94d39aa1d/src/compiler/moduleNameResolver.ts#L2465):

Alternatives

I could use libraries like synckit to force convert async API to sync, but it is less ideal.

As for the matcher/resolver, I could copy codes from vite-tsconfig-paths, which IMHO is also not ideal.

Additional context

@SukkaW SukkaW added the enhancement New feature or request label Jul 27, 2024
@dominikg
Copy link
Owner

from your requirements it reads like get-tsconfig is a pretty good fit. What makes you consider tsconfck as a replacement?

see #31 and #18 for previous discussions around sync apis.

@SukkaW
Copy link
Author

SukkaW commented Jul 28, 2024

from your requirements it reads like get-tsconfig is a pretty good fit. What makes you consider tsconfck as a replacement?

Mostly the sheer difficulties of contributing to get-tsconfig. I've tried to add ${configDir} support for get-tsconfig, but I can't even get its existing test cases to pass after upgrading to TypeScript 5.5. On the other hand, tsconfck already has full ${configDir} support.

@dominikg
Copy link
Owner

it might still be easier to add support for that in get-tsconfig (a little surprised it isn't supported yet) than bringing sync support to tsconfck.

There is an old branch linked in the Discussion above but from what i remember it wasn't easy to have a single codebase that supports sync and async. And it probably got worse since then because of the changes around the cache.

Happy to look into contributions that add sync support, but afraid that would require a major refactor to ensure keeping it lean and without duplicated logic.

For the features around implementing a resolver or paths matcher, it is more difficult to justify adding them to tsconfck. I think they would better live in separate packages and shared between get-tsconfig, vite-tsconfig-paths etc.

tsconfck focus is

A utility to find and parse tsconfig files without depending on typescript

what to do with the output is out of it's scope.

@dominikg
Copy link
Owner

dominikg commented Oct 8, 2024

closing this as out of scope, get-tsconfig gives you sync access until eslint allows you to work async and anything that is related to interpreting the outcome of tsconfig needs to be in a separate package.

@dominikg dominikg closed this as completed Oct 8, 2024
@dominikg dominikg reopened this Oct 8, 2024
@dominikg dominikg closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2024
@SukkaW
Copy link
Author

SukkaW commented Oct 8, 2024

Still thanks for your awesome library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants