Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_array_constructor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use oxc_ast::ast::Expression;
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_semantic::IsGlobalReference;
use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};
Expand Down Expand Up @@ -62,10 +64,16 @@ impl Rule for NoArrayConstructor {
&new_expr.type_parameters,
false,
),
_ => return,
_ => {
return;
}
};

if callee.is_specific_id("Array")
let Expression::Identifier(ident) = &callee else {
return;
};

if ident.is_global_reference_name("Array", ctx.symbols())
&& arguments.len() != 1
&& type_parameters.is_none()
&& !optional
Expand Down Expand Up @@ -104,6 +112,7 @@ fn test() {
("Array?.<Foo>();", None),
("Array?.(0, 1, 2);", None),
("Array?.(x, y);", None),
("var Array; new Array;", None),
];

let fail = vec![
Expand Down