feat(linter/plugins): RuleTester parser support options#16641
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. |
There was a problem hiding this comment.
Pull request overview
This PR adds parser options support to RuleTester by introducing a ParserOptions struct that allows configuring the language type (js, jsx, ts, tsx, dts) and source type (script, module, unambiguous) for parsing. The options are threaded through from TypeScript to Rust and used to configure the parser's SourceType.
Key Changes:
- Added
ParserOptionsstruct withlangandsource_typefields on Rust side - Updated
parse_raw_syncandparse_raw_implto accept optional parser options - Added corresponding TypeScript type definitions and updated the
parsefunction signature
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
apps/oxlint/src/js_plugins/parse.rs |
Adds ParserOptions struct, updates parser functions to accept options, and includes get_source_type helper function to process the options |
apps/oxlint/src-js/package/parse.ts |
Updates parse function signature to accept optional ParseOptions parameter and passes it to Rust binding |
apps/oxlint/src-js/bindings.d.ts |
Defines ParserOptions TypeScript interface and updates parseRawSync signature (auto-generated) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fdabc71 to
d5bf26a
Compare
CodSpeed Performance ReportMerging #16641 will not alter performanceComparing Summary
Footnotes
|
d5bf26a to
fbdd54f
Compare
Merge activity
|
Add options to the parser used in `RuleTester`. Currently `RuleTester` doesn't actually use these options, but this prepares the way for other changes to `RuleTester` in future PRs. The extra types for `Comment` etc in `bindings.d.ts` are just the result of using `oxc_napi` crate for its `get_source_type` function. We don't use those types, but they're also not exposed externally, so it doesn't matter.
fbdd54f to
554250e
Compare
Add options to the parser used in `RuleTester`. Currently `RuleTester` doesn't actually use these options, but this prepares the way for other changes to `RuleTester` in future PRs. The extra types for `Comment` etc in `bindings.d.ts` are just the result of using `oxc_napi` crate for its `get_source_type` function. We don't use those types, but they're also not exposed externally, so it doesn't matter.
…t#16641) Add options to the parser used in `RuleTester`. Currently `RuleTester` doesn't actually use these options, but this prepares the way for other changes to `RuleTester` in future PRs. The extra types for `Comment` etc in `bindings.d.ts` are just the result of using `oxc_napi` crate for its `get_source_type` function. We don't use those types, but they're also not exposed externally, so it doesn't matter.
…fig types (oxc-project#16642) Add to types for `Config` and `TestCase` in `RuleTester`. Similar to oxc-project#16641, these options are currently ignored, but it prepares the way for other changes to `RuleTester` in future PRs.

Add options to the parser used in
RuleTester. CurrentlyRuleTesterdoesn't actually use these options, but this prepares the way for other changes toRuleTesterin future PRs.The extra types for
Commentetc inbindings.d.tsare just the result of usingoxc_napicrate for itsget_source_typefunction. We don't use those types, but they're also not exposed externally, so it doesn't matter.