-
-
Notifications
You must be signed in to change notification settings - Fork 79
Parsing fails on scriptless Vue files with typescript-eslint parser #125
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
Comments
If you do not write If you want to enable a rule that uses type checking in all vue files, I think you'll need to specify e.g. {
"parserOptions": {
"parser": "@typescript-eslint/parser"
}
} https://github.com/vuejs/vue-eslint-parser#parseroptionsparser |
Why would this matter for a Vue file without a script tag? Is this this some kind of limitation? If so, where would this be addressed, eslint, this repository, ...? |
As described in this parser documentation, your way of specifying is to determine the parser by https://github.com/vuejs/vue-eslint-parser#parseroptionsparser |
The documentation says:
yet there is no |
When you don't provide a script tag, the vue compiler will generate a basic component object for you. so it's like writing: <script>
export default {}
</script> ... because components need a base object. Since that code doesn't have You will likely have the same problem with a plain .js file. Is there a specific reason why you want to use a different parser for JS? the TS parser can handle both just fine |
The reason for using espree for
|
Interesting. I haven't used type-enhanced eslint rules so far, so maybe that's why stuff worked for me ... We'll need to take a deeper look. you have a workaround for now, I think. |
The workaround allows successful linting indeed. The reproduction repo can be used if you want to debug the issue. If no solution is found this workaround could benefit from documenting. The workaround: add this to all your vue files <script lang="ts">
export default {}
</script> |
I think this is a bug. I would like to modify it so that |
@ota-meshi, thank you for addressing this issue! One note: with the latest parser version, 7.11.0,, when the js parser option is not specified or set to espree, scriptless vue files still cause the same error. While this is not a problem for me as I set |
When you say "the same error", are you referring to the error about the typescript-eslint rule? That would be expected. A JS parser like spree can't provide type informaiton to a type-aware rule. Using |
I'm well aware. I was just remarking that a |
When using an eslint config that specifies
parserOptions.parser.ts
, eslint errors while parsing files that do not have at least an empty<script lang="ts"></script>
.The eslint error is:
Config:
Reproduction: https://github.com/MatthiasKunnen/eslint-plugin-vue-ts-script.
The text was updated successfully, but these errors were encountered: