Disallow else blocks after return statements in if statements

Proprietary

Removes the unnecessary else when every branch of the preceding if/else if chain ends in a return, unwrapping the else body into the enclosing statement list. For example, if (x) { return y; } else { return z; } becomes if (x) { return y; } return z;. Replicates the autofix of the ESLint rule no-else-return under its default options.

org.openrewrite.javascript.cleanup.NoElseReturn
mod run . --recipe=org.openrewrite.javascript.cleanup.NoElseReturn

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.