valid-v-if
Angular templatesHTMLVue / SvelteVue / Sveltecorrectnessno fixdefault: warnhtml/eslint-plugin-vue-recommended
What it does
Section titled “What it does”Reports a v-if that has no expression, has an argument or a modifier, or is on the same element as v-else or v-else-if.
Why it matters
Section titled “Why it matters”A v-if without an expression fails to compile or always hides the element, and an argument or a modifier is ignored.
To fix, write v-if="condition" and put v-else on the next element.
Example
Section titled “Example”... text... <p v-if="a" v-else-if="b">both</p></template>Configuration
Section titled “Configuration”angular: lint: rules: valid-v-if: warn # off, warn (default), errorhtml: lint: rules: valid-v-if: warn # off, warn (default), errorsvelte: lint: rules: valid-v-if: warn # off, warn (default), errorvue: lint: rules: valid-v-if: warn # off, warn (default), errorEnabled by the presets: html/eslint-plugin-vue-recommended.
Suppress one line with sudsy-disable-next-line valid-v-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-if |
full |