Open
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
Relevant Package
parser
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Description
Re-filing #251 now that ESLint's flat config is stable: asking users to manually set tsconfigRootDir
is a mild config pain:
- It's an extra line of code plumbing to memorize a need for
- Its default value is >99% of the time just the current file's directory...
- ...which has some nuance in how to retrieve (CJS/ESM;
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:
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
- {
- languageOptions: {
- parserOptions: {
- projectService: true,
- },
- },
- },
);
✨.
Additional Info
Investigation needed:
- Is there an ESLint API / something provided to parsers that would help with this?
- If not, can we file an issue on ESLint core asking for it?
💖
Metadata
Metadata
Assignees
Labels
New feature or requestNew feature or requestA member of the typescript-eslint team should work on this.A member of the typescript-eslint team should work on this.