Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork77
Description
Reason:typescript-eslint/typescript-eslint#2865 (comment)
Hi, I'm usingvue-eslint-parser
andtypescript-eslint
in company project.
At the same time, I also help to contributetypescript-eslint
project for fixing vue problems.
This problems are only happens when using type rules intypescript-eslint
.
You need to addparserOptions.project
in project to enable it.
https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/TYPED_LINTING.md
There are two main issues:
performance issue
issues:#65,typescript-eslint/typescript-eslint#1180
The problem is thatvue-eslint-parser
is designed with the AST not type information.
Thevue-eslint-parser
will split code frame from template to@typescript-eslint/parser
.
typescript-eslint/typescript-eslint#1180 (comment)
Typescript program need to parse full project for generate type information.
When parsing code frame, typescript program will reparse file AST and rebuild type information in project.
Thevue-eslint-parser
will pass more code frames and same file path in single Vue SFC.
Possible solutions:
- Ignore
parserOptions.project
to close get type information when pass code frame. - Try to use ESLint processors, likeSvelte.
Ref:Add fragment options to lint code fragment for Vue SFC performance typescript-eslint/typescript-eslint#1180 (comment)
[no-unsafe-*] rules
issues:typescript-eslint/typescript-eslint#2865
Strictly speaking, it isn't a problem with this project.
The typescript program can't parse Vue SFC file directly.
You may think it's strange, but why is it working now?
Because@typescript-eslint/parser
will prioritize the content delivered from ESLint.
Typescript program will update by ESLint content not same as typescript program read.
But this problem is happens when ESLint not send file content and content from typescript program reading.
Example:
// App.vueimportHelloWorldfrom'./components/HelloWorld.vue'// <- typescript program can't parse it. because it will read including template and style.exportdefault{name:'App',components:{ HelloWorld// <- so type information is `any`}}
This problem will also have in<script setup>
RFC.
Possible solutions:
- Override
HelloWorld.vue
content. - Mock a
HelloWorld.vue.ts
file.
Maybe we need a common project for hacking typescript program.
Thanks for watching. Have a good day!