no-dead-branches
ProDead CodeDisallow if/ternary/while statements with literal conditions that create dead branches
no-dead-branches
Disallow if/ternary/while statements with literal conditions that create dead branches
Category: Dead Code | Tier: Pro
Why This Matters
AI generates conditional branches that can never execute -- duplicate conditions, contradictory checks, or branches after exhaustive matches. Dead branches bloat the code and mislead readers about possible program states.
Bad Code
// Branch can never be reached
const status = 'active';
if (status === 'active') {
activate();
} else if (status === 'active') {
// duplicate -- dead code
}
Good Code
// Each branch is reachable and meaningful
if (status === 'active') {
activate();
} else if (status === 'inactive') {
deactivate();
}
Configuration
This rule has no configuration options. It is enabled by default in lintmyai:recommended.