-
-
Notifications
You must be signed in to change notification settings - Fork 715
feat(napi/parser): export visitor keys #13927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Instrumentation Performance ReportMerging #13927 will not alter performanceComparing Summary
Footnotes |
af8fbe1 to
60ae4c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds visitor keys export to the oxc-parser NPM package by generating them from TypeScript ESLint's visitor keys with modifications for Oxc-specific AST nodes. This functionality will enable ESTree walker support for Oxc's AST.
Key changes:
- Creates a new generator that extracts visitor keys from
@typescript-eslint/visitor-keys - Adds Oxc-specific AST nodes like
ParenthesizedExpressionandV8IntrinsicExpression - Exports visitor keys through the parser package's main index
Reviewed Changes
Copilot reviewed 11 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tasks/ast_tools/src/generators/estree_visit.rs | New generator that creates visitor keys by running a Node.js script and processing the output |
| tasks/ast_tools/src/utils.rs | Adds string! macro for creating String instances |
| napi/parser/scripts/visitor-keys.mjs | Node.js script that extracts visitor keys from TypeScript ESLint |
| napi/parser/src-js/index.mjs | Exports the generated visitor keys |
| napi/parser/test/parse.test.ts | Adds tests for the visitor keys functionality |
| .github/workflows/ci.yml | Adds Node.js setup for CI workflow |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
60ae4c7 to
f694cda
Compare
f68cffb to
f7f9e3a
Compare
f7f9e3a to
b0abdfd
Compare
b0abdfd to
7091e82
Compare
5b2c840 to
0185984
Compare
7091e82 to
fe80787
Compare
|
Needs to be changed after #13978. |
fe80787 to
2395e3a
Compare
Done. |
2395e3a to
2bd7aa7
Compare
Merge activity
|
Add visitor keys export to `oxc-parser` NPM package. This is useful in itself, but also the first step towards an ESTree walker. Visitor keys are based on `@typescript-eslint/visitor-keys`. It'd be ideal to generate visitor keys direct from Oxc's own types, but that's proving difficult due to all the custom serializers we use to translate to ESTree. So using the shortcut of borrowing from TS-ESLint for now. Oxc's AST is slightly different from TS-ESTree (notably Oxc's AST adds `ParenthesizedExpression`). But apart from those few differences, TS-ESLint's AST and Oxc's are identical, and I made a PR to TS-ESLint earlier this year (typescript-eslint/typescript-eslint#11279) to ensure visitor key order is correct, and matches Oxc. To avoid adding a runtime dependency on `@typescript-eslint/visitor-keys`, extract the data from TS-ESLint in `oxc_ast_tools`, amend for Oxc/TS-ESTree differences, and re-output it as a simple object literal. This approach will be faster at runtime, as the object's shape is consistent, and also avoids a dependency.
2bd7aa7 to
4ee94a3
Compare

Add visitor keys export to
oxc-parserNPM package. This is useful in itself, but also the first step towards an ESTree walker.Visitor keys are based on
@typescript-eslint/visitor-keys.It'd be ideal to generate visitor keys direct from Oxc's own types, but that's proving difficult due to all the custom serializers we use to translate to ESTree. So using the shortcut of borrowing from TS-ESLint for now.
Oxc's AST is slightly different from TS-ESTree (notably Oxc's AST adds
ParenthesizedExpression). But apart from those few differences, TS-ESLint's AST and Oxc's are identical, and I made a PR to TS-ESLint earlier this year (typescript-eslint/typescript-eslint#11279) to ensure visitor key order is correct, and matches Oxc.To avoid adding a runtime dependency on
@typescript-eslint/visitor-keys, extract the data from TS-ESLint inoxc_ast_tools, amend for Oxc/TS-ESTree differences, and re-output it as a simple object literal.This approach will be faster at runtime, as the object's shape is consistent, and also avoids a dependency.