{"id":13716507,"url":"https://github.com/syntax-tree/esast","last_synced_at":"2026-02-03T19:14:23.133Z","repository":{"id":43407468,"uuid":"338856266","full_name":"syntax-tree/esast","owner":"syntax-tree","description":"ECMAScript Abstract Syntax Tree format","archived":false,"fork":false,"pushed_at":"2024-10-04T13:03:16.000Z","size":29,"stargazers_count":50,"open_issues_count":0,"forks_count":1,"subscribers_count":9,"default_branch":"main","last_synced_at":"2024-11-14T04:34:50.115Z","etag":null,"topics":["ast","ecmascript","es","esast","estree","javascript","js","syntax-tree","unist"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syntax-tree.png","metadata":{"funding":{"github":"unifiedjs","open_collective":"unified"},"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2021-02-14T17:06:56.000Z","updated_at":"2024-11-10T12:40:11.000Z","dependencies_parsed_at":"2024-11-14T07:15:10.928Z","dependency_job_id":null,"html_url":"https://github.com/syntax-tree/esast","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fesast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fesast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fesast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fesast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syntax-tree","download_url":"https://codeload.github.com/syntax-tree/esast/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252823493,"owners_count":21809705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","ecmascript","es","esast","estree","javascript","js","syntax-tree","unist"],"created_at":"2024-08-03T00:01:11.120Z","updated_at":"2026-02-03T19:14:19.753Z","avatar_url":"https://github.com/syntax-tree.png","language":null,"readme":"\u003c!--lint disable no-html--\u003e\n\n# [![esast][logo]][site]\n\n**E**CMA**S**cript **A**bstract **S**yntax **T**ree format.\n\n***\n\n**esast** is a specification for representing [JavaScript][] as an abstract\n[syntax tree][syntax-tree].\nIt implements the **[unist][]** spec.\n\nThis document may not be released.\nSee [releases][] for released documents.\nThe latest released version is [`1.0.0`][latest].\n\n## Contents\n\n* [Introduction](#introduction)\n  * [Where this specification fits](#where-this-specification-fits)\n  * [ESTree](#estree)\n* [Nodes](#nodes)\n  * [`Node`](#node)\n  * [`RegExpLiteral`](#regexpliteral)\n  * [`BigIntLiteral`](#bigintliteral)\n* [Recommendations](#recommendations)\n* [Glossary](#glossary)\n* [List of utilities](#list-of-utilities)\n* [References](#references)\n* [Security](#security)\n* [Related](#related)\n* [Contribute](#contribute)\n* [Acknowledgments](#acknowledgments)\n* [License](#license)\n\n## Introduction\n\nThis document defines a format for representing ECMAScript as an [abstract\nsyntax tree][syntax-tree].\nDevelopment of esast started in February 2021.\nThis specification is written in a [Web IDL][webidl]-like grammar.\n\n### Where this specification fits\n\nesast extends [unist][],\na format for syntax trees,\nto benefit from its [ecosystem of utilities][utilities].\nThere is one important difference with other implementations of unist: children\nare added at fields other than the `children` array and the `children` field is\nnot used.\n\nesast relates to [ESTree][] in that the first is a superset of the latter.\nAny tool that accepts an ESTree also supports esast.\n\nesast relates to [JavaScript][],\nother than that it represents it,\nin that it has an [ecosystem of utilities][list-of-utilities] for working with\ncompliantsyntax trees in JavaScript.\nHowever,\nesast is not limited to JavaScript and can be used in other programming\nlanguages.\n\nesast relates to the [unified][] project in that esast syntax trees are used\nthroughout its ecosystem.\n\n### ESTree\n\nESTree is great but it is missing some things:\n\n* trees can’t be roundtripped through `JSON.parse(JSON.stringify(s))`,\n  leading to cache troubles\n* columns are 0-indexed,\n  whereas most text editors display 1-indexed columns,\n  leading to a tiny discrepancy or some math to display warnings\n* there is no recommendation for range-based positional info,\n  leading implementations to scatter them in different places\n* there is no safe space for metadata,\n  leading implementations to scatter them in different places\n* there are no recommendations for how to handle JSX,\n  comments,\n  or raw values\n\nThese are minor nits,\nwhich is why esast is a superset.\n\n## Nodes\n\n### `Node`\n\n```idl\nextend interface Node \u003c: UnistNode {}\n```\n\nAll esast nodes inherit from unist’s [Node][unist-node] and are otherwise the\nsame as their ESTree counterparts,\nwith the exception of `RegExpLiteral` and `BigIntLiteral`.\n\n### `RegExpLiteral`\n\nThe `regex` field on\n[`RegExpLiteral`](https://github.com/estree/estree/blob/master/es5.md#regexpliteral)\nmust be used whereas the `value` field of such literals should be `null` and\nmust be ignored.\n\n### `BigIntLiteral`\n\nThe `bigint` field on\n[`BigIntLiteral`](https://github.com/estree/estree/blob/master/es2020.md#bigintliteral)\nmust be used whereas the `value` field of such literals should be `null` and\nmust be ignored.\n\n## Recommendations\n\nFor JSX,\nfollow the\n[JSX extension](https://github.com/facebook/jsx/blob/master/AST.md)\nmaintained in `facebook/jsx`.\n\nFor type annotations,\nfollow the\n[Type annotations extension](https://github.com/estree/estree/blob/master/extensions/type-annotations.md)\nmaintained in `estree/estree`.\n\n`raw` fields (added by most parsers) should not be used: they create an extra\nsource of truth,\nwhich is often not maintained.\n\n`start`,\n`end`,\nand `range` fields should not be used.\n\n`comments` should not be added on nodes other that `Program`.\nWhen adding comments,\nuse the `'Block'` (for `/**/`) or `'Line'` (for `//`) types.\nDo not use `leading` or `trailing` fields on comment nodes.\n\n`tokens` should not be used.\n\n## Glossary\n\nSee the [unist glossary][glossary] but note of the following deviating terms.\n\n###### Child\n\nNode X is **child** of node Y,\nif X is either referenced directly or referenced in an array at a field on\nnode Y.\n\n###### Sibling\n\nNode X is a **sibling** of node Y,\nif X and Y have the same parent (if any) and X and Y are both referenced in an\narray at a field on node Y.\n\n## List of utilities\n\nSee the [unist list of utilities][utilities] for more utilities.\n\n* [`estree-util-attach-comments`](https://github.com/syntax-tree/estree-util-attach-comments)\n  — attach comments to estree nodes\n* [`estree-util-build-jsx`](https://github.com/syntax-tree/estree-util-build-jsx)\n  — transform JSX to function calls\n* [`estree-util-is-identifier-name`](https://github.com/syntax-tree/estree-util-is-identifier-name)\n  — check if something can be an identifier name\n* [`estree-util-value-to-estree`](https://github.com/remcohaszing/estree-util-value-to-estree)\n  — convert a JavaScript value to an estree expression\n* [`estree-util-to-js`](https://github.com/syntax-tree/estree-util-to-js)\n  — serialize as JavaScript\n* [`estree-util-visit`](https://github.com/syntax-tree/estree-util-visit)\n  — visit nodes\n* [`esast-util-from-estree`](https://github.com/syntax-tree/esast-util-from-estree)\n  — transform from estree\n* [`esast-util-from-js`](https://github.com/syntax-tree/esast-util-from-js)\n  — parse from JavaScript\n\nPlease use either `estree-util-` (if it works with all ESTrees,\npreferred)\nor `esast-util-` (if it uses on esast specific features) as a prefix.\n\nSee also the [`estree`](https://github.com/search?q=topic%3Aestree\\\u0026s=stars\\\u0026o=desc)\ntopic on GitHub.\n\n## References\n\n* **unist**:\n  [Universal Syntax Tree][unist].\n  T. Wormer; et al.\n* **JavaScript**:\n  [ECMAScript Language Specification][javascript].\n  Ecma International.\n* **JSON**\n  [The JavaScript Object Notation (JSON) Data Interchange Format][json],\n  T. Bray.\n  IETF.\n* **Web IDL**:\n  [Web IDL][webidl],\n  C. McCormack.\n  W3C.\n\n## Security\n\nAs esast represents JS,\nand JS can open you up to a bunch of problems,\nesast is also unsafe.\nAlways be careful with user input.\n\n## Related\n\n* [hast](https://github.com/syntax-tree/hast) — HTML\n* [mdast](https://github.com/syntax-tree/mdast) — Markdown\n* [nlcst](https://github.com/syntax-tree/nlcst) — Natural language\n* [xast](https://github.com/syntax-tree/xast) — XML\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.\nIdeas for new utilities and tools can be posted in [`syntax-tree/ideas`][ideas].\n\nA curated list of awesome `syntax-tree`,\nunist,\nmdast,\nesast,\nxast,\nand nlcst resources can be found in [awesome syntax-tree][awesome].\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository,\norganization,\nor community you agree to abide by its terms.\n\n## Acknowledgments\n\nThe initial release of this project was authored by\n**[@wooorm](https://github.com/wooorm)**.\n\n## License\n\n[CC-BY-4.0][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[health]: https://github.com/syntax-tree/.github\n\n[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md\n\n[awesome]: https://github.com/syntax-tree/awesome-syntax-tree\n\n[ideas]: https://github.com/syntax-tree/ideas\n\n[license]: https://creativecommons.org/licenses/by/4.0/\n\n[author]: https://wooorm.com\n\n[logo]: https://raw.githubusercontent.com/syntax-tree/esast/0164416/logo.svg?sanitize=true\n\n[site]: https://unifiedjs.com\n\n[releases]: https://github.com/syntax-tree/esast/releases\n\n[latest]: https://github.com/syntax-tree/esast/releases/tag/2.3.0\n\n[list-of-utilities]: #list-of-utilities\n\n[unist]: https://github.com/syntax-tree/unist\n\n[syntax-tree]: https://github.com/syntax-tree/unist#syntax-tree\n\n[javascript]: https://www.ecma-international.org/ecma-262/9.0/index.html\n\n[json]: https://tools.ietf.org/html/rfc7159\n\n[webidl]: https://heycam.github.io/webidl/\n\n[glossary]: https://github.com/syntax-tree/unist#glossary\n\n[utilities]: https://github.com/syntax-tree/unist#list-of-utilities\n\n[unified]: https://github.com/unifiedjs/unified\n\n[estree]: https://github.com/estree/estree\n\n[unist-node]: https://github.com/syntax-tree/unist#node\n","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":["esast utilities"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fesast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntax-tree%2Fesast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fesast/lists"}