menu

no-duplicate-else-if

Disallow else-if conditions made unreachable by earlier conditions

An else-if condition that implies an earlier condition can never select its body. Instead, you SHOULD remove the unreachable branch or correct the conditions so each branch can be selected.

Reported

1function classify(value: int32): string {2    if (value > 0) {3        return "positive";4    } else if (value > 0 && value < 10) {5        return "small";6    }7    return "other";8}

Accepted

1function classify(value: int32): string {2    if (value > 0 && value < 10) {3        return "small";4    } else if (value > 0) {5        return "positive";6    }7    return "other";8}