Require const declarations for variables that are never reassigned after declared

Proprietary

Replaces let with const for declarations whose bindings are never reassigned, e.g. let a = 3; becomes const a = 3;, including for-in/for-of loop variables and fully constant destructuring patterns. A top-level let in a file that is not a module is left unchanged, as other scripts may reassign it, and so is a declaration in a block that uses eval, which may assign it. Replicates the autofix of the ESLint rule prefer-const under its default options.

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

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