Use object spread instead of Object.assign with an object literal first argument

Proprietary

Rewrites Object.assign({}, a, {b: 1}) to the equivalent object spread { ...a, b: 1} and unwraps single-argument calls such as Object.assign({foo: bar}) to a plain object literal, adding parentheses where a bare { would parse as a block. Calls that mutate a target (non-literal first argument), use spread arguments, or pass object literals containing getters/setters (computed keys included) are left unchanged, as are calls where an argument that may have side effects follows a non-literal source, since Object.assign evaluates every argument before copying while a spread copies each source in turn, and calls where a binding in scope shadows the global Object. Unlike ESLint, Object["assign"] and globalThis.Object.assign are left unchanged too. Replicates the autofix of the ESLint rule prefer-object-spread under its default options.

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

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