Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Config propertyparserOptions.project relative path resolving #540

Closed
Labels
package: parserIssues related to @typescript-eslint/parserquestionQuestions! (i.e. not a bug / enhancment / documentation)working as intendedIssues that are closed as they are working as intended
@woldner

Description

@woldner

When using a relativeparserOptions.project path, I've found that the path is not relative to the config file (e.g..eslintrc.js) referencing this path, but instead relative to the working directory of the process running the CLI.

From the@typescript-eslint/eslint-plugin docs:

typescript

Here's the problem:
When using the eslint CLI in a different working directory compared to where the eslint config file (e.g..eslintrc.js) is located, then theparserOptions.project path will resolve relative to the working directory of the process rather than the config file referencing the relative path.

Here's an example using a project located at
C:\Users\m41n\Source\Repos\TT-ESLint-VisualStudioSample:

  1. I have a terminal with the user folder as working directory (e.g.C:\Users\m41n)
  2. I run the eslint CLI through the terminal on a file located in different directory:
    $ C:\Users\m41n\Source\Repos\TT-ESLint-VisualStudioSample\src\TypeScriptSample\node_modules\.bin\eslint.cmd "C:\Users\m41n\Source\Repos\TT-ESLint-VisualStudioSample\src\TypeScriptSample\Scripts\app\HomePageService.ts" --format="json"

By omitting the--config parameter to the CLI, the config will be resolved correctly by eslint. In this case:
C:\Users\m41n\Source\Repos\TT-ESLint-VisualStudioSample\src\TypeScriptSample\.eslintrc.js

Here's the content of the.eslintrc.js file (irrelevant parts omitted for brevity):

module.exports = {    ...    "parser": "@typescript-eslint/parser",    "parserOptions": {        "project": "./tsconfig.json"    },    ...

I'll get an parsing error, saying that the fileC:\Users\m41n\tsconfig.json could not be found (parserOptions.project path is relative to the working directory of the process, rather than the.eslintrc.js file):

[  {    "filePath": "C:\\Users\\m41n\\Source\\Repos\\TT-ESLint-VisualStudioSample\\src\\TypeScriptSample\\Scripts\\app\\HomePageService.ts",    "messages": [      {        "ruleId": null,        "fatal": true,        "severity": 2,        "message": "Parsing error: File 'C:\\Users\\m41n\\tsconfig.json' not found."      }    ],    "errorCount": 1,    "warningCount": 0,    "fixableErrorCount": 0,    "fixableWarningCount": 0,    "source": "..."  }]

What did you expect to happen?
I expect the config propertyparserOptions.project path to resolve relative to the config file rather than the process running the CLI.

Versions

packageversion
"@typescript-eslint/eslint-plugin1.9.0
@typescript-eslint/parser1.9.0
TypeScript3.4.5
ESLint5.16.0
node11.12.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: parserIssues related to @typescript-eslint/parserquestionQuestions! (i.e. not a bug / enhancment / documentation)working as intendedIssues that are closed as they are working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp