no-dupe-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 whose condition is the same as an earlier v-if or v-else-if of the chain. Conditions are compared as text without blanks, and || alternatives one by one; a condition that only some earlier && terms cover is not found. Only in .vue files.
Why it matters
Section titled “Why it matters”The earlier branch with the same condition always wins, so this branch can never run. It is usually a copy that was meant to have another condition.
To fix, change the condition, or remove the branch.
Example
Section titled “Example”... <MyCard v-for="x in xs" />... <b v-if="a" /><i v-else-if="a || b" /><i v-else-if="a" />... <template v-for="x in xs" :key="x"><li /></template>...Configuration
Section titled “Configuration”angular: lint: rules: no-dupe-v-else-if: warn # off, warn (default), errorhtml: lint: rules: no-dupe-v-else-if: warn # off, warn (default), errorsvelte: lint: rules: no-dupe-v-else-if: warn # off, warn (default), errorvue: lint: rules: no-dupe-v-else-if: warn # off, warn (default), errorEnabled by the presets: html/eslint-plugin-vue-recommended.
Suppress one line with sudsy-disable-next-line no-dupe-v-else-if in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| eslint-plugin-vue | no-dupe-v-else-if |
partial | conditions are compared as text, || alternatives one by one; && subsets are not found |