Skip to content

Commit ae58fac

Browse files
committed
handle null globalScope
1 parent 18c7f67 commit ae58fac

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

apps/oxlint/src-js/plugins/scope.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,11 @@ export function isGlobalReference(node: ESTree.Node): boolean {
165165
return false;
166166
}
167167

168+
const globalScope = SOURCE_CODE.scopeManager.scopes[0];
169+
if (!globalScope) return false;
170+
168171
// If the identifier is a reference to a global variable, the global scope should have a variable with the name.
169-
const variable = SOURCE_CODE.scopeManager.globalScope.set.get(name);
172+
const variable = globalScope.set.get(name);
170173

171174
// Global variables are not defined by any node, so they should have no definitions.
172175
if (!variable || variable.defs.length > 0) {

0 commit comments

Comments
 (0)