You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been working on setting up Vue support for eslint in a repo where we use ES5, and the Vue plugin doesn't work well with eslint's ES5 mode.
Installing the Vue plugin silently overwrites certain settings: ecmaVersion is set to 2018, sourceType to module, and JSX is enabled. This caused us to accidentally disable enforcement of our "no ES6" rule for about a month until I found out.
I tried to remedy this by changing these settings back in our .eslintrc.json, but that causes strange errors and even crashes to happen when linting templates that use v-for.
<template>
<div class="foo">
<p
v-for="x in xs"
:key="x"
>
{{ x }}
</p>
</div>
</template>
Second file (v-for using parens to get both the value and the index):
<template>
<div class="foo">
<p
v-for="(x, index) in xs"
:key="index"
>
{{ x }}
</p>
</div>
</template>
What did you expect to happen?
Both of these files should lint without errors, even in ES5 mode (ecmaVersion: 5 in the eslint config).
What actually happened?
For the first file, I get confusing errors about the v-for line:
4:7 error 'v-for' directives require that attribute value vue/valid-v-for
4:14 error Parsing error: Unexpected token x vue/no-parsing-error
5:7 error Expected 'v-bind:key' directive to use the variables which are defined by the 'v-for' directive vue/valid-v-for
For the second file, I get an error message that exposes a JS error / crash in the plugin code, without reference to a line number:
0:0 error Parsing error: Cannot read property 'block' of undefined
Both of these errors only happen if ecmaVersion: 5 is set. If I set ecmaVersion: 6, the errors go away.
The text was updated successfully, but these errors were encountered:
We are trying to introduce Vue into our legacy ES5 codebase and this is proving to be a blocker so any help with this would be greatly appreciated.
It's pretty much this issue but it seems like it was never reported here.
vuejs/eslint-plugin-vue#1089
The text was updated successfully, but these errors were encountered: