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
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
<divv-if="loading">
...
</div>
<divv-else>
...
</div>
<MyItemv-for="item in items" :key="item.id" />
// GOOD
<templatev-if="Loading">
<div>
...
</div>
</template>
<templatev-else>
<div>
...
</div>
</template>
<templatev-for="item in items" :key="item.id">
<MyItem />
</template>
The text was updated successfully, but these errors were encountered:
BenAlbin
changed the title
Disallow v-if, v-else and v-for on non-template tags
Rule Proposal: Disallow v-if, v-else and v-for on non-template tags
Dec 23, 2021
Thank you for the rule proposal.
I think that some users prefer the opposite, so it would be better if we could offer various options by referring to the curly rule.
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 putv-if
orv-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:
The text was updated successfully, but these errors were encountered: