typescript-eslint: vscode-eslint: Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
What code were you trying to parse?
// new.ts
console.log(`hello`)l
What did you expect to happen?
no errors
What actually happened? vscode-eslint yells at me. Running in cli is fine. Only happens for new files.
I know the workaround is to restart vscode but that’s like dropping a nuclear bomb to break open a coconut.
I assume it’s an issue with watching for changes.

Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: common/util/new.ts.
The file must be included in at least one of the projects provided.
Always see this at the start of a new file. Existing files work fine. I assumed this was fixed in new version, but it seems not.
Configs
tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"alwaysStrict": true,
"baseUrl": ".",
"checkJs": false,
"declaration": false,
"esModuleInterop": true,
"jsx": "react",
"jsxFactory": "h",
"lib": ["esnext", "dom"],
"moduleResolution": "node",
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"pretty": true,
"resolveJsonModule": true,
"sourceMap": true,
"strictNullChecks": false,
"target": "es6",
"typeRoots": ["./node_modules/@types", "./ts-global-types"],
"paths": {
"common/*": ["./common/*"],
"server/*": ["./server/*"]
}
},
"include": ["common/", "frontend/", "server/"]
}
.eslintrc.js
const TS_OVERRIDE = {
files: [`**/*.ts`, `**/*.tsx`],
parser: `@typescript-eslint/parser`,
parserOptions: {
project: `./tsconfig.json`,
tsconfigRootDir: __dirname,
},
plugins: [`@typescript-eslint`],
extends: [
`eslint:recommended`,
`plugin:@typescript-eslint/eslint-recommended`,
`plugin:@typescript-eslint/recommended`,
`plugin:@typescript-eslint/recommended-requiring-type-checking`,
`prettier`,
`prettier/@typescript-eslint`,
],
rules: ...
};
module.exports = {
root: true,
env: {
browser: true,
es6: true,
},
extends: `eslint:recommended`,
overrides: [TS_OVERRIDE],
parserOptions: {
ecmaVersion: 2020,
sourceType: `module`,
ecmaFeatures: {
jsx: true,
},
},
plugins: [`react`],
settings: {
react: {
pragma: `h`,
},
},
....
}
Versions
"@typescript-eslint/eslint-plugin": "2.23.0",
"@typescript-eslint/parser": "2.23.0",
"typescript": "3.8.3",
"eslint": "6.8.0",
node v12.14.0
npm 6.13.6
Halp!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 7
- Comments: 18 (6 by maintainers)
Do not use that option. It was added as a stop-gap to help people migrate to v2 whilst we ironed out the kinks in the new algorithm.
It has been many months since we rebuilt the algorithms, and it now properly handles all the configurations and adding/removing of files.
As such,
createDefaultProgramwill be removed in a future version. Relying upon this flag now will cause you pain in the future.Additionally using this option will exponentially increase your lint times (this is why we turn that functionality off by default in 2.0).
If you are receiving this error message it means the following:
You are attempting to lint a file (with type aware linting) which is not included in one of the tsconfigs you have passed to
parserOptions.project.Solutions:
includeglobs.tsconfig.eslint.json) andincludethe file there.parserOptions.project)..eslintingorefile to ignore the file from linting.Again, and I cannot stress this enough, DO NOT USE
createDefaultProgram.I figured it out: I had workspace open via symlinked folder. Once I open workspace at the real folder path it works.
@clehene
I was having the same issue, my project structure is:
project |-- tsconfig.json |-- .eslintrc.js |-- .eslintignore |-- src
Since I only want to lint the files in src, in my tsconfig.json I have “include”: [ “src/**/*” ]
With this setup, I was getting the same error, so I added .eslint.js in the .eslintignore and it works fine. If you want linting in the .eslint.js, if you add .eslint.js in the include, it will probably work
@bradzacher - We also migrating from tslint to eslint and have started facing the same issue.
We have a Monorepo using “lerna” Our settings.json file has this config to support monorepo:-
"eslint.workingDirectories": [{ "pattern": "./packages/*/" }],Our tsconfig.json file:-
Our eslintrc.js file:-
Let me know in case i have open another issue.
This issue is happening for our whole team currently across VSCode and Atom IDEs. Our only solution has been to remove node_modules and reinstall all packages. It usually happens when pulling in new files from Git.