Disallow redundant return statements

Proprietary

Removes return; statements that are in tail position of a function's control flow, where removal cannot change runtime behavior. Returns with a value, returns inside loops or finally blocks, returns in unreachable code, unbraced statement bodies (if (foo) return;), a return;; and a return with a comment before its semicolon are left unchanged. Unlike ESLint, the line left empty is removed too. Replicates the autofix of the ESLint rule no-useless-return under its default options.

io.moderne.javascript.cleanup.NoUselessReturn
mod run . --recipe=io.moderne.javascript.cleanup.NoUselessReturn

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