Skip to content
← Back to rules

eslint/no-new-native-nonconstructor Correctness

✅ This rule is turned on by default.

What it does ​

Disallow new operators with global non-constructor functions (Symbol, BigInt).

This rule can be disabled for TypeScript code, as the TypeScript compiler enforces this check.

Why is this bad? ​

Both new Symbol and new BigInt throw a type error because they are functions and not classes. It is easy to make this mistake by assuming the uppercase letters indicate classes.

Examples ​

Examples of incorrect code for this rule:

js
// throws a TypeError
let foo = new Symbol("foo");

// throws a TypeError
let result = new BigInt(9007199254740991);

Examples of correct code for this rule:

js
let foo = Symbol("foo");

let result = BigInt(9007199254740991);

How to use ​

To enable this rule using the config file or in the CLI, you can use:

json
{
  "rules": {
    "no-new-native-nonconstructor": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  rules: {
    "no-new-native-nonconstructor": "error",
  },
});
bash
oxlint --deny no-new-native-nonconstructor

Version ​

This rule was added in v0.3.3.

References ​