Disallow if statements as the only statement in else blocks

Proprietary

Collapses an else block that contains nothing but an if statement into an else if. For example, else { if (b) { g(); } } becomes else if (b) { g(); }. Replicates the autofix of the ESLint rule no-lonely-if under its default options.

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

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