Skip to content

no-dupe-v-else-if

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.

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.

Reported
...
<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>
...
angular:
lint:
rules:
no-dupe-v-else-if: warn # off, warn (default), error
html:
lint:
rules:
no-dupe-v-else-if: warn # off, warn (default), error
svelte:
lint:
rules:
no-dupe-v-else-if: warn # off, warn (default), error
vue:
lint:
rules:
no-dupe-v-else-if: warn # off, warn (default), error

Enabled 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.

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