Skip to content

Commit 8b9cffa

Browse files
committed
fix(linter): rule unicorn/new-for-builtins do not look into globals
1 parent 2ffdd7a commit 8b9cffa

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

crates/oxc_linter/src/rules/unicorn/new_for_builtins.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,16 @@ fn is_expr_global_builtin<'a, 'b>(
101101
) -> Option<&'b str> {
102102
match expr {
103103
Expression::Identifier(ident) => {
104-
if !ctx.is_reference_to_global_variable(ident) {
104+
if !ctx.scopes().root_unresolved_references().contains_key(ident.name.as_str()) {
105105
return None;
106106
}
107+
108+
if !ENFORCE_NEW_FOR_BUILTINS.contains(&ident.name)
109+
&& !DISALLOW_NEW_FOR_BUILTINS.contains(&ident.name)
110+
{
111+
return None;
112+
}
113+
107114
Some(ident.name.as_str())
108115
}
109116
match_member_expression!(Expression) => {

0 commit comments

Comments
 (0)