An empty object is built by calling Object instead of writing {}

tx0/ts:object-constructor-callstrictwarningstyle

What it finds

new Object() builds an empty object, which {} writes shorter and without looking up a global that a script could have replaced.

Reported are new Object() and Object() calls of the global Object without arguments. The fix, which is safe, writes {}, in parentheses where a statement or an arrow body would otherwise start with a brace.

From the rule's source, object_constructor_call.rs.

Example from the rule's tests
export const a = new Object();tx0 reports: new Object() builds an empty objectexport const b = Object();tx0 reports: Object() builds an empty objectexport const c = Object.create(null);export const d = new Object(c);
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:object-constructor-call" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:object-constructor-call] reason="..."

tx0 explain tx0/ts:object-constructor-call shows the same in the terminal. Found a false positive? Report it.