Skip to content

Enhancement: should throw if invalid tsconfigRootDir is provided #11460

@kirkwaiblinger

Description

@kirkwaiblinger

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

I expect that these should throw (when validating parser options):

import tseslint from 'typescript-eslint';

export default tseslint.config(
  tseslint.configs.strictTypeChecked,
  {
    languageOptions: {
      parserOptions: {
        projectService: true,
        tsconfigRootDir: 'not/an/absolute/path',
      }
    }
  }
);

(or tsconfigRootDir: 42, or tsconfigRootDir: '.').

In other words, I think the following...

export function createParseSettings(
code: string | ts.SourceFile,
tsestreeOptions: Partial<TSESTreeOptions> = {},
): MutableParseSettings {
const codeFullText = enforceCodeString(code);
const singleRun = inferSingleRun(tsestreeOptions);
const tsconfigRootDir =
typeof tsestreeOptions.tsconfigRootDir === 'string'
? tsestreeOptions.tsconfigRootDir
: getInferredTSConfigRootDir();

...should have (roughly)

assert(
  tsestreeOptions.tsconfigRootDir == null ||
    (typeof tsestreeOptions.tsconfigRootDir === "string" &&
      path.isAbsolute(tsestreeOptions.tsconfigRootDir)),
);

Additional Info

Relates to #11414, #11429

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions