Preparing for system design interviews?  Try bugzed.com →

Detect Global Variables in JavaScript ASTs

JSON →
library 7.0.1 ·javascript
verified Jun 17, 2026

acorn-globals is a utility for identifying global variable references within JavaScript code by leveraging the Acorn AST parser. It traverses the Abstract Syntax Tree (AST) generated by Acorn to distinguish between locally declared variables and those that implicitly refer to the global scope. The package is currently at version 7.0.1 and appears to maintain an active release cadence, primarily driven by updates to its underlying Acorn dependency and bug fixes related to scope resolution (e.g., switch statement bodies, catch handlers). Its key differentiator is its focus solely on global variable detection based on AST analysis, providing precise lexical scope information without performing any runtime evaluation. It is particularly useful for static analysis tools, linters, and bundlers that need to understand variable leakage or undeclared globals.

total hits 39
actors 7 distinct systems
last hit 16d ago human
GPTBot
4
ByteDance
3
Script
1
Search engines
15
Humans
11

top countries 🇸🇬 Singapore · 🇺🇸 United States · 🇨🇦 Canada · 🇧🇷 Brazil · VN