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, and so are values with a TypeScript non-null assertion such as {x: x!}, whose ! the shorthand has no place for, {this: this}, which has no shorthand, {__proto__: __proto__}, whose shorthand defines an own property instead of setting the prototype, and functions with duplicate parameter names, which a method does not allow. A converted function can no longer be called with new and has no prototype; the ignoreConstructors option keeps functions with a constructor-like key. Replicates the autofix of the ESLint rule object-shorthand under its default options.

io.moderne.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=io.moderne.javascript.cleanup.ObjectShorthand

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