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

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

Closed
thany opened this issue Jan 28, 2020 · 4 comments
Closed
Labels
package: parser Issues related to @typescript-eslint/parser working as intended Issues that are closed as they are working as intended

Comments

@thany
Copy link

thany commented Jan 28, 2020

What code were you trying to parse?
An empty, newly added file anywhere within the project.

What did you expect to happen?
Nothing. The file is included by the include directive in tsconfig.json so this error seems unjust to me. All other files at the same level as that empty file do not throw this error, so the inclusion of these files in the project is probably configured correctly.

What actually happened?
An error is thrown on the empty file:

Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: C:\workspaces\enexis-ui\src\utils\test.tsx.
The file must be included in at least one of the projects provided.

Also tried
I tried to change my tsconfig.json to explicitly include all ts/tsx files, by changing the include directive like so:

"include": ["src/**/*.{ts,tsx}", "types"]

Or even going all-globs:

"include": ["./src/**/*.{ts,tsx}", "./types/**/*.ts"]

This appears to make no difference.

Versions

package version
@typescript-eslint/parser 2.4.0
TypeScript 3.6.4
ESLint 6.5.1
node 10.16.3
npm 6.9.0

.eslintrc
My .eslint is located at the project root, "next to" nodule_modules and such.

{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "project": "./tsconfig.json"
  },
  "extends": [
    "airbnb"
  ],
  "plugins": [
    "@typescript-eslint",
    "react-hooks"
  ],
  "env": {
    "browser": true
  },
  "rules": {
    "arrow-parens": [ "error", "as-needed" ],
    "comma-dangle": "off",
    // ...long list of rules - irrelevant, I think
  }
}

tsconfig.json
My tsconfig.json is located "next to" my .eslintrc

{
  "include": ["src", "types"],
  "compilerOptions": {
    "target": "es5",
    "module": "esnext",
    "lib": ["dom", "esnext", "es2017"],
    "importHelpers": true,
    "declaration": true,
    "downlevelIteration": true,
    "sourceMap": true,
    "rootDir": "./",
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "noImplicitThis": true,
    "alwaysStrict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "moduleResolution": "node",
    "baseUrl": "./",
    "paths": {
      "*": ["src/*", "node_modules/*"]
    },
    "jsx": "react",
    "esModuleInterop": true
  }
}
@thany thany added package: parser Issues related to @typescript-eslint/parser triage Waiting for maintainers to take a look labels Jan 28, 2020
@armano2
Copy link
Member

armano2 commented Jan 28, 2020

@thany i have few questions:

  1. is this issue in editor, console or both?
    • if only in editor which one
  2. on which os you are experiencing this issue? (win/linux/mac/?)
  3. did you tried upgrading parser to 2.16.0 (or higher):

@armano2 armano2 added awaiting response Issues waiting for a reply from the OP or another party package: typescript-estree Issues related to @typescript-eslint/typescript-estree package: parser Issues related to @typescript-eslint/parser and removed package: parser Issues related to @typescript-eslint/parser triage Waiting for maintainers to take a look package: typescript-estree Issues related to @typescript-eslint/typescript-estree labels Jan 28, 2020
@thany
Copy link
Author

thany commented Jan 28, 2020

  1. Editor only, as far as I can tell. My console command would be eslint ./src/**/*.{js,jsx,ts,tsx} which doesn't give that error. My editor is VScode 1.41.1
  2. Windows 10
  3. It appears to be working in 2.18.0.

Is there a temporary workaround for 2.4.0? This is a rather complex project and I can't willy nilly upgrade packages. We will be upgrading tho, but not yet 😀
Also there's no telling from a quick test, whether this issue could return after doing more package upgrades (which, as you can see, are due).

@armano2
Copy link
Member

armano2 commented Jan 28, 2020

minimum what you will have to update is typescript-estree package

but if you are looking for temporary fix (by editing package), than you can manually file:
in lib/create-program/createWatchProgram.js

  • in while after log('File was not found in program - triggering folder update. %s', filePath);,
  • after hasCallback = true;

you can remove break, this should fix this issue temporarily for you,

9720d2c#diff-32cd9e2645e695e2ede2d99856727abfL402


but i do recommend to upgrade at least typescript-estree to 2.16.0

@bradzacher bradzacher added working as intended Issues that are closed as they are working as intended and removed awaiting response Issues waiting for a reply from the OP or another party labels Jan 28, 2020
@bradzacher
Copy link
Member

Is there a temporary workaround for 2.4.0? This is a rather complex project and I can't willy nilly upgrade packages.

This bug was fixed in a later version.
If you must stay on the older version, you have to manually patch the changes yourself.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: parser Issues related to @typescript-eslint/parser working as intended Issues that are closed as they are working as intended
Projects
None yet
Development

No branches or pull requests

3 participants