Skip to content

Align JS-side AST with standard for JSX #9703

@overlookmotel

Description

@overlookmotel

Our AST on JS side (via oxc-parser NPM package) is now aligned with ESTree standard.

We have conformance tests which ensure our AST is exactly the same as Acorn's AST for all Test262 test cases which Acorn can parse.

Aim

We should ensure our JS-side AST is aligned to a common standard for JSX too.

The JSX spec only specifies JSX grammar, but not field names etc for an AST that includes JSX nodes. acorn-jsx appears to be popular (40m weekly NPM downloads), so I suggest it's a good target to align with.

The extensions to AST for JSX are quite minimal (only a handful of types), so it's possible that our AST is already perfectly aligned. But we should adopt a conformance test suite which is run in CI so we can (a) ensure that's correct and (b) make sure we don't break it accidentally in future.

Suggested plan

I suggest that we:

Use the test cases from acorn-jsx as our target for conformance. The JSON snapshots in that file are not great, because they include loc and range properties. But we could:

  • Use the inputs from those tests.
  • Parse them all with Acorn using acorn-jsx plugin.
  • Record that output as JSON files.

Use same methodology as for the ESTree conformance tests:

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-astArea - ASTC-enhancementCategory - New feature or requestE-Help WantedExperience level - For the experienced collaborators

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions