{"record":{"id":"7ca62653d4ae1756","repo":"oxc-project/oxc","slug":"disallow-calls-to-the-object-constructor-without","errorCode":null,"errorMessage":"Disallow calls to the `Object` constructor without an argument","messagePattern":"Disallow calls to the `Object` constructor without an argument","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/eslint/no_object_constructor.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_object_constructor_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Disallow calls to the `Object` constructor without an argument\")\n        .with_help(\"Use object literal notation {} instead\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoObjectConstructor;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow calls to the Object constructor without an argument.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Use of the Object constructor to construct a new empty object is generally discouraged in favor of object literal notation because of conciseness and because the Object global may be redefined. The exception is when the Object constructor is used to intentionally wrap a specified value which is passed as an argument.\n    ///\n    /// ### Examples\n    ///","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs#L1-L27","documentation":"Lint diagnostic from eslint/no-object-constructor: Object was called with no arguments. new Object()/Object() returns an empty object exactly like a literal but is more verbose and obscures intent; the object literal is the idiomatic form.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/eslint/no_object_constructor.rs:9 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use an object literal: const o = {}"],"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"}