Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Enhancement: Default tsconfigRootDir to the running flat config's directory if available #10841

Copy link
Copy link
Open
@JoshuaKGoldberg

Description

@JoshuaKGoldberg
Issue body actions

Before You File a Proposal Please Confirm You Have Done The Following...

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:

  1. Is there an ESLint API / something provided to parsers that would help with this?
  2. If not, can we file an issue on ESLint core asking for it?

💖

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestNew feature or requestteam assignedA member of the typescript-eslint team should work on this.A member of the typescript-eslint team should work on this.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.