new is applied to Symbol or BigInt, which throws
What it finds
new Symbol("id"), new BigInt(1): Symbol and BigInt make primitive values and are not constructors, so new throws a TypeError. They are called without it.
The name must refer to the global Symbol or BigInt, not to one the file declares or imports. The fix removes new where there are arguments; the code then no longer throws, so it is unsafe.
From the rule's source, new_non_constructor.rs.
const id = new Symbol("id");tx0 reports: new Symbol throws a TypeError; Symbol is called without newconst big = new BigInt(1);tx0 reports: new BigInt throwsconst bare = new Symbol;tx0 reports: new Symbol throwsconst ok = Symbol("id");const map = new Map(); function shadowed(Symbol: new (name: string) => object) { return new Symbol("x");} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/ts:new-non-constructor" = "off"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:new-non-constructor] reason="..."tx0 explain tx0/ts:new-non-constructor shows the same in the terminal. Found a false positive? Report it.