Skip to content

Enhancement: Confusing error message when file is linted but not in parserOptions.project TSConfig #11797

@jwbth

Description

@jwbth

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

Relevant Package

typescript-estree

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

The current error message for files that ESLint attempts to lint but aren't included in any TSConfig is confusing and seemingly contradictory:

Parsing error: ESLint was configured to run on `<tsconfigRootDir>/sandbox\test.mjs` using `parserOptions.project`:
- <tsconfigRootDir>/jsconfig.json
- <tsconfigRootDir>/src\jsconfig.json
...
However, none of those TSConfigs include this file.

Problem

The phrase "ESLint was configured to run on [file] using parserOptions.project" is confusing because it sounds like the user explicitly configured ESLint to lint this file with those specific TSConfigs. In reality:

  1. ESLint's file inclusion rules determined the file should be linted
  2. The parserOptions.project setting exists globally
  3. None of the TSConfigs actually cover this file

This creates an apparent contradiction: "configured to run using X" followed by "but X doesn't include this file" makes it sound like the configuration is broken or nonsensical.

Solution

Consider rewording to make the two-step process clearer:

Parsing error: ESLint is attempting to lint `<tsconfigRootDir>/sandbox\test.mjs`, but this file is not included in any of the TSConfigs specified in `parserOptions.project`:
- <tsconfigRootDir>/jsconfig.json
- <tsconfigRootDir>/src\jsconfig.json
...

Either:
- Exclude this file from linting (add it to `ignores`)
- Add this file's location to one of the TSConfig's `include` patterns
- Create a new TSConfig that includes this file and add it to `parserOptions.project`
- Use a separate ESLint configuration for this file without type-aware linting

See the typescript-eslint docs for more info: https://typescript-eslint.io/troubleshooting/typed-linting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file

This makes it clear that:

  1. ESLint wants to lint the file (for reasons separate from parserOptions.project)
  2. The type-checking feature requires TSConfig coverage
  3. There's a mismatch between these two things

Additional Info

Relevant file: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-estree/src/create-program/createProjectProgramError.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttriageWaiting for team members to take a look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions