{"name":"eslint-scope","description":"ECMAScript scope analyzer for ESLint","homepage":"https://github.com/eslint/js/blob/main/packages/eslint-scope/README.md","main":"./dist/eslint-scope.cjs","type":"module","exports":{".":{"import":"./lib/index.js","require":"./dist/eslint-scope.cjs"},"./package.json":"./package.json"},"version":"8.3.0","engines":{"node":"^18.18.0 || ^20.9.0 || >=21.1.0"},"repository":{"type":"git","url":"git+https://github.com/eslint/js.git"},"funding":"https://opencollective.com/eslint","bugs":{"url":"https://github.com/eslint/js/issues"},"license":"BSD-2-Clause","scripts":{"build":"rollup -c","build:update-version":"node tools/update-version.js","prepublishOnly":"npm run build:update-version && npm run build","pretest":"npm run build","release:generate:latest":"eslint-generate-release","release:generate:alpha":"eslint-generate-prerelease alpha","release:generate:beta":"eslint-generate-prerelease beta","release:generate:rc":"eslint-generate-prerelease rc","release:publish":"eslint-publish-release","test":"node Makefile.js test"},"dependencies":{"esrecurse":"^4.3.0","estraverse":"^5.2.0"},"devDependencies":{"@typescript-eslint/parser":"^8.7.0","c8":"^7.7.3","chai":"^4.3.4","eslint-release":"^3.2.0","eslint-visitor-keys":"^4.2.0","espree":"^10.3.0","mocha":"^9.0.1","npm-license":"^0.3.3","rollup":"^2.52.7","shelljs":"^0.8.5","typescript":"^5.4.2"},"_id":"eslint-scope@8.3.0","gitHead":"e01326a62008e678c9393518383256ab6a496936","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-pUNxi75F8MJ/GdeKtVLSbYg4ZI34J6C0C7sbL4YOp2exGwen7ZsuBqKzUhXd0qMQ362yET3z+uPwKeg/0C2XCQ==","shasum":"10cd3a918ffdd722f5f3f7b5b83db9b23c87340d","tarball":"http://registry-npm.ywwl.com/eslint-scope/download/eslint-scope-8.3.0.tgz","fileCount":14,"unpackedSize":155422,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/eslint-scope@8.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGhH/V+tayebtN88RS+3gBSUgOXCGmUN7+urF7CB0D4wAiA1HKC06Wjnu0oLE4v6o7QOuz5vS3d5kMirpY3gXKCYXg=="}],"size":28957,"noattachment":false,"key":"/eslint-scope/-/eslint-scope-8.3.0.tgz"},"_npmUser":{"name":"eslintbot","email":"contact@eslint.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/eslint-scope_8.3.0_1741380149656_0.7265196917718457"},"_hasShrinkwrap":false,"readme":"[![npm version](https://img.shields.io/npm/v/eslint-scope.svg)](https://www.npmjs.com/package/eslint-scope)\n[![Downloads](https://img.shields.io/npm/dm/eslint-scope.svg)](https://www.npmjs.com/package/eslint-scope)\n[![Build Status](https://github.com/eslint/js/workflows/CI/badge.svg)](https://github.com/eslint/js/actions)\n\n# ESLint Scope\n\nESLint 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).\n\n## Install\n\n```\nnpm i eslint-scope --save\n```\n\n## 📖 Usage\n\nTo use in an ESM file:\n\n```js\nimport * as eslintScope from 'eslint-scope';\n```\n\nTo use in a CommonJS file:\n\n```js\nconst eslintScope = require('eslint-scope');\n```\n\nIn order to analyze scope, you'll need to have an [ESTree](https://github.com/estree/estree) compliant AST structure to run it on. The primary method is `eslintScope.analyze()`, which takes two arguments:\n\n1. `ast` - the ESTree-compliant AST structure to analyze.\n2. `options` (optional) - Options to adjust how the scope is analyzed, including:\n  * `ignoreEval` (default: `false`) - Set to `true` to ignore all `eval()` calls (which would normally create scopes).\n  * `nodejsScope` (default: `false`) - Set to `true` to create a top-level function scope needed for CommonJS evaluation.\n  * `impliedStrict` (default: `false`) - Set to `true` to evaluate the code in strict mode even outside of modules and without `\"use strict\"`.\n  * `ecmaVersion` (default: `5`) - The version of ECMAScript to use to evaluate the code.\n  * `sourceType` (default: `\"script\"`) - The type of JavaScript file to evaluate. Change to `\"module\"` for ECMAScript module code.\n  * `childVisitorKeys` (default: `null`) - An object with visitor key information (like [`eslint-visitor-keys`](https://github.com/eslint/js/tree/main/packages/eslint-visitor-keys)). Without this, `eslint-scope` finds child nodes to visit algorithmically. Providing this option is a performance enhancement.\n  * `fallback` (default: `\"iteration\"`) - The strategy to use when `childVisitorKeys` is not specified. May be a function.\n  * `jsx` (default: `false`) - Enables the tracking of JSX components as variable references.\n\nExample:\n\n```js\nimport * as eslintScope from 'eslint-scope';\nimport * as espree from 'espree';\nimport estraverse from 'estraverse';\n\nconst options = {\n    ecmaVersion: 2022,\n    sourceType: \"module\"\n};\n\nconst ast = espree.parse(code, { range: true, ...options });\nconst scopeManager = eslintScope.analyze(ast, options);\n\nconst currentScope = scopeManager.acquire(ast);   // global scope\n\nestraverse.traverse(ast, {\n    enter (node, parent) {\n        // do stuff\n\n        if (/Function/.test(node.type)) {\n            currentScope = scopeManager.acquire(node);  // get current function scope\n        }\n    },\n    leave(node, parent) {\n        if (/Function/.test(node.type)) {\n            currentScope = currentScope.upper;  // set to parent scope\n        }\n\n        // do stuff\n    }\n});\n```\n\n## Contributing\n\nIssues 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/js/issues).\n\n## Security Policy\n\nWe work hard to ensure that ESLint Scope is safe for everyone and that security issues are addressed quickly and responsibly. Read the full [security policy](https://github.com/eslint/.github/blob/master/SECURITY.md).\n\n## Build Commands\n\n* `npm test` - run all linting and tests\n* `npm run lint` - run all linting\n\n## License\n\nESLint Scope is licensed under a permissive BSD 2-clause license.\n\n<!-- NOTE: This section is autogenerated. Do not manually edit.-->\n<!--sponsorsstart-->\n## Sponsors\n\nThe following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)\nto get your logo on our READMEs and [website](https://eslint.org/sponsors).\n\n<h3>Platinum Sponsors</h3>\n<p><a href=\"https://automattic.com\"><img src=\"https://images.opencollective.com/automattic/d0ef3e1/logo.png\" alt=\"Automattic\" height=\"128\"></a> <a href=\"https://www.airbnb.com/\"><img src=\"https://images.opencollective.com/airbnb/d327d66/logo.png\" alt=\"Airbnb\" height=\"128\"></a></p><h3>Gold Sponsors</h3>\n<p><a href=\"https://qlty.sh/\"><img src=\"https://images.opencollective.com/qltysh/33d157d/logo.png\" alt=\"Qlty Software\" height=\"96\"></a> <a href=\"https://trunk.io/\"><img src=\"https://images.opencollective.com/trunkio/fb92d60/avatar.png\" alt=\"trunk.io\" height=\"96\"></a> <a href=\"https://shopify.engineering/\"><img src=\"https://avatars.githubusercontent.com/u/8085\" alt=\"Shopify\" height=\"96\"></a></p><h3>Silver Sponsors</h3>\n<p><a href=\"https://vite.dev/\"><img src=\"https://images.opencollective.com/vite/e6d15e1/logo.png\" alt=\"Vite\" height=\"64\"></a> <a href=\"https://www.jetbrains.com/\"><img src=\"https://images.opencollective.com/jetbrains/fe76f99/logo.png\" alt=\"JetBrains\" height=\"64\"></a> <a href=\"https://liftoff.io/\"><img src=\"https://images.opencollective.com/liftoff/5c4fa84/logo.png\" alt=\"Liftoff\" height=\"64\"></a> <a href=\"https://stackblitz.com\"><img src=\"https://avatars.githubusercontent.com/u/28635252\" alt=\"StackBlitz\" height=\"64\"></a></p><h3>Bronze Sponsors</h3>\n<p><a href=\"https://cybozu.co.jp/\"><img src=\"https://images.opencollective.com/cybozu/933e46d/logo.png\" alt=\"Cybozu\" height=\"32\"></a> <a href=\"https://www.crosswordsolver.org/anagram-solver/\"><img src=\"https://images.opencollective.com/anagram-solver/2666271/logo.png\" alt=\"Anagram Solver\" height=\"32\"></a> <a href=\"https://icons8.com/\"><img src=\"https://images.opencollective.com/icons8/7fa1641/logo.png\" alt=\"Icons8\" height=\"32\"></a> <a href=\"https://discord.com\"><img src=\"https://images.opencollective.com/discordapp/f9645d9/logo.png\" alt=\"Discord\" height=\"32\"></a> <a href=\"https://www.gitbook.com\"><img src=\"https://avatars.githubusercontent.com/u/7111340\" alt=\"GitBook\" height=\"32\"></a> <a href=\"https://nolebase.ayaka.io\"><img src=\"https://avatars.githubusercontent.com/u/11081491\" alt=\"Neko\" height=\"32\"></a> <a href=\"https://nx.dev\"><img src=\"https://avatars.githubusercontent.com/u/23692104\" alt=\"Nx\" height=\"32\"></a> <a href=\"https://opensource.mercedes-benz.com/\"><img src=\"https://avatars.githubusercontent.com/u/34240465\" alt=\"Mercedes-Benz Group\" height=\"32\"></a> <a href=\"https://herocoders.com\"><img src=\"https://avatars.githubusercontent.com/u/37549774\" alt=\"HeroCoders\" height=\"32\"></a> <a href=\"https://www.lambdatest.com\"><img src=\"https://avatars.githubusercontent.com/u/171592363\" alt=\"LambdaTest\" height=\"32\"></a></p>\n<h3>Technology Sponsors</h3>\nTechnology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.\n<p><a href=\"https://netlify.com\"><img src=\"https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg\" alt=\"Netlify\" height=\"32\"></a> <a href=\"https://algolia.com\"><img src=\"https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg\" alt=\"Algolia\" height=\"32\"></a> <a href=\"https://1password.com\"><img src=\"https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg\" alt=\"1Password\" height=\"32\"></a></p>\n<!--sponsorsend-->\n","publish_time":1741380149837,"maintainers":[{"name":"openjsfoundation","email":"npm@openjsf.org"},{"name":"eslintbot","email":"contact@eslint.org"},{"name":"nzakas","email":"nicholas@nczconsulting.com"},{"name":"ivolodin","email":"ivolodin@gmail.com"}],"_cnpm_publish_time":1741380149837,"dist-tags":{"latest":"9.1.2","next":"4.0.0-rc.0","v3-latest":"3.7.3"}}