Align JS-side AST with standard for JSX #9703
Labels
A-ast
Area - AST
C-enhancement
Category - New feature or request
E-Help Wanted
Experience level - For the experienced collaborators
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
andrange
properties. But we could:acorn-jsx
plugin.Use same methodology as for the ESTree conformance tests:
ESTree
conformance runner in this repo run Oxc parser on same test cases, and compare output to snapshots inacorn-test262
.The text was updated successfully, but these errors were encountered: