-
-
Notifications
You must be signed in to change notification settings - Fork 723
Description
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-jsxplugin. - Record that output as JSON files.
Use same methodology as for the ESTree conformance tests:
- Commit the test case snapshots to https://github.com/oxc-project/acorn-test262.
ESTreeconformance runner in this repo run Oxc parser on same test cases, and compare output to snapshots inacorn-test262.