no-object-constructor
UnreleasedConfiguration
rslint.config.ts
Rule Details
Use of the Object constructor to construct a new empty object is generally discouraged in favor of object literal notation because of conciseness and because the Object global may be redefined. The exception is when the Object constructor is used to intentionally wrap a specified value which is passed as an argument.
This rule disallows calling the Object constructor without an argument.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Differences from ESLint
- When the object constructor call is fixed onto a new line right after certain TypeScript-only constructs — a type alias (
type T = Foo), an ambient or overload function declaration (declare function foo()), an import-equals declaration (import Foo = Bar), or anas/satisfiestype cast — rslint's suggested fix inserts a leading;that ESLint omits (e.g.type T = Foo\n;({})instead oftype T = Foo\n({})). The extra semicolon never changes the resulting code's behavior.