Detect Global Variables in JavaScript ASTs

JSON →
library 7.0.1 ·javascript
verified May 27, 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 40
actors 7 distinct systems
last hit 4d ago human
MetaBot
4
GPTBot
2
Amazonbot
2
Script
1
Search engines
6
Humans
17

top countries 🇺🇸 United States · 🇸🇬 Singapore · 🇩🇪 Germany · 🇨🇦 Canada · VN