Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser. #2811

Closed
ljwagerfield opened this issue Nov 24, 2020 · 2 comments
Labels
duplicate This issue or pull request already exists package: parser Issues related to @typescript-eslint/parser

Comments

@ljwagerfield
Copy link

Repro

Run eslint . --ext .js,.jsx,.ts,.tsx on the following codebase:

/.eslintrc.yaml

root: true
parser: "@typescript-eslint/parser"
parserOptions:
  project: "./tsconfig.json"
plugins:
  - "@typescript-eslint"
env:
  node: true

/tsconfig.json

{
  "compilerOptions": {
    "lib": ["es2019"],
    "module": "commonjs",
    "target": "es2019",
    "strict": true,
    "esModuleInterop": true,
    "allowJs": true,
    "checkJs": true,
    "baseUrl": "./"
  },
  "include": ["./**/*"],
  "exclude": ["./node_modules/**/*"]
}

/package.json

{
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "4.8.2",
    "@typescript-eslint/parser": "4.8.2",
    "eslint": "7.14.0",
    "typescript": "4.1.2"
  }
}

/src/Foo.ts

export default function foo(): string {
  return "";
}

/src/Foo.js

export default function foo() {
  return "";
}

Expected Result

eslint to succeed.

Actual Result

eslint fails due to Foo.js not being included within the project (even though it's covered by my "include" settings):

/Users/lawrence/Repositories/playground/eslint-js-example/src/Foo.js
  0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: src/Foo.js.
The file must be included in at least one of the projects provided

✖ 1 problem (1 error, 0 warnings)

Versions

package version
@typescript-eslint/parser 4.8.2
TypeScript 4.1.2
ESLint 7.14.0
node 12.19.0
@ljwagerfield ljwagerfield added package: parser Issues related to @typescript-eslint/parser triage Waiting for team members to take a look labels Nov 24, 2020
@bradzacher
Copy link
Member

bradzacher commented Nov 24, 2020

This is a known problem with typescript and files named the same.
Nothing we can do about it unfortunately!

Please checkout the readme - this is explicitly called out!

https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#parseroptionsproject

TypeScript will ignore files with duplicate filenames in the same folder (for example, src/file.ts and src/file.js). TypeScript purposely ignore all but one of the files, only keeping the one file with the highest priority extension (the extension priority order (from highest to lowest) is .ts, .tsx, .d.ts, .js, .jsx). For more info see #955.

Also this is a duplicate of #955

@bradzacher bradzacher added duplicate This issue or pull request already exists and removed triage Waiting for team members to take a look labels Nov 24, 2020
@ljwagerfield
Copy link
Author

Thank you for the fast response 😄

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists package: parser Issues related to @typescript-eslint/parser
Projects
None yet
Development

No branches or pull requests

2 participants