no-dupe-else-if
What it does
Section titled “What it does”Reports an else if whose condition cannot be true at that point: it repeats a condition of an earlier branch of the chain (if (a) {} else if (a) {}), or each operand of its || is a whole earlier condition or an operand of an earlier || (if (a || b) {} else if (a) {}). A condition that is only implied by an earlier one (a && b after a) is not found.
Why it matters
Section titled “Why it matters”If an earlier condition was true its branch ran, and if it was false the same condition is false again, so the later branch never runs. This is nearly always a copy-paste slip where the condition was not changed, and the code the author meant to run is the dead one.
To fix, correct the condition or remove the branch.
Example
Section titled “Example”...if (a) {} else if (b) {} else if (a) {}if (a || b) {} else if (a) {} else if (b && c) {}if (a && b) {} else if (a) {} else if (b && a) {}...Configuration
Section titled “Configuration”js: lint: rules: no-dupe-else-if: warn # off, warn (default), errorEnabled by the presets: js/eslint-recommended, js/biome-recommended, js/oxlint.
Suppress one line with sudsy-disable-next-line no-dupe-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 | no-dupe-else-if |
full |