no_equal_conditions
v1.0.0 Warning Control Flow
This rule flags an if/else if chain that tests the same condition twice.
Why use this rule
Section titled “Why use this rule”The second test can never be reached: the first branch already took every case it would have matched. Whatever the repeated branch does is dead code, and the case it was meant to handle silently falls through to else — so the bug shows up as a missing behaviour rather than an error.
It is a copy-paste result: a branch duplicated and its body edited while its condition was left alone.
Two independent if statements testing the same thing are not reported — the first may have changed the state the second reads. Only one chain is compared. A pattern case (if (x case ...)) is skipped, since two clauses that read alike need not test the same thing.
if (status.isPending) { showSpinner();} else if (status.isPending) { // never reached showRetry();}if (status.isPending) { showSpinner();} else if (status.isFailed) { showRetry();}Turning this rule off
Section titled “Turning this rule off”This rule is in the recommended preset, so it is on with
preset: recommended or preset: opinionated.
To disable this rule:
rules: no_equal_conditions: falseTo keep the rule on but skip certain paths, use per-rule exclude.
Related rules
Section titled “Related rules”no_equal_switch_case— Flag two switch branches with identical bodies.no_equal_then_else— Both branches of a condition are identical.avoid_constant_conditions— Detect comparisons where both sides are constants.avoid_negated_conditions— State the positive case first in an if/else.