vscode-eslint: Error when creating new file, but disappear on window reload
I am getting this error every time I created a new TypeScript file:
Parsing error: If "parserOptions.project" has been set for @typescript-eslint/parser, /home/tkesgar/git/charaverse/admiral-hipper/src/mods/abc.ts must be included in at least one of the projects provided.
The error disappears if I run "Developer: Reload Window"
.
The error does not appear if I deleted a TypeScript file and created a new file with the same name.
Visual Studio Code version:
Version: 1.37.1
Commit: f06011ac164ae4dc8e753a3fe7f9549844d15e35
Date: 2019-08-15T16:17:25.463Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Linux x64 4.15.0-58-generic snap
Extension:
Name: ESLint
Id: dbaeumer.vscode-eslint
Description: Integrates ESLint JavaScript into VS Code.
Version: 1.9.1
Publisher: Dirk Baeumer
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
.eslintrc.json:
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json"
},
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:prettier/recommended",
"prettier/@typescript-eslint"
]
}
package.json:
{
"name": "admiral-hipper",
"version": "0.0.0",
"repository": "https://github.com/charaverse/admiral-hipper",
"author": "Ted Kesgar <t.kesgar@live.com>",
"license": "Apache-2.0",
"scripts": {
"start": "node dist/server.js",
"watch:server": "nodemon",
"watch:ts": "tsc --watch",
"watch": "run-p watch:*",
"lint": "eslint --ext '.js,.ts' 'src/**/*.ts'",
"format": "prettier --write 'src/**/*.ts'",
"test": "jest",
"coverage": "jest --coverage",
"clean": "del-cli dist/",
"build": "tsc"
},
"dependencies": {
"dotenv": "^6.2.0",
"express": "^4.17.1",
"pino": "^5.13.2"
},
"devDependencies": {
"@types/dotenv": "^6.1.1",
"@types/express": "^4.17.1",
"@types/jest": "^24.0.18",
"@types/node": "^12.7.2",
"@types/pino": "^5.8.9",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"del-cli": "^2.0.0",
"eslint": "^6.2.1",
"eslint-config-prettier": "^6.1.0",
"eslint-plugin-prettier": "^3.1.0",
"husky": "^3.0.4",
"jest": "^24.9.0",
"lint-staged": "^9.2.3",
"nodemon": "^1.19.1",
"npm-run-all": "^4.1.5",
"pino-pretty": "^3.2.1",
"prettier": "1.18.2",
"ts-jest": "^24.0.2",
"typescript": "^3.5.3"
},
"jest": {
"moduleFileExtensions": [
"ts",
"js"
],
"testEnvironment": "node",
"testMatch": [
"<rootDir>/src/tests/**/*.ts"
],
"transform": {
"^.+\\.ts$": "ts-jest"
}
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,ts}": [
"eslint --fix",
"prettier --write",
"git add"
]
}
}
Repository: https://github.com/charaverse/admiral-hipper/tree/7315ff1144
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 15 (5 by maintainers)
I’ve solved trouble used VSCode workspace setting
eslint.options
to addparserOptions
.I’ve got the new parser 2.5.0 installed, and the error still occurs in VSC.
Setting the parser option
"createDefaultProgram": true
will circumvent the included check in typescript/eslint (with a performance penalty) I suspect they might have a caching issue eg. if they store a map of all asts/files to lint. It could be that the map is not updated using watch when used in long running instances webpack/vs code eslint extension etc.As state over there this is best fixed on the typescript eslint side since it affects all integrations of the parser (WebStorm, watch mode, …)
I will mark the issue as upstream.
@HosseinAgha thanks for pointing to the typescript eslint issue.
I even get this type of error in my
webpack.config.js
file..eslintrc.json
:tsconfig.json
: