Description
Please describe what the rule should do:
This rule would enforce putting v-if
, v-else-if
, v-else
, v-for
directives on a <template>
tag and disallow them on html elements or custom components. The main reason for this is consistency since sometimes it is required to put v-if
or v-for
on a <template>
tag rather than on the element. It also allows for better and more clear code collapsing in editors, since the component that we want to control with the directive may also have a number of attributes.
What category should the rule belong to?
[x] Enforces code style (layout)
[ ] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)
Provide 2-3 code examples that this rule should warn about:
// BAD
<div v-if="loading">
...
</div>
<div v-else>
...
</div>
<MyItem v-for="item in items" :key="item.id" />
// GOOD
<template v-if="Loading">
<div>
...
</div>
</template>
<template v-else>
<div>
...
</div>
</template>
<template v-for="item in items" :key="item.id">
<MyItem />
</template>