refactor(linter/plugins): store rule options as Vecs#16336
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 ExternalPluginStore to enforce that rule options are always arrays at the type system level. Instead of storing options as serde_json::Value (which would always be a Value::Array), they are now stored as Vec<serde_json::Value>, making the invariant explicit in the type system.
Key changes:
- Changed the
optionsfield type fromIndexVec<ExternalOptionsId, serde_json::Value>toIndexVec<ExternalOptionsId, Vec<serde_json::Value>> - Updated
add_optionsto destructure the array at runtime and panic if it's not an array - Simplified initialization to use
vec![]instead ofserde_json::json!([])
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #16336 will not alter performanceComparing Summary
Footnotes
|
0d6fad4 to
d7a4296
Compare
Merge activity
|
Follow-on after #16215. Options for each rule is always an array. Enforce this in type system by storing options as `Vec<serde_json::Value>` instead of a single `serde_json::Value` which is always a `Value::Array`. I'll try to alter `ESLintRule`'s `config` field to be a `Vec<serde_json::Value>` too in another PR to follow.
d7a4296 to
82f8b9f
Compare
camc314
left a comment
There was a problem hiding this comment.
can this ever be more than a single element? maybe it should be a custom type with a custom serialize implementation, this means we could reduce memory usage as we wouldn't have to keep the vec wrapper
|
Certainly for JS plugins it can be more then 1 element long. This is legit: {
"rules": {
"my-rule": ["error", "something", 123, false, { "oh yeah": true } ]
}
}...and I believe many real rules do take multiple options like this. |
…6336) Follow-on after oxc-project#16215. Options for each rule is always an array. Enforce this in type system by storing options as `Vec<serde_json::Value>` instead of a single `serde_json::Value` which is always a `Value::Array`. I'll try to alter `ESLintRule`'s `config` field to be a `Vec<serde_json::Value>` too in another PR to follow.

Follow-on after #16215.
Options for each rule is always an array. Enforce this in type system by storing options as
Vec<serde_json::Value>instead of a singleserde_json::Valuewhich is always aValue::Array.I'll try to alter
ESLintRule'sconfigfield to be aVec<serde_json::Value>too in another PR to follow.