{"record":{"id":"22c48e7d644c5c94","repo":"oxc-project/oxc","slug":"do-not-use-builtin-name-as-a-constructor","errorCode":null,"errorMessage":"Do not use `{builtin_name}` as a constructor","messagePattern":"Do not use `(.+?)` as a constructor","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/eslint/no_new_wrappers.rs","lineNumber":17,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{Argument, Expression, NewExpression},\n};\nuse 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    ///","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_new_wrappers.rs#L1-L35","documentation":"Lint diagnostic from eslint/no-new-wrappers: a primitive wrapper builtin (String, Number, Boolean) was used with new. Wrappers produce objects that behave subtly differently from primitives in comparisons and type checks; the rule wants literal/conversion forms instead.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/eslint/no_new_wrappers.rs:17 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the new operator and use the conversion function form, e.g. String(x)","Use literals (0, '', false) for primitive values"],"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-14T05:17:10.506Z"}