{"record":{"id":"c4d2d2b60557fa88","repo":"oxc-project/oxc","slug":"fn-name-cannot-be-called-as-a-constructor","errorCode":null,"errorMessage":"`{fn_name}` cannot be called as a constructor.","messagePattern":"`(.+?)` cannot be called as a constructor\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/eslint/no_new_native_nonconstructor.rs","lineNumber":9,"sourceCode":"use oxc_ast::{AstKind, ast::Expression};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn no_new_native_nonconstructor_diagnostic(fn_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"`{fn_name}` cannot be called as a constructor.\"))\n        .with_help(format!(\"Remove the `new` operator to call `{fn_name}` as a function.\"))\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoNewNativeNonconstructor;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow `new` operators with global non-constructor functions (`Symbol`, `BigInt`).\n    ///\n    /// This rule can be disabled for TypeScript code, as the TypeScript compiler\n    /// enforces this check.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Both `new Symbol` and `new BigInt` throw a type error because they are","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_new_native_nonconstructor.rs#L1-L27","documentation":"Lint diagnostic from eslint/no-new-native-nonconstructor: new was used on a builtin that is not a constructor (e.g. new Symbol() or new BigInt()). These throw a TypeError at runtime since the spec defines them as non-constructable functions.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/eslint/no_new_native_nonconstructor.rs:9 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the new operator and call the builtin as a function, e.g. Symbol('x')"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}