eslint-scope (7.2.2)

Published 2026-02-24 13:56:17 +00:00 by atheaadmin

Installation

registry=
npm install eslint-scope@7.2.2
"eslint-scope": "7.2.2"

About this package

npm version Downloads Build Status

ESLint Scope

ESLint Scope is the ECMAScript scope analyzer used in ESLint. It is a fork of escope.

Install

npm i eslint-scope --save

📖 Usage

To use in an ESM file:

import * as eslintScope from 'eslint-scope';

To use in a CommonJS file:

const eslintScope = require('eslint-scope');

Example:

import * as eslintScope from 'eslint-scope';
import * as espree from 'espree';
import estraverse from 'estraverse';

const ast = espree.parse(code, { range: true });
const scopeManager = eslintScope.analyze(ast);

const currentScope = scopeManager.acquire(ast);   // global scope

estraverse.traverse(ast, {
    enter (node, parent) {
        // do stuff

        if (/Function/.test(node.type)) {
            currentScope = scopeManager.acquire(node);  // get current function scope
        }
    },
    leave(node, parent) {
        if (/Function/.test(node.type)) {
            currentScope = currentScope.upper;  // set to parent scope
        }

        // do stuff
    }
});

Contributing

Issues and pull requests will be triaged and responded to as quickly as possible. We operate under the ESLint Contributor Guidelines, so please be sure to read them before contributing. If you're not sure where to dig in, check out the issues.

Build Commands

  • npm test - run all linting and tests
  • npm run lint - run all linting

License

ESLint Scope is licensed under a permissive BSD 2-clause license.

Dependencies

Dependencies

ID Version
esrecurse ^4.3.0
estraverse ^5.2.0

Development Dependencies

ID Version
@typescript-eslint/parser ^4.28.1
c8 ^7.7.3
chai ^4.3.4
eslint ^7.29.0
eslint-config-eslint ^7.0.0
eslint-plugin-jsdoc ^35.4.1
eslint-plugin-node ^11.1.0
eslint-release ^3.2.0
eslint-visitor-keys ^3.3.0
espree ^9.3.1
mocha ^9.0.1
npm-license ^0.3.3
rollup ^2.52.7
shelljs ^0.8.4
typescript ^4.3.5
Details
npm
2026-02-24 13:56:17 +00:00
0
BSD-2-Clause
latest
25 KiB
Assets (1)
Versions (3) View all
7.2.2 2026-02-24
4.0.3 2026-02-24
5.1.1 2026-02-24