Skip to content

Comments

refactor(linter/plugins): store rule options as Vecs#16336

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-01-refactor_linter_plugins_store_rule_options_as_vec_s
Dec 1, 2025
Merged

refactor(linter/plugins): store rule options as Vecs#16336
graphite-app[bot] merged 1 commit intomainfrom
12-01-refactor_linter_plugins_store_rule_options_as_vec_s

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Dec 1, 2025

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.

@github-actions github-actions bot added A-linter Area - Linter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Dec 1, 2025
Copy link
Member Author

overlookmotel commented Dec 1, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@overlookmotel overlookmotel marked this pull request as ready for review December 1, 2025 12:56
Copilot AI review requested due to automatic review settings December 1, 2025 12:56
@overlookmotel overlookmotel self-assigned this Dec 1, 2025
@overlookmotel overlookmotel added the A-linter-plugins Area - Linter JS plugins label Dec 1, 2025
Copy link
Contributor

Copilot AI left a 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 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 options field type from IndexVec<ExternalOptionsId, serde_json::Value> to IndexVec<ExternalOptionsId, Vec<serde_json::Value>>
  • Updated add_options to destructure the array at runtime and panic if it's not an array
  • Simplified initialization to use vec![] instead of serde_json::json!([])

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 1, 2025

CodSpeed Performance Report

Merging #16336 will not alter performance

Comparing 12-01-refactor_linter_plugins_store_rule_options_as_vec_s (d7a4296) with main (5ad5435)1

Summary

✅ 4 untouched
⏩ 41 skipped2

Footnotes

  1. No successful run was found on main (55cf157) during the generation of this report, so 5ad5435 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 41 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Member Author

overlookmotel commented Dec 1, 2025

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.
@graphite-app graphite-app bot force-pushed the 12-01-refactor_linter_plugins_store_rule_options_as_vec_s branch from d7a4296 to 82f8b9f Compare December 1, 2025 13:45
@graphite-app graphite-app bot merged commit 82f8b9f into main Dec 1, 2025
20 checks passed
@graphite-app graphite-app bot deleted the 12-01-refactor_linter_plugins_store_rule_options_as_vec_s branch December 1, 2025 13:50
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 1, 2025
Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@overlookmotel
Copy link
Member Author

overlookmotel commented Dec 1, 2025

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.

taearls pushed a commit to taearls/oxc that referenced this pull request Dec 11, 2025
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter A-linter-plugins Area - Linter JS plugins C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants