File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
apps/oxlint/src-js/plugins Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -165,11 +165,15 @@ export function isGlobalReference(node: ESTree.Node): boolean {
165165 return false ;
166166 }
167167
168+ // If the identifier is a reference to a global variable, the global scope should have a variable with the name.
168169 const variable = SOURCE_CODE . scopeManager . globalScope . set . get ( name ) ;
170+
171+ // Global variables are not defined by any node, so they should have no definitions.
169172 if ( ! variable || variable . defs . length > 0 ) {
170173 return false ;
171174 }
172175
176+ // If there is a variable by the same name exists in the global scope, we need to check our node is one of its references.
173177 const { references } = variable ;
174178
175179 for ( let i = 0 ; i < references . length ; i ++ ) {
You can’t perform that action at this time.
0 commit comments