-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Enhancement: Default tsconfigRootDir
to the running flat config's directory if available
#10841
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
Comments
Curious how this would interact with experimental-config-lookup. Guess we'd default it to the resolved, inner config? Even if the inner config imports the root config or something? |
Copying my comment #10507 (comment)
|
The config lookup feature doesn't change the |
👍 filed eslint/eslint#19438. Marking this blocked on that. |
Welp, eslint/eslint#19438 was rejected. But I really want us to be able to do this for users - not having to explicitly provide a Proposal: how about as a breaking change in the next major version with behavioral changes, if the user has enabled
So, looking at the different use cases:
What do we think @typescript-eslint/triage-team? |
The ESLint config won't show up in the call stack -- it's ESLint itself that calls the parser, not the ESLint config. So we'd need to do disk traversal to find it. |
But if they're calling to |
Really depends on who you're targeting. |
I'm glad we haven't committed to anything or triaged #10935 yet then 😄 It seems to me that we and our users have two options for this area of configuring typed linting:
We would of course need to make both cases work out-of-the-box; using some I'm in favor of going with an "enhanced" config, so that we can give users the features they need that are blocked on ESLint core. |
I'm firmly 👎 on adding functionality into the An alternative idea for supporting this in the config would be to have something like import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
tseslint.configs.enableProjectService({ tsconfigRootDir: import.meta.dirname })
); |
Hypothetically, if we had to choose between:
...which would you choose? I think that's a false dichotomy and that we can reach a workaround, but just for the sake of discussion. 😄
I think the ideal solution would be to not add an explicit line about Spitballing some alternatives:
I think 🍏 I normally would hate to add a dynamic getter and also hate to add yet another weird implicit global state shenanigan. But it's the only one that doesn't add work for users. |
In all of these we're forced to choose between forcing users to pass Technical ideas as to how we'd guess the config directory:
I think if we can reasonably implement a solution where we get |
In theory either. I think there are roughly three places we can look for information (since ESLint doesn't give us any), in descending order of how reliable they are:
We can only trigger 🐉 from code actually run in the ESLint config (#10841 (comment)). But I love the being able to definitively see that some file named I think the problem with 🥚 and 🐟 disk traversal is edge cases that cause it to search up the directory chain:
...then again, Anyway, my current tentative proposal is still 🐉 for the current major version. |
I think my order of preference is
|
Before You File a Proposal Please Confirm You Have Done The Following...
Relevant Package
parser
My proposal is suitable for this project
Description
Re-filing #251 now that ESLint's flat config is stable: asking users to manually set
tsconfigRootDir
is a mild config pain:import.meta.dirname
Node.js support)#251 was closed as noted in #251 (comment) because ESLint doesn't tell parsers the eslintrc path(s). But, now that we're on flat config, maybe there's a way to get the single flat config file / directory. That would be ideal IMO.
If we could infer
tsconfigRootDir
then https://typescript-eslint.io/getting-started/typed-linting would be simplified by a line:import eslint from '@eslint/js'; import tseslint from 'typescript-eslint'; export default tseslint.config( eslint.configs.recommended, tseslint.configs.recommendedTypeChecked, { languageOptions: { parserOptions: { projectService: true, - tsconfigRootDir: import.meta.dirname, }, }, }, );
...and #10507 would be unblocked, which would allow simplifying that config in the next major version to the much cleaner:
✨.
Additional Info
Investigation needed:
💖
The text was updated successfully, but these errors were encountered: