no-use-v-else-with-v-for
What it does
Section titled “What it does”Reports an element that has v-else and v-for together. Only in .vue files.
Why it matters
Section titled “Why it matters”v-else is evaluated first and cannot read the loop variable, and the result is not what the markup reads like.
To fix, put the v-for on a child or on a wrapping <template>.
Example
Section titled “Example”... <MyCard v-for="x in xs" />... <li v-else v-for="x in xs" :key="x" /> <template v-for="x in xs" :key="x"><li /></template>...Configuration
Section titled “Configuration”angular: lint: rules: no-use-v-else-with-v-for: warn # off, warn (default), errorhtml: lint: rules: no-use-v-else-with-v-for: warn # off, warn (default), errorsvelte: lint: rules: no-use-v-else-with-v-for: warn # off, warn (default), errorvue: lint: rules: no-use-v-else-with-v-for: warn # off, warn (default), errorSuppress one line with sudsy-disable-next-line no-use-v-else-with-v-for in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| eslint-plugin-vue | no-use-v-else-with-v-for |
full |