refactor(linter/plugins): RuleTester use setOptions to set up options#16929
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 refactors the RuleTester implementation to use setOptions() for setting up rule options, making it follow the same code path as the actual linter. Previously, the RuleTester directly called mergeOptions() and manipulated the allOptions array, which diverged from how the Rust linter processes options. This refactor improves consistency and fixes a bug where a test case with empty options object [{}] wasn't being handled correctly.
Key changes:
- RuleTester now builds a JSON string in the same format as Rust does and calls
setOptions()instead of directly manipulating options - Removed
initAllOptions()function that was only used by RuleTester - Made
mergeOptions()a private function since it's now only called internally bysetOptions()
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
apps/oxlint/src-js/plugins/options.ts |
Removed initAllOptions() function and made mergeOptions() private since it's now only used internally by setOptions() |
apps/oxlint/src-js/package/rule_tester.ts |
Added setupOptions() function that mimics Rust behavior by building JSON string and calling setOptions(), updated imports, and improved cleanup logic to handle null allOptions |
apps/oxlint/conformance/snapshot.md |
Test results updated showing no-useless-computed-key rule now fully passing (217 vs 216 fully passing rules, 28671 vs 28670 passing tests) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
69d41c5 to
b845871
Compare
0772a71 to
0c799e2
Compare

RuleTestercallsetOptionsto set up rule options, same as linter does. This makes sure the rule tester's behavior matches actual linter exactly.It also prepares the way for applying defaults from
rule.meta.schema(#16930).