Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: syntax-tree/esast
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.0
Choose a base ref
...
head repository: syntax-tree/esast
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 14 commits
  • 6 files changed
  • 2 contributors

Commits on Apr 14, 2021

  1. Add bb

    wooorm committed Apr 14, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    wooorm Titus
    Copy the full SHA
    509b190 View commit details
  2. Update dotfiles

    wooorm committed Apr 14, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    wooorm Titus
    Copy the full SHA
    f3e6859 View commit details

Commits on Jun 1, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    wooorm Titus
    Copy the full SHA
    91fdcb3 View commit details

Commits on Jul 19, 2021

  1. Add some utilities

    wooorm authored Jul 19, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    wooorm Titus
    Copy the full SHA
    0b97314 View commit details

Commits on Mar 3, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    wooorm Titus
    Copy the full SHA
    2339f56 View commit details

Commits on May 31, 2022

  1. Update dev-dependencies

    wooorm committed May 31, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    wooorm Titus
    Copy the full SHA
    71332cd View commit details
  2. Add improved docs

    wooorm committed May 31, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    wooorm Titus
    Copy the full SHA
    48f4cca View commit details

Commits on Feb 4, 2023

  1. Update dev-dependencies

    wooorm committed Feb 4, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    wooorm Titus
    Copy the full SHA
    f94fa08 View commit details

Commits on Oct 4, 2024

  1. Update dev-dependencies

    wooorm committed Oct 4, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    wooorm Titus
    Copy the full SHA
    8c75003 View commit details
  2. Add Actions

    wooorm committed Oct 4, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    wooorm Titus
    Copy the full SHA
    02a65c9 View commit details
  3. Refactor .npmrc

    wooorm committed Oct 4, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    wooorm Titus
    Copy the full SHA
    ed716f2 View commit details
  4. Refactor logo.svg

    wooorm committed Oct 4, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    wooorm Titus
    Copy the full SHA
    d25c36e View commit details
  5. Refactor package.json

    wooorm committed Oct 4, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    wooorm Titus
    Copy the full SHA
    a392fc6 View commit details
  6. Refactor docs

    wooorm committed Oct 4, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    wooorm Titus
    Copy the full SHA
    bf6b48c View commit details
Showing with 157 additions and 95 deletions.
  1. +13 −0 .github/workflows/bb.yml
  2. +14 −0 .github/workflows/main.yml
  3. +2 −0 .npmrc
  4. +4 −4 logo.svg
  5. +14 −14 package.json
  6. +110 −77 readme.md
13 changes: 13 additions & 0 deletions .github/workflows/bb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: unifiedjs/beep-boop-beta@main
with:
repo-token: ${{secrets.GITHUB_TOKEN}}
name: bb
on:
issues:
types: [closed, edited, labeled, opened, reopened, unlabeled]
pull_request_target:
types: [closed, edited, labeled, opened, reopened, unlabeled]
14 changes: 14 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: node
- run: npm install
- run: npm test
name: main
on:
- pull_request
- push
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore-scripts=true
package-lock=false
8 changes: 4 additions & 4 deletions logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"private": true,
"version": "1.0.0",
"description": "ecmascript abstract syntax tree",
"license": "MIT",
"keywords": [],
"repository": "syntax-tree/esast",
"bugs": "https://github.com/syntax-tree/esast/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"bugs": "https://github.com/syntax-tree/esast/issues",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"description": "ecmascript abstract syntax tree",
"devDependencies": {
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0"
},
"scripts": {
"format": "remark . -qfo",
"test": "npm run format"
"remark-cli": "^12.0.0",
"remark-preset-wooorm": "^10.0.0"
},
"keywords": [],
"license": "MIT",
"private": true,
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
}
},
"repository": "syntax-tree/esast",
"scripts": {
"format": "remark --frail --output --quiet -- .",
"test": "npm run format"
},
"version": "1.0.0"
}
187 changes: 110 additions & 77 deletions readme.md
Original file line number Diff line number Diff line change
@@ -8,30 +8,30 @@

**esast** is a specification for representing [JavaScript][] as an abstract
[syntax tree][syntax-tree].
It implements the [**unist**][unist] spec.
It implements the **[unist][]** spec.

This document may not be released.
See [releases][] for released documents.
The latest released version is [`1.0.0`][latest].

## Contents

* [Introduction](#introduction)
* [Where this specification fits](#where-this-specification-fits)
* [ESTree](#estree)
* [Nodes](#nodes)
* [`Node`](#node)
* [`RegExpLiteral`](#regexpliteral)
* [`BigIntLiteral`](#bigintliteral)
* [Recommendations](#recommendations)
* [Glossary](#glossary)
* [List of utilities](#list-of-utilities)
* [References](#references)
* [Security](#security)
* [Related](#related)
* [Contribute](#contribute)
* [Acknowledgments](#acknowledgments)
* [License](#license)
* [Introduction](#introduction)
* [Where this specification fits](#where-this-specification-fits)
* [ESTree](#estree)
* [Nodes](#nodes)
* [`Node`](#node)
* [`RegExpLiteral`](#regexpliteral)
* [`BigIntLiteral`](#bigintliteral)
* [Recommendations](#recommendations)
* [Glossary](#glossary)
* [List of utilities](#list-of-utilities)
* [References](#references)
* [Security](#security)
* [Related](#related)
* [Contribute](#contribute)
* [Acknowledgments](#acknowledgments)
* [License](#license)

## Introduction

@@ -42,19 +42,22 @@ This specification is written in a [Web IDL][webidl]-like grammar.

### Where this specification fits

esast extends [unist][], a format for syntax trees, to benefit from its
[ecosystem of utilities][utilities].
esast extends [unist][],
a format for syntax trees,
to benefit from its [ecosystem of utilities][utilities].
There is one important difference with other implementations of unist: children
are added at fields other than the `children` array and the `children` field is
not used.

esast relates to [ESTree][] in that the first is a superset of the latter.
Any tool that accepts an ESTree also supports esast.

esast relates to [JavaScript][], other than that it represents it, in that it
has an [ecosystem of utilities][list-of-utilities] for working with compliant
syntax trees in JavaScript.
However, esast is not limited to JavaScript and can be used in other programming
esast relates to [JavaScript][],
other than that it represents it,
in that it has an [ecosystem of utilities][list-of-utilities] for working with
compliantsyntax trees in JavaScript.
However,
esast is not limited to JavaScript and can be used in other programming
languages.

esast relates to the [unified][] project in that esast syntax trees are used
@@ -64,17 +67,21 @@ throughout its ecosystem.

ESTree is great but it is missing some things:

* Trees can’t be roundtripped through `JSON.parse(JSON.stringify(s))`,
leading to cache troubles
* Columns are 0-indexed, whereas most text editors display 1-indexed
columns, leading to a tiny discrepancy or some math to display warnings
* There is no recommendation for range-based positional info,
leading implementations to scatter them in different places
* There is no safe space for metadata,
leading implementations to scatter them in different places
* There are no recommendations for how to handle JSX, comments, or raw values

These are minor nits, which is why esast is a superset.
* trees can’t be roundtripped through `JSON.parse(JSON.stringify(s))`,
leading to cache troubles
* columns are 0-indexed,
whereas most text editors display 1-indexed columns,
leading to a tiny discrepancy or some math to display warnings
* there is no recommendation for range-based positional info,
leading implementations to scatter them in different places
* there is no safe space for metadata,
leading implementations to scatter them in different places
* there are no recommendations for how to handle JSX,
comments,
or raw values

These are minor nits,
which is why esast is a superset.

## Nodes

@@ -85,8 +92,8 @@ extend interface Node <: UnistNode {}
```

All esast nodes inherit from unist’s [Node][unist-node] and are otherwise the
same as their ESTree counterparts, with the exception of `RegExpLiteral` and
`BigIntLiteral`.
same as their ESTree counterparts,
with the exception of `RegExpLiteral` and `BigIntLiteral`.

### `RegExpLiteral`

@@ -104,22 +111,27 @@ must be ignored.

## Recommendations

For JSX, follow the
For JSX,
follow the
[JSX extension](https://github.com/facebook/jsx/blob/master/AST.md)
maintained in `facebook/jsx`.

For type annotations, follow the
For type annotations,
follow the
[Type annotations extension](https://github.com/estree/estree/blob/master/extensions/type-annotations.md)
maintained in `estree/estree`.

`raw` fields (added by most parsers) should not be used: they create an extra
source of truth, which is often not maintained.
source of truth,
which is often not maintained.

`start`, `end`, and `range` fields should not be used.
`start`,
`end`,
and `range` fields should not be used.

`comments` should not be added on nodes other that `Program`.
When adding comments, use the `'Block'` (for `/**/`) or `'Line'` (for `//`)
types.
When adding comments,
use the `'Block'` (for `/**/`) or `'Line'` (for `//`) types.
Do not use `leading` or `trailing` fields on comment nodes.

`tokens` should not be used.
@@ -130,58 +142,74 @@ See the [unist glossary][glossary] but note of the following deviating terms.

###### Child

Node X is **child** of node Y, if X is either referenced directly or referenced
in an array at a field on node Y.
Node X is **child** of node Y,
if X is either referenced directly or referenced in an array at a field on
node Y.

###### Sibling

Node X is a **sibling** of node Y, if X and Y have the same parent (if any) and
X and Y are both referenced in an array at a field on node Y.
Node X is a **sibling** of node Y,
if X and Y have the same parent (if any) and X and Y are both referenced in an
array at a field on node Y.

## List of utilities

See the [unist list of utilities][utilities] for more utilities.

* [`estree-util-build-jsx`](https://github.com/wooorm/estree-util-build-jsx)
— Transform JSX to function calls
* [`estree-util-is-identifier-name`](https://github.com/wooorm/estree-util-is-identifier-name)
— Check if something can be an identifier name

Please use either `estree-util-` (if it works with all ESTrees, preferred)
* [`estree-util-attach-comments`](https://github.com/syntax-tree/estree-util-attach-comments)
— attach comments to estree nodes
* [`estree-util-build-jsx`](https://github.com/syntax-tree/estree-util-build-jsx)
— transform JSX to function calls
* [`estree-util-is-identifier-name`](https://github.com/syntax-tree/estree-util-is-identifier-name)
— check if something can be an identifier name
* [`estree-util-value-to-estree`](https://github.com/remcohaszing/estree-util-value-to-estree)
— convert a JavaScript value to an estree expression
* [`estree-util-to-js`](https://github.com/syntax-tree/estree-util-to-js)
— serialize as JavaScript
* [`estree-util-visit`](https://github.com/syntax-tree/estree-util-visit)
— visit nodes
* [`esast-util-from-estree`](https://github.com/syntax-tree/esast-util-from-estree)
— transform from estree
* [`esast-util-from-js`](https://github.com/syntax-tree/esast-util-from-js)
— parse from JavaScript

Please use either `estree-util-` (if it works with all ESTrees,
preferred)
or `esast-util-` (if it uses on esast specific features) as a prefix.

See also the [`estree`](https://github.com/search?q=topic%3Aestree\&s=stars\&o=desc)
topic on GitHub.

## References

* **unist**:
[Universal Syntax Tree][unist].
T. Wormer; et al.
* **JavaScript**:
[ECMAScript Language Specification][javascript].
Ecma International.
* **JSON**
[The JavaScript Object Notation (JSON) Data Interchange Format][json],
T. Bray.
IETF.
* **Web IDL**:
[Web IDL][webidl],
C. McCormack.
W3C.
* **unist**:
[Universal Syntax Tree][unist].
T. Wormer; et al.
* **JavaScript**:
[ECMAScript Language Specification][javascript].
Ecma International.
* **JSON**
[The JavaScript Object Notation (JSON) Data Interchange Format][json],
T. Bray.
IETF.
* **Web IDL**:
[Web IDL][webidl],
C. McCormack.
W3C.

## Security

As esast represents JS, and JS can open you up to a bunch of problems, esast is
also unsafe.
As esast represents JS,
and JS can open you up to a bunch of problems,
esast is also unsafe.
Always be careful with user input.

## Related

* [hast](https://github.com/syntax-tree/hast) — HTML
* [mdast](https://github.com/syntax-tree/mdast) — Markdown
* [nlcst](https://github.com/syntax-tree/nlcst) — Natural language
* [xast](https://github.com/syntax-tree/xast) — XML
* [hast](https://github.com/syntax-tree/hast) — HTML
* [mdast](https://github.com/syntax-tree/mdast) — Markdown
* [nlcst](https://github.com/syntax-tree/nlcst) — Natural language
* [xast](https://github.com/syntax-tree/xast) — XML

## Contribute

@@ -190,17 +218,22 @@ ways to get started.
See [`support.md`][support] for ways to get help.
Ideas for new utilities and tools can be posted in [`syntax-tree/ideas`][ideas].

A curated list of awesome syntax-tree, unist, mdast, esast, xast, and nlcst
resources can be found in [awesome syntax-tree][awesome].
A curated list of awesome `syntax-tree`,
unist,
mdast,
esast,
xast,
and nlcst resources can be found in [awesome syntax-tree][awesome].

This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
By interacting with this repository,
organization,
or community you agree to abide by its terms.

## Acknowledgments

The initial release of this project was authored by
[**@wooorm**](https://github.com/wooorm).
**[@wooorm](https://github.com/wooorm)**.

## License