← Back

no-else-return warning

Disallow else blocks after return statements in if statements

Examples

❌  Incorrect

function foo() {
    if (x) {
        return a;
    } else if (y) {
        return b;
    } else {
        return c;
    }
}

✅  Correct

function foo() {
    if (x) {
        return a;
    }

    if (y) {
        return b;
    }

    return c;
}