{"id":15395039,"url":"https://github.com/goto-bus-stop/scope-analyzer","last_synced_at":"2026-03-05T02:31:06.104Z","repository":{"id":26847809,"uuid":"110863578","full_name":"goto-bus-stop/scope-analyzer","owner":"goto-bus-stop","description":"simple scope analysis for javascript ASTs","archived":false,"fork":false,"pushed_at":"2022-12-12T04:03:15.000Z","size":72,"stargazers_count":24,"open_issues_count":7,"forks_count":5,"subscribers_count":1,"default_branch":"default","last_synced_at":"2025-10-28T00:44:55.373Z","etag":null,"topics":["ast","javascript","variables"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goto-bus-stop.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-15T17:16:41.000Z","updated_at":"2025-08-24T04:20:34.000Z","dependencies_parsed_at":"2023-01-14T05:23:48.100Z","dependency_job_id":null,"html_url":"https://github.com/goto-bus-stop/scope-analyzer","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/goto-bus-stop/scope-analyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goto-bus-stop%2Fscope-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goto-bus-stop%2Fscope-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goto-bus-stop%2Fscope-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goto-bus-stop%2Fscope-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goto-bus-stop","download_url":"https://codeload.github.com/goto-bus-stop/scope-analyzer/tar.gz/refs/heads/default","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goto-bus-stop%2Fscope-analyzer/sbom","scorecard":{"id":442136,"data":{"date":"2025-08-11","repo":{"name":"github.com/goto-bus-stop/scope-analyzer","commit":"7ed5afff67fc392b8e8b4cd657e325331b9acb36"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 2/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/goto-bus-stop/scope-analyzer/ci.yml/default?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/goto-bus-stop/scope-analyzer/ci.yml/default?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/goto-bus-stop/scope-analyzer/ci.yml/default?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/goto-bus-stop/scope-analyzer/ci.yml/default?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:21","Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:35","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'default'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 10 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T05:48:55.329Z","repository_id":26847809,"created_at":"2025-08-19T05:48:55.330Z","updated_at":"2025-08-19T05:48:55.330Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30107201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T01:39:18.192Z","status":"online","status_checked_at":"2026-03-05T02:00:06.710Z","response_time":93,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ast","javascript","variables"],"created_at":"2024-10-01T15:25:26.319Z","updated_at":"2026-03-05T02:31:06.074Z","avatar_url":"https://github.com/goto-bus-stop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scope-analyzer\n\nsimple scope analysis for javascript ASTs. tracks scopes and collects references to variables.\n\nCaveats and/or todos:\n\n - May be missing edge cases.\n - Things like `label:`s are not considered at all, but ideally in the future they will!\n\n[![stability][stability-image]][stability-url]\n[![npm][npm-image]][npm-url]\n[![travis][travis-image]][travis-url]\n[![standard][standard-image]][standard-url]\n\n[stability-image]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square\n[stability-url]: https://nodejs.org/api/documentation.html#documentation_stability_index\n[npm-image]: https://img.shields.io/npm/v/scope-analyzer.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/scope-analyzer\n[travis-image]: https://img.shields.io/travis/goto-bus-stop/scope-analyzer.svg?style=flat-square\n[travis-url]: https://travis-ci.org/goto-bus-stop/scope-analyzer\n[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[standard-url]: http://npm.im/standard\n\n## Install\n\n```\nnpm install scope-analyzer\n```\n\n## Usage\n\nNote: AST nodes passed to `scope-analyzer` functions are expected to reference the parent node on a `node.parent` property.\nNodes from [falafel](https://github.com/substack/node-falafel) or [transform-ast](https://github.com/goto-bus-stop/transform-ast) have a `.parent` property, but others may not. You can use [estree-assign-parent](https://github.com/goto-bus-stop/estree-assign-parent) to quickly assign a parent property to all nodes in an AST.\n\n```js\nvar scan = require('scope-analyzer')\n\nvar ast = parse('...')\n// Initialize node module variables\nscan.createScope(ast, ['module', 'exports', '__dirname', '__filename'])\nscan.crawl(ast)\n\nvar binding = scan.getBinding(ast, 'exports')\nbinding.getReferences().forEach(function (reference) {\n  // Assume for the sake of the example that all references to `exports` are assignments like\n  // `exports.xyz = abc`\n  console.log('found export:', reference.parent.property.name)\n})\n```\n\n## API\n\n### `crawl(ast)`\n\nWalk the ast and analyze all scopes. This will immediately allow you to use the `get*` methods on any node in the tree.\n\n### `clear(ast)`\n\nClear scope information in all nodes of the AST.\n\n### `visitScope(node)`\n\nVisit a node to check if it initialises any scopes.\nFor example, a function declaration will initialise a new scope to hold bindings for its parameters.\nUse this if you are already walking the AST manually, and if you don't need the scope information during this walk.\n\n### `visitBinding(node)`\n\nVisit a node to check if it is a reference to an existing binding.\nIf it is, the reference is added to the parent scope.\nUse this if you are already walking the AST manually.\n\n### `createScope(node, bindings)`\n\nInitialise a new scope at the given node. `bindings` is an array of variable names.\nThis can be useful to make the scope analyzer aware of preexisting global variables.\nIn that case, call `createScope` on the root node with the names of globals:\n\n```js\nvar ast = parse('xyz')\nscopeAnalyzer.createScope(ast, ['HTMLElement', 'Notification', ...])\n```\n\n### `deleteScope(node)`\n\nDelete the scope initialised by node.\n\n### `scope(node)`\n\nGet the [Scope](#scope) initialised by the given node.\n\n### `getBinding(node)`\n\nGet the [Binding](#binding) referenced by the `Identifier` `node`.\n\n### Scope\n\n#### `scope.has(name)`\n\nCheck if this scope defines `name`.\n\n#### `scope.getBinding(name)`\n\nGet the [Binding](#binding) named `name` that is declared by this scope.\n\n#### `scope.getReferences(name)`\n\nGet a list of all nodes referencing the `name` binding that is declared by this scope.\n\n#### `scope.getUndeclaredNames()`\n\nGet a list of all names that were used in this scope, but not defined anywhere in the AST.\n\n#### `scope.forEach(cb(binding, name))`\n\nLoop over all bindings declared by this scope.\n\n#### `scope.forEachAvailable(cb(binding, name))`\n\nLoop over all bindings available to this scope, declared in this scope or any parent scope.\n\n### Binding\n\n#### `binding.definition`\n\nThe node that defined this binding. If this binding was not declared in the AST, `binding.definition` will be undefined.\n\n#### `binding.getReferences()`\n\nReturn an array of nodes that reference this binding.\n\n#### `binding.isReferenced()`\n\nCheck if the binding is referenced, i.e., if there are any identifier Nodes (other than `binding.definition`) referencing this binding.\n\n#### `binding.remove(node)`\n\nRemove a reference to this binding. Use this when you are replacing the node referencing the binding with something else.\n\n## License\n\n[Apache-2.0](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoto-bus-stop%2Fscope-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoto-bus-stop%2Fscope-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoto-bus-stop%2Fscope-analyzer/lists"}