Skip to content

objectCalls

Prefer {} object literal notation or Object.create instead of calling or constructing Object.

✅ This rule is included in the ts stylistic preset.

Calling or constructing the global Object directly is unnecessarily verbose and less idiomatic than using object literal syntax. Object literal notation {} is the preferred and more concise way to create plain objects in JavaScript and TypeScript.

const emptyObject = new Object();
const emptyObject = Object();
const config = new Object({ key: "value" });
const config = Object({ key: "value" });

This rule is not configurable.

If you have an existing codebase style that would be difficult to migrate away from, such as for consistency preferences with legacy code, you might find it difficult to onboard to this rule. Alternately, if you target a legacy runtime with behavioral quirks where object literals behave differently than Object() calls, this rule might be counterproductive for you.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.