{"record":{"id":"bfc9e8af7793327b","repo":"oxc-project/oxc","slug":"builtin-name-is-not-a-constructor","errorCode":null,"errorMessage":"`{builtin_name}` is not a constructor","messagePattern":"`(.+?)` is not a constructor","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/eslint/no_new_wrappers.rs","lineNumber":23,"sourceCode":"use oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    fixer::{RuleFix, RuleFixer},\n    rule::Rule,\n};\n\nfn no_new_wrappers_diagnostic(builtin_name: &str, new_span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Do not use `{builtin_name}` as a constructor\"))\n        .with_help(\"Remove the `new` operator.\")\n        .with_label(new_span)\n}\n\nfn not_a_constructor_diagnostic(builtin_name: &str, new_span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"`{builtin_name}` is not a constructor\"))\n        .with_help(\"Remove the `new` operator.\")\n        .with_label(new_span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoNewWrappers;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow `new` operators with the `String`, `Number`, and `Boolean` objects.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// The first problem is that primitive wrapper objects are, in fact,\n    /// objects. That means `typeof` will return `\"object\"` instead of `\"string\"`,\n    /// `\"number\"`, or `\"boolean\"`.  The second problem comes with boolean\n    /// objects. Every object is truthy, that means an instance of `Boolean`","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_new_wrappers.rs#L5-L41","documentation":"Lint diagnostic from eslint/no-new-wrappers (not_a_constructor_diagnostic): new was applied to a builtin that is callable but has no constructor form in this context (e.g. new Symbol()/new BigInt()), which throws a TypeError at runtime before any wrapping can happen.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/eslint/no_new_wrappers.rs:23 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Drop new and call the builtin directly, e.g. Symbol(), BigInt(1)"],"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"}