{"id":43549807,"url":"https://github.com/syntax-tree/estree-util-visit","last_synced_at":"2026-02-03T19:14:50.703Z","repository":{"id":43396604,"uuid":"340004448","full_name":"syntax-tree/estree-util-visit","owner":"syntax-tree","description":"esast (and estree) utility to visit nodes","archived":false,"fork":false,"pushed_at":"2023-07-19T12:35:56.000Z","size":76,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2026-01-27T04:59:47.614Z","etag":null,"topics":["ecmascript","esast","esast-util","estree","estree-util","javascript"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syntax-tree.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"unifiedjs","open_collective":"unified"}},"created_at":"2021-02-18T09:51:31.000Z","updated_at":"2025-11-25T17:42:09.000Z","dependencies_parsed_at":"2024-06-18T18:51:43.151Z","dependency_job_id":null,"html_url":"https://github.com/syntax-tree/estree-util-visit","commit_stats":{"total_commits":39,"total_committers":2,"mean_commits":19.5,"dds":0.02564102564102566,"last_synced_commit":"eaf95f5ae0d28a3245cdc9ad3cbdba4130d1694f"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/syntax-tree/estree-util-visit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Festree-util-visit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Festree-util-visit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Festree-util-visit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Festree-util-visit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syntax-tree","download_url":"https://codeload.github.com/syntax-tree/estree-util-visit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Festree-util-visit/sbom","scorecard":{"id":863434,"data":{"date":"2025-08-11","repo":{"name":"github.com/syntax-tree/estree-util-visit","commit":"eaf95f5ae0d28a3245cdc9ad3cbdba4130d1694f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.1,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/30 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":"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":"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":"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":"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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/bb.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/estree-util-visit/bb.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/estree-util-visit/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/estree-util-visit/main.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/estree-util-visit/main.yml/main?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/main.yml:15","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   1 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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/bb.yml:1","Warn: no topLevel permission defined: .github/workflows/main.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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: license:0","Info: FSF or OSI recognized license: MIT License: license:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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":"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":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"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":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: github.com/syntax-tree/.github/security.md:1","Info: Found linked content: github.com/syntax-tree/.github/security.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/syntax-tree/.github/security.md:1","Info: Found text in security policy: github.com/syntax-tree/.github/security.md:1"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 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-24T02:00:17.141Z","repository_id":43396604,"created_at":"2025-08-24T02:00:17.141Z","updated_at":"2025-08-24T02:00:17.141Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29054205,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T15:43:47.601Z","status":"ssl_error","status_checked_at":"2026-02-03T15:43:46.709Z","response_time":96,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ecmascript","esast","esast-util","estree","estree-util","javascript"],"created_at":"2026-02-03T19:12:39.532Z","updated_at":"2026-02-03T19:14:44.634Z","avatar_url":"https://github.com/syntax-tree.png","language":"JavaScript","readme":"# estree-util-visit\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n[estree][] (and [esast][]) utility to visit nodes.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`visit(tree, visitor|visitors)`](#visittree-visitorvisitors)\n    *   [`CONTINUE`](#continue)\n    *   [`EXIT`](#exit)\n    *   [`SKIP`](#skip)\n    *   [`Action`](#action)\n    *   [`ActionTuple`](#actiontuple)\n    *   [`Index`](#index)\n    *   [`Visitor`](#visitor)\n    *   [`Visitors`](#visitors)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package is a utility that helps you walk the tree.\n\n## When should I use this?\n\nThis package helps when dealing with JavaScript ASTs.\nUse [`unist-util-visit`][unist-util-visit] for other unist ASTs.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install estree-util-visit\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {visit} from 'https://esm.sh/estree-util-visit@2'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {visit} from 'https://esm.sh/estree-util-visit@2?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\n```js\nimport {parse} from 'acorn'\nimport {visit} from 'estree-util-visit'\n\nconst tree = parse(\n  'export function x() { console.log(1 + \"2\"); process.exit(3) }',\n  {sourceType: 'module', ecmaVersion: 2020}\n)\n\nvisit(tree, function (node) {\n  if (node.type === 'Literal' \u0026\u0026 'value' in node) console.log(node.value)\n})\n\n// Both enter and leave:\nwalk(tree, {\n  enter(node, field, index, parents) { /* … */ },\n  leave(node, field, index, parents) { /* … */ }\n})\n```\n\nYields:\n\n```txt\n1\n\"2\"\n3\n```\n\n## API\n\nThis package exports the identifiers [`CONTINUE`][api-continue],\n[`EXIT`][api-exit],\n[`SKIP`][api-skip], and\n[`visit`][api-visit].\nThere is no default export.\n\n### `visit(tree, visitor|visitors)`\n\nVisit nodes, with ancestral information.\n\nThis algorithm performs [*depth-first*][depth-first]\n[*tree traversal*][tree-traversal] in [*preorder*][preorder] (**NLR**) and/or\n[*postorder*][postorder] (**LRN**).\n\nCompared to other estree walkers, this does not need a dictionary of which\nfields are nodes, because it ducktypes instead.\n\nWalking the tree is an intensive task.\nMake use of the return values of the visitor(s) when possible.\nInstead of walking a tree multiple times, walk it once, use\n[`unist-util-is`][is] to check if a node matches, and then perform different\noperations.\n\n###### Parameters\n\n*   `tree` ([`Node`][node])\n    — tree to traverse\n*   `visitor` ([`Visitor`][api-visitor])\n    — same as passing `{enter: visitor}`\n*   `visitors` ([`Visitors`][api-visitors])\n    — handle each node\n\n###### Returns\n\nNothing (`undefined`).\n\n### `CONTINUE`\n\nContinue traversing as normal (`symbol`).\n\n### `EXIT`\n\nStop traversing immediately (`symbol`).\n\n### `SKIP`\n\nDo not traverse this node’s children (`symbol`).\n\n### `Action`\n\nUnion of the action types (TypeScript type).\n\n###### Type\n\n```ts\ntype Action = typeof CONTINUE | typeof EXIT | typeof SKIP\n```\n\n### `ActionTuple`\n\nList with one or two values, the first an action, the second an index\n(TypeScript type).\n\n###### Type\n\n```ts\ntype ActionTuple = [\n  (Action | null | undefined | void)?,\n  (Index | null | undefined)?\n]\n```\n\n### `Index`\n\nMove to the sibling at `index` next (after node itself is completely\ntraversed), when moving in an array (TypeScript type).\n\nUseful if mutating the tree, such as removing the node the visitor is currently\non, or any of its previous siblings.\nResults less than 0 or greater than or equal to `children.length` stop\ntraversing the parent.\n\n###### Type\n\n```ts\ntype Index = number\n```\n\n### `Visitor`\n\nHandle a node (TypeScript type).\n\nVisitors are free to transform `node`.\nThey can also transform the parent of node (the last of `ancestors`).\n\nReplacing `node` itself, if `SKIP` is not returned, still causes its\ndescendants to be walked (which is a bug).\n\nWhen adding or removing previous siblings of `node`, the `Visitor` should\nreturn a new `Index` to specify the sibling to traverse after `node` is\ntraversed.\nAdding or removing next siblings of `node` is handled as expected without\nneeding to return a new `Index`.\n\n###### Parameters\n\n*   `node` ([`Node`][node])\n    — found node\n*   `key` (`string` or `undefined`)\n    — field at which `node` lives in its parent (or where a list of nodes\n    lives)\n*   `index` (`number` or `undefined`)\n    — index where `node` lives if `parent[key]` is an array\n*   `ancestors` ([`Array\u003cNode\u003e`][node])\n    — ancestors of `node`\n\n###### Returns\n\nWhat to do next ([`Action`][api-action], [`Index`][api-index], or\n[`ActionTuple`][api-action-tuple], optional).\n\nAn `Index` is treated as a tuple of `[CONTINUE, Index]`.\nAn `Action` is treated as a tuple of `[Action]`.\n\nPassing a tuple back only makes sense if the `Action` is `SKIP`.\nWhen the `Action` is `EXIT`, that action can be returned.\nWhen the `Action` is `CONTINUE`, `Index` can be returned.\n\n### `Visitors`\n\nHandle nodes when entering (preorder) and leaving (postorder) (TypeScript\ntype).\n\n###### Fields\n\n*   `enter` ([`Visitor`][api-visitor], optional)\n    — handle nodes when entering (preorder)\n*   `leave` ([`Visitor`][api-visitor], optional)\n    — handle nodes when leaving (postorder)\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional types [`Action`][api-action],\n[`ActionTuple`][api-action-tuple],\n[`Index`][api-index],\n[`Visitor`][api-visitor], and\n[`Visitors`][api-visitors].\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `estree-util-visit@^2`,\ncompatible with Node.js 16.\n\n## Related\n\n*   [`unist-util-visit`](https://github.com/syntax-tree/unist-util-visit)\n    — walk any unist tree\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for\nways to get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definition --\u003e\n\n[build-badge]: https://github.com/syntax-tree/estree-util-visit/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/estree-util-visit/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/estree-util-visit.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/estree-util-visit\n\n[downloads-badge]: https://img.shields.io/npm/dm/estree-util-visit.svg\n\n[downloads]: https://www.npmjs.com/package/estree-util-visit\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size\u0026query=$.size.compressedSize\u0026url=https://deno.bundlejs.com/?q=estree-util-visit\n\n[size]: https://bundlejs.com/?q=estree-util-visit\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/syntax-tree/unist/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[health]: https://github.com/syntax-tree/.github\n\n[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/main/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md\n\n[esast]: https://github.com/syntax-tree/esast\n\n[estree]: https://github.com/estree/estree\n\n[depth-first]: https://github.com/syntax-tree/unist#depth-first-traversal\n\n[tree-traversal]: https://github.com/syntax-tree/unist#tree-traversal\n\n[preorder]: https://github.com/syntax-tree/unist#preorder\n\n[postorder]: https://github.com/syntax-tree/unist#postorder\n\n[is]: https://github.com/syntax-tree/unist-util-is\n\n[node]: https://github.com/syntax-tree/esast#node\n\n[unist-util-visit]: https://github.com/syntax-tree/unist-util-visit\n\n[api-continue]: #continue\n\n[api-action]: #action\n\n[api-action-tuple]: #actiontuple\n\n[api-exit]: #exit\n\n[api-index]: #index\n\n[api-skip]: #skip\n\n[api-visit]: #visittree-visitorvisitors\n\n[api-visitor]: #visitor\n\n[api-visitors]: #visitors\n","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Festree-util-visit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntax-tree%2Festree-util-visit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Festree-util-visit/lists"}