ESLint Scope is the ECMAScript scope analyzer used in ESLint, forked from escope. The current stable version is 9.1.2, with regular releases as part of the ESLint monorepo. It analyzes ESTree-compliant ASTs to produce a ScopeManager with variable scopes, references, and definitions. Key differentiators include deep integration with ESLint, support for JSX, modern ECMAScript features, and both ESM and CommonJS module analysis. It ships with TypeScript types since v9.1.0 and requires Node.js ^20.19.0 || ^22.13.0 || >=24.
npm install eslint-scopeVerified import paths — ran on the pinned version, not inferred.
Parses JavaScript code with espree, analyzes scopes with eslint-scope, and logs global and function scope variables.
Update Node.js to a supported version (20.19.0+, 22.13.0+, or 24+).
Change 'import eslintScope from "eslint-scope"' to 'import * as eslintScope from "eslint-scope"'.
Always check that the return value is not null before using it.
Avoid relying on optimistic scope analysis; use default behavior.
Provide the same ecmaVersion to both the parser and eslint-scope.analyze().
Replace 'import eslintScope from "eslint-scope"' with 'import * as eslintScope from "eslint-scope"'.
Ensure 'eslint-scope' is listed in package.json dependencies and run npm install. For .mjs files, use ESM import syntax.
Use scopeManager.acquire(node), not scope.acquire(node).
Set sourceType to either "script" or "module" (e.g., sourceType: "module").