source: imaps-frontend/node_modules/eslint-scope/README.md@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[d565449]1[![npm version](https://img.shields.io/npm/v/eslint-scope.svg)](https://www.npmjs.com/package/eslint-scope)
2[![Downloads](https://img.shields.io/npm/dm/eslint-scope.svg)](https://www.npmjs.com/package/eslint-scope)
3[![Build Status](https://github.com/eslint/eslint-scope/workflows/CI/badge.svg)](https://github.com/eslint/eslint-scope/actions)
4
5# ESLint Scope
6
7ESLint Scope is the [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm) scope analyzer used in ESLint. It is a fork of [escope](http://github.com/estools/escope).
8
9## Install
10
11```
12npm i eslint-scope --save
13```
14
15## 📖 Usage
16
17To use in an ESM file:
18
19```js
20import * as eslintScope from 'eslint-scope';
21```
22
23To use in a CommonJS file:
24
25```js
26const eslintScope = require('eslint-scope');
27```
28
29Example:
30
31```js
32import * as eslintScope from 'eslint-scope';
33import * as espree from 'espree';
34import estraverse from 'estraverse';
35
36const ast = espree.parse(code, { range: true });
37const scopeManager = eslintScope.analyze(ast);
38
39const currentScope = scopeManager.acquire(ast); // global scope
40
41estraverse.traverse(ast, {
42 enter (node, parent) {
43 // do stuff
44
45 if (/Function/.test(node.type)) {
46 currentScope = scopeManager.acquire(node); // get current function scope
47 }
48 },
49 leave(node, parent) {
50 if (/Function/.test(node.type)) {
51 currentScope = currentScope.upper; // set to parent scope
52 }
53
54 // do stuff
55 }
56});
57```
58
59## Contributing
60
61Issues and pull requests will be triaged and responded to as quickly as possible. We operate under the [ESLint Contributor Guidelines](http://eslint.org/docs/developer-guide/contributing), so please be sure to read them before contributing. If you're not sure where to dig in, check out the [issues](https://github.com/eslint/eslint-scope/issues).
62
63## Build Commands
64
65* `npm test` - run all linting and tests
66* `npm run lint` - run all linting
67
68## License
69
70ESLint Scope is licensed under a permissive BSD 2-clause license.
Note: See TracBrowser for help on using the repository browser.