Content-Length: 313146 | pFad | http://github.com/typescript-eslint/typescript-eslint/issues/10841

AB Enhancement: Default `tsconfigRootDir` to the running flat config's directory if available · Issue #10841 · typescript-eslint/typescript-eslint · GitHub
Skip to content

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

Closed
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

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 requestteam assignedA 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









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: http://github.com/typescript-eslint/typescript-eslint/issues/10841

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy