mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 20:28:58 +00:00
fix(linter): global variable check should always check builtin variables (#3973)
closes #3374
This commit is contained in:
parent
1eac3d244d
commit
dbbb6fca56
2 changed files with 8 additions and 4 deletions
|
|
@ -137,13 +137,16 @@ impl<'a> LintContext<'a> {
|
|||
}
|
||||
|
||||
pub fn env_contains_var(&self, var: &str) -> bool {
|
||||
if GLOBALS["builtin"].contains_key("var") {
|
||||
return true;
|
||||
}
|
||||
for env in self.env().iter() {
|
||||
let env = GLOBALS.get(env).unwrap_or(&GLOBALS["builtin"]);
|
||||
if env.get(var).is_some() {
|
||||
return true;
|
||||
if let Some(env) = GLOBALS.get(env) {
|
||||
if env.contains_key(var) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ fn test() {
|
|||
"class C { static { a; let a; } }",
|
||||
"class C { static { function a() {} a; } }",
|
||||
"class C { static { a; function a() {} } }",
|
||||
"String;Array;Boolean;"
|
||||
];
|
||||
|
||||
let fail = vec![
|
||||
|
|
|
|||
Loading…
Reference in a new issue