requireEarlyReturn

Requires to return early in a function.

Types: Boolean

Values:

  • true: disallow to use of else if the corresponding if block contain a return.

Example

"requireEarlyReturn": true
Valid
function test() {
    if (x) {
        return x;
    }
    return y;
}
Invalid
function test() {
    if (x) {
        return x;
    } else {
        return y;
    }
}
Rule source
Test source