Closed
Description
What rule do you want to change?
New rule vue/no-use-v-if-with-v-for
vue/no-use-v-else-with-v-for
Does this change cause the rule to produce more or fewer warnings?
More
How will the change be implemented? (New option, new default behavior, etc.)?
Not sure, but probably default behavior.
Please provide some example code that this change will affect:
<!-- GOOD, this is caught be the vue/no-use-v-if-with-v-for rule already -->
<div v-if="foo" v-for="x in xs">{{ x }}</div>
<!-- BAD -->
<div v-if="foo">foo</div>
<div v-else v-for="x in xs">{{ x }}</div>
<!-- GOOD -->
<div v-if="foo">foo</div>
<template v-else>
<div v-for="x in xs">{{ x }}</div>
</template>
<!-- BAD -->
<div v-if="foo">foo</div>
<div v-else-if="bar" v-for="x in xs">{{ x }}</div>
<!-- GOOD -->
<div v-if="foo">foo</div>
<template v-else-if="bar">
<div v-for="x in xs">{{ x }}</div>
</template>
What does the rule currently do for this code?
Only report the first case (v-if
+v-for
).
What will the rule do after it's changed?
Also warn about the other cases (v-else
+v-for
and v-else-if
+v-for
), and maybe even autofix to add a wrapper <template>
tag.