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 a binding in scope shadows the global Object. Replicates the autofix of the ESLint rule prefer-object-spread under its default options.

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

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