Require object literal shorthand syntax

Proprietary

Uses ES6 shorthand syntax in object literals: {x: x} becomes {x} and {a: function() {}} becomes {a() {}}, moving async and generator * modifiers in front of the key. Arrow functions, named function expressions, and destructuring patterns are left unchanged. Replicates the autofix of the ESLint rule object-shorthand under its default options.

org.openrewrite.javascript.cleanup.ObjectShorthand

Optional

Leave function expressions whose key looks like a constructor name unchanged, since a shorthand method cannot be called with new. A key looks like a constructor name when its first character other than _, $ or a digit is uppercase. Mirrors ESLint's ignoreConstructors option, and also applies to string-literal keys. Default is false.

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

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