Skip to content

Bug: more informatively explain when tsconfigRootDir doesn't include the cwd #6883

@artola

Description

@artola

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

typescript-estree

Playground Link

No response

Repro Code

The logic in getProjectConfigFiles compares the length of parseSettings.filePath (dirname) and parseSettings.tsconfigRootDir to stop looking for the config.

But when tsconfigRootDir is not set in the .eslintrc.js config, they can be totally different paths, for example, depending where VSCode was installed (value used for tsconfigRootDir) for tooling.

Then, it is correct to stop looking for config "only" if the parseSettings.filePath starts with tsconfigRootDir, otherwise just keep looking up to the root.

directory.length >= parseSettings.tsconfigRootDir.length

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/<rule-name>": ["error", ...<options>],
  },
  parserOptions: {
    project: true
  }
};

tsconfig

{
  "compilerOptions": {
    // ...
  }
}

Expected Result

The config file should be found.

Actual Result

The config file is not found because it stops prematurely.

Additional Info

No response

Versions

package version
@typescript-eslint/eslint-plugin 5.58.0
@typescript-eslint/parser 5.58.0
@typescript-eslint/scope-manager 5.58.0
@typescript-eslint/typescript-estree 5.58.0
@typescript-eslint/type-utils 5.58.0
@typescript-eslint/utils 5.58.0
TypeScript 5.0.4
ESLint 8.38.0
node 18.14.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: typescript-estreeIssues related to @typescript-eslint/typescript-estree

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions