oxc-project/oxc · error · OxcDiagnostic
Disallow calls to the `Object` constructor without an argume
Error message
Disallow calls to the `Object` constructor without an argument
What it means
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.
Source
Thrown at crates/oxc_linter/src/rules/eslint/no_object_constructor.rs:9
use oxc_ast::{AstKind, ast::Expression};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use crate::{AstNode, context::LintContext, rule::Rule};
fn no_object_constructor_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Disallow calls to the `Object` constructor without an argument")
.with_help("Use object literal notation {} instead")
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct NoObjectConstructor;
declare_oxc_lint!(
/// ### What it does
///
/// Disallow calls to the Object constructor without an argument.
///
/// ### Why is this bad?
///
/// 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.
///
/// ### Examples
///View on GitHub (pinned to e1e7af627c)
Solutions
- Use an object literal: const o = {}
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/eslint/no_object_constructor.rs:9 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/7ca62653d4ae1756.
Report an issue: GitHub.