valid-v-else-if
Angular templatesHTMLVue / SvelteVue / Sveltecorrectnessno fixdefault: warnhtml/eslint-plugin-vue-recommended
What it does
Section titled “What it does”Reports a v-else-if that has no expression, has an argument or a modifier, shares an element with v-if or v-else, or is not on the element right after one with v-if or v-else-if. Only comments and blank space may sit between the elements of a chain.
Why it matters
Section titled “Why it matters”A v-else-if that does not continue a chain is a compile error, or it is ignored and the element is always rendered.
To fix, write v-else-if="condition" right after the v-if or v-else-if element.
Example
Section titled “Example”... <!-- a comment may sit between --> <p v-else-if="b">b</p> <p v-else>c</p> <p v-else-if="d">after else</p> <p v-if="a">a</p> text <p v-else-if="x">b</p>... <p v-if="a" v-else-if="b">both</p></template>Configuration
Section titled “Configuration”angular: lint: rules: valid-v-else-if: warn # off, warn (default), errorhtml: lint: rules: valid-v-else-if: warn # off, warn (default), errorsvelte: lint: rules: valid-v-else-if: warn # off, warn (default), errorvue: lint: rules: valid-v-else-if: warn # off, warn (default), errorEnabled by the presets: html/eslint-plugin-vue-recommended.
Suppress one line with sudsy-disable-next-line valid-v-else-if 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 | valid-v-else-if |
full |