typescript-eslint: Newly created Vue SFC File: Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser

What code were you trying to parse? I run into the infamous error of not finding the parser (similar to https://github.com/typescript-eslint/typescript-eslint/issues/1159 and https://github.com/typescript-eslint/typescript-eslint/issues/883) for new Vue files I create in my project. NOTE: a restart of VS and my live compiler eliminates the problem until the next time I create a new .vue file.

I am using Quasar, and vue-class-component for my SFC Vue files.

Error details:

 error  in ./src/components/signup/CLSignupStepperHeader.vue

Module Error (from ./node_modules/eslint-loader/index.js):

/Users/eyedean/dev/xxxxx/src/components/signup/CLSignupStepperHeader.vue
  0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: src/components/signup/CLSignupStepperHeader.vue.
The file must be included in at least one of the projects provided

✖ 1 problem (1 error, 0 warnings)


 @ ./node_modules/ts-loader??ref--10-0!./node_modules/vue-loader/lib??vue-loader-options!./src/pages/signup/CLSignupStepVitals.vue?vue&type=script&lang=ts& 10:0-81 143:12-33

Per the request at https://github.com/typescript-eslint/typescript-eslint/issues/1159#issuecomment-558427959 I am creating this new ticket.

What did you expect to happen? The new Vue file should be picked up normally. Again, a restart of live tsc and VS code fixes it, but it kinda takes 1 minute for my project.

What actually happened? It used to work flawlessly until I upgraded typescript-eslint, after a few months, recently. Looking at https://github.com/typescript-eslint/typescript-eslint/pull/1083/commits/e3f344874368a952c607ac7167d4324287a70061 which was the fix for a similar problem, the symptom I am seeing is very related to parsedFilesSeen not picking up the newly created file .vue on-the-fly.

Additional Notes Per https://eslint.vuejs.org/user-guide/#how-to-use-custom-parser for parsing Vue files, I have the following in my .eslintrc:

	parser: "vue-eslint-parser",
	
	// Must use parserOptions instead of "parser" to allow vue-eslint-parser to keep working
	// See https://eslint.vuejs.org/user-guide/#how-to-use-custom-parser
	// `parser: "vue-eslint-parser"` is already included with any "plugin:vue/**" config and should be omitted
	parserOptions: {
		project: "./tsconfig.eslint.json",
		parser: "@typescript-eslint/parser",
		sourceType: "module",
		extraFileExtensions: [".vue"]
	},

And then it is in my tsconfig.eslint.json that I am mentioning all the Vue files should be picked:

{
	"extends": "./tsconfig.json",
	"include": [
	  "**/*.ts",
	  "**/*.js",
	  "**/*.vue",
	  "**/*.json",
	],
	"compilerOptions": {
	  "allowJs": true,
	  "checkJs": true
	}
}

Versions

package version
@typescript-eslint/parser 2.10.0 (was the same on 2.8.0)
TypeScript 3.3.3
ESLint 5.16.0 (It’s on purpose to be on 5, rather than 6)
node 12.3.1
npm 6.13.0

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 20 (1 by maintainers)

Most upvoted comments

This also happens to me too in VS Code when a new file is added. Have to restart VS Code each time for it to go away.

  • typescript@3.5.3
  • @typescript-eslint/parser@2.13.0
  • @typescript-eslint/typescript-estree@2.13.0

i was able to reproduce this in simple example project, i will take a look into this

@armano2 I tested typescript-estree version 2.15.1-alpha.7 and it still has the issue with newly created ts/tsx files when using the vscode extension

@armano2 I have only tsx and ts files in my project and it’s still happening. I’ll try and create an example project to reproduce.

@eyedean @demisx @yoyo930021 today we merged pr (#1412) that fixes ~similar issue (not in vue sfc), can you re-test it with 2.15.1-alpha.5 or provide step by step example how to reproduce it?