Skip to content

Commit

Permalink
fix(linter): rule unicorn/new-for-builtins do not look into `global…
Browse files Browse the repository at this point in the history
…s` (#9146)
  • Loading branch information
Sysix committed Feb 15, 2025
1 parent 490c77d commit b68e240
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/oxc_linter/src/rules/unicorn/new_for_builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,16 @@ fn is_expr_global_builtin<'a, 'b>(
) -> Option<&'b str> {
match expr {
Expression::Identifier(ident) => {
if !ctx.is_reference_to_global_variable(ident) {
if !ctx.scopes().root_unresolved_references().contains_key(ident.name.as_str()) {
return None;
}

if !ENFORCE_NEW_FOR_BUILTINS.contains(&ident.name)
&& !DISALLOW_NEW_FOR_BUILTINS.contains(&ident.name)
{
return None;
}

Some(ident.name.as_str())
}
match_member_expression!(Expression) => {
Expand Down

0 comments on commit b68e240

Please sign in to comment.