@@ -42,19 +42,22 @@ This specification is written in a [Web IDL][webidl]-like grammar.
4242
4343### Where this specification fits
4444
45- esast extends [ unist] [ ] , a format for syntax trees, to benefit from its
46- [ ecosystem of utilities] [ utilities ] .
45+ esast extends [ unist] [ ] ,
46+ a format for syntax trees,
47+ to benefit from its [ ecosystem of utilities] [ utilities ] .
4748There is one important difference with other implementations of unist: children
4849are added at fields other than the ` children ` array and the ` children ` field is
4950not used.
5051
5152esast relates to [ ESTree] [ ] in that the first is a superset of the latter.
5253Any tool that accepts an ESTree also supports esast.
5354
54- esast relates to [ JavaScript] [ ] , other than that it represents it, in that it
55- has an [ ecosystem of utilities] [ list-of-utilities ] for working with compliant
56- syntax trees in JavaScript.
57- However, esast is not limited to JavaScript and can be used in other programming
55+ esast relates to [ JavaScript] [ ] ,
56+ other than that it represents it,
57+ in that it has an [ ecosystem of utilities] [ list-of-utilities ] for working with
58+ compliantsyntax trees in JavaScript.
59+ However,
60+ esast is not limited to JavaScript and can be used in other programming
5861languages.
5962
6063esast relates to the [ unified] [ ] project in that esast syntax trees are used
@@ -64,17 +67,21 @@ throughout its ecosystem.
6467
6568ESTree is great but it is missing some things:
6669
67- * Trees can’t be roundtripped through ` JSON.parse(JSON.stringify(s)) ` ,
70+ * trees can’t be roundtripped through ` JSON.parse(JSON.stringify(s)) ` ,
6871 leading to cache troubles
69- * Columns are 0-indexed, whereas most text editors display 1-indexed
70- columns, leading to a tiny discrepancy or some math to display warnings
71- * There is no recommendation for range-based positional info,
72+ * columns are 0-indexed,
73+ whereas most text editors display 1-indexed columns,
74+ leading to a tiny discrepancy or some math to display warnings
75+ * there is no recommendation for range-based positional info,
7276 leading implementations to scatter them in different places
73- * There is no safe space for metadata,
77+ * there is no safe space for metadata,
7478 leading implementations to scatter them in different places
75- * There are no recommendations for how to handle JSX, comments, or raw values
79+ * there are no recommendations for how to handle JSX,
80+ comments,
81+ or raw values
7682
77- These are minor nits, which is why esast is a superset.
83+ These are minor nits,
84+ which is why esast is a superset.
7885
7986## Nodes
8087
@@ -85,8 +92,8 @@ extend interface Node <: UnistNode {}
8592```
8693
8794All esast nodes inherit from unist’s [ Node] [ unist-node ] and are otherwise the
88- same as their ESTree counterparts, with the exception of ` RegExpLiteral ` and
89- ` BigIntLiteral ` .
95+ same as their ESTree counterparts,
96+ with the exception of ` RegExpLiteral ` and ` BigIntLiteral ` .
9097
9198### ` RegExpLiteral `
9299
@@ -104,22 +111,27 @@ must be ignored.
104111
105112## Recommendations
106113
107- For JSX, follow the
114+ For JSX,
115+ follow the
108116[ JSX extension] ( https://github.com/facebook/jsx/blob/master/AST.md )
109117maintained in ` facebook/jsx ` .
110118
111- For type annotations, follow the
119+ For type annotations,
120+ follow the
112121[ Type annotations extension] ( https://github.com/estree/estree/blob/master/extensions/type-annotations.md )
113122maintained in ` estree/estree ` .
114123
115124` raw ` fields (added by most parsers) should not be used: they create an extra
116- source of truth, which is often not maintained.
125+ source of truth,
126+ which is often not maintained.
117127
118- ` start ` , ` end ` , and ` range ` fields should not be used.
128+ ` start ` ,
129+ ` end ` ,
130+ and ` range ` fields should not be used.
119131
120132` comments ` should not be added on nodes other that ` Program ` .
121- When adding comments, use the ` 'Block' ` (for ` /**/ ` ) or ` 'Line' ` (for ` // ` )
122- types.
133+ When adding comments,
134+ use the ` 'Block' ` (for ` /**/ ` ) or ` 'Line' ` (for ` // ` ) types.
123135Do not use ` leading ` or ` trailing ` fields on comment nodes.
124136
125137` tokens ` should not be used.
@@ -130,13 +142,15 @@ See the [unist glossary][glossary] but note of the following deviating terms.
130142
131143###### Child
132144
133- Node X is ** child** of node Y, if X is either referenced directly or referenced
134- in an array at a field on node Y.
145+ Node X is ** child** of node Y,
146+ if X is either referenced directly or referenced in an array at a field on
147+ node Y.
135148
136149###### Sibling
137150
138- Node X is a ** sibling** of node Y, if X and Y have the same parent (if any) and
139- X and Y are both referenced in an array at a field on node Y.
151+ Node X is a ** sibling** of node Y,
152+ if X and Y have the same parent (if any) and X and Y are both referenced in an
153+ array at a field on node Y.
140154
141155## List of utilities
142156
@@ -159,7 +173,8 @@ See the [unist list of utilities][utilities] for more utilities.
159173* [ ` esast-util-from-js ` ] ( https://github.com/syntax-tree/esast-util-from-js )
160174 — parse from JavaScript
161175
162- Please use either ` estree-util- ` (if it works with all ESTrees, preferred)
176+ Please use either ` estree-util- ` (if it works with all ESTrees,
177+ preferred)
163178or ` esast-util- ` (if it uses on esast specific features) as a prefix.
164179
165180See also the [ ` estree ` ] ( https://github.com/search?q=topic%3Aestree\& s=stars\& o=desc )
@@ -184,8 +199,9 @@ topic on GitHub.
184199
185200## Security
186201
187- As esast represents JS, and JS can open you up to a bunch of problems, esast is
188- also unsafe.
202+ As esast represents JS,
203+ and JS can open you up to a bunch of problems,
204+ esast is also unsafe.
189205Always be careful with user input.
190206
191207## Related
@@ -202,12 +218,17 @@ ways to get started.
202218See [ ` support.md ` ] [ support ] for ways to get help.
203219Ideas for new utilities and tools can be posted in [ ` syntax-tree/ideas ` ] [ ideas ] .
204220
205- A curated list of awesome syntax-tree, unist, mdast, esast, xast, and nlcst
206- resources can be found in [ awesome syntax-tree] [ awesome ] .
221+ A curated list of awesome ` syntax-tree ` ,
222+ unist,
223+ mdast,
224+ esast,
225+ xast,
226+ and nlcst resources can be found in [ awesome syntax-tree] [ awesome ] .
207227
208228This project has a [ code of conduct] [ coc ] .
209- By interacting with this repository, organization, or community you agree to
210- abide by its terms.
229+ By interacting with this repository,
230+ organization,
231+ or community you agree to abide by its terms.
211232
212233## Acknowledgments
213234
0 commit comments