newNativeNonConstructors
Disallows using
newwith global non-constructor functions like Symbol and BigInt.
✅ This rule is included in the ts untyped preset.
The global Symbol and BigInt functions are not constructors and will throw a TypeError when called with the new keyword.
These functions should be called directly without new to create their respective values.
Examples
Section titled “Examples”const symbol = new Symbol("description");const bigNumber = new BigInt(42);function create() { return new BigInt(100);}const symbol = Symbol("description");const bigNumber = BigInt(42);function create() { return BigInt(100);}Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you have globally overridden BigInt and/or Symbol with classes that are meant to be used as constructors, you may want to disable this rule.
However, overriding these names is generally not recommended as it can cause confusion with the global functions.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noInvalidBuiltinInstantiation - Deno:
no-new-symbol - ESLint:
no-new-native-nonconstructor - Oxlint:
eslint/no-new-native-nonconstructor
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.