no-new-native-nonconstructor
Disallow new Symbol() and new BigInt()
error by default
Symbol and BigInt start with a capital letter but aren't constructors. new Symbol("id") and new BigInt(10) throw a TypeError when they run. Call them without new.
This rule is on by default in JavaScript files. It's off in TypeScript files, where TypeScript reports the same mistake.
Configure#
On by default as an error. To turn it off:
bunfig.toml
[lint.rules]
"no-new-native-nonconstructor" = "off" # or "warn"Examples#
example.js1 problem
const id = new SymbolSymbol cannot be called as a constructor.("id");example.js1 problem
const total = new BigIntBigInt cannot be called as a constructor.(9007199254740991);example.jsNo problems
const id = Symbol("id");
const total = BigInt(9007199254740991);