Skip to content

feat(linter): backfill rule version metadata#21391

Merged
camc314 merged 7 commits intooxc-project:mainfrom
penkzhou:feat/backfill-rule-version-metadata
Apr 14, 2026
Merged

feat(linter): backfill rule version metadata#21391
camc314 merged 7 commits intooxc-project:mainfrom
penkzhou:feat/backfill-rule-version-metadata

Conversation

@penkzhou
Copy link
Copy Markdown
Contributor

Summary

This PR covers the first two follow-up tasks from #19890:

  • backfill missing version metadata for the remaining rules
  • add a test to prevent future regressions
  • expose rule version metadata through RuleEnum so the new test can validate it programmatically

The following rules now declare version = "1.60.0":

  • jest/valid-expect-in-promise
  • jest/prefer-importing-jest-globals
  • unicorn/consistent-template-literal-escape

Why

Part of #19890 tracks adding per-rule introduction versions for oxlint rules. This PR focuses on finishing the metadata backfill and adding a guardrail so future rules cannot regress by omitting version = ....

Testing

cargo test -p oxc_linter --test rule_version_metadata_test --features ruledocs
cargo test -p oxc_linter --test rule_configuration_documentation_test --features ruledocs
cargo test -p oxc_linter --features ruledocs
cargo fmt

Notes

This PR intentionally does not include:

  • release automation for rewriting version = "next"
  • website/docs rendering changes

Those are better handled in follow-up PRs.

AI Usage Disclosure

I used AI assistance to help analyze the issue, inspect the relevant code paths, and draft the implementation plan and PR text. I manually reviewed the proposed changes and remain responsible for the final code and submission.

@github-actions github-actions Bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Apr 13, 2026
@penkzhou penkzhou marked this pull request as ready for review April 13, 2026 17:18
@penkzhou penkzhou requested a review from camc314 as a code owner April 13, 2026 17:18
Copilot AI review requested due to automatic review settings April 13, 2026 17:18
Copy link
Copy Markdown
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 completes the backfill of missing per-rule introduction version metadata for remaining linter rules and adds a regression test to ensure all rules always declare version metadata (under the ruledocs feature).

Changes:

  • Add RuleEnum::version() (feature-gated on ruledocs) so rule version metadata can be queried programmatically.
  • Add an integration test ensuring every rule exposes non-None version metadata.
  • Backfill version = "1.60.0" on the remaining rules missing it.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tasks/linter_codegen/src/rules_enum.rs Extends codegen to emit a RuleEnum::version() accessor (ruledocs-only).
crates/oxc_linter/tests/rule_version_metadata_test.rs New ruledocs-only test asserting every rule has version metadata.
crates/oxc_linter/src/rules/unicorn/consistent_template_literal_escape.rs Adds missing version = "1.60.0" metadata.
crates/oxc_linter/src/rules/jest/valid_expect_in_promise.rs Adds missing version = "1.60.0" metadata.
crates/oxc_linter/src/rules/jest/prefer_importing_jest_globals.rs Adds missing version = "1.60.0" metadata.
crates/oxc_linter/src/generated/rules_enum.rs Regenerated output including the new RuleEnum::version() method.

@penkzhou
Copy link
Copy Markdown
Contributor Author

Addressed a follow-up on the metadata guard test:

  • validate version values as either x.y.z or next
  • verify that exception entries still point to real rules
  • make RuleEnum::version() available without the ruledocs cfg so the guard can run in the default test build too

I also added direct regression tests for the version-format and exception-validation helpers.

Copy link
Copy Markdown
Member

@camchenry camchenry left a comment

Choose a reason for hiding this comment

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

I think there is a slightly simpler way to do this. I don't think we should need to update rules_enum with the version information at the moment.

Instead, we can mark VERSION as non-optional in RuleMeta and non-optional in LintRuleMeta. Then, we throw an error if we didn't parse out a version. If there is no version defined, then it will simply fail to compile the macro, so we don't even need a test for it.

@penkzhou
Copy link
Copy Markdown
Contributor Author

@camchenry Thanks for the suggestion. I applied this approach in the latest update.

I changed RuleMeta::VERSION and the macro metadata to make version required at compile time, so missing version = ... now fails the macro expansion directly. With that in place, I removed the extra RuleEnum::version() plumbing and the linter-wide metadata test, since they are no longer needed for enforcement.

I also updated the existing macro integration test cases to include version = "next" so they still compile under the new contract.

When you have a moment, could you please take another look?

Copy link
Copy Markdown
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.

nice!

Thank yoU!

@camc314 camc314 requested a review from camchenry April 14, 2026 15:24
@camc314 camc314 merged commit cffdc2e into oxc-project:main Apr 14, 2026
25 checks passed
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 14, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing penkzhou:feat/backfill-rule-version-metadata (e19dbb3) with main (24b03de)2

Open in CodSpeed

Footnotes

  1. 47 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.

  2. No successful run was found on main (59aef8b) during the generation of this report, so 24b03de was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

camc314 added a commit that referenced this pull request Apr 20, 2026
# Oxlint
### 💥 BREAKING CHANGES

- 24fb7eb allocator: [**BREAKING**] Rename `Box` and `Vec` methods
(#21395) (overlookmotel)

### 🚀 Features

- 38d8090 linter/jest: Implemented jest `version` settings in config
file. (#21522) (Said Atrahouch)
- 7dbbb99 linter/eslint: Implement suggestion for `no-case-declarations`
rule (#21508) (Mikhail Baev)
- 9b4d9f6 linter/prefer-template: Implement autofix (#21502) (François)
- daa64ed linter/no-empty-pattern: Add `allowObjectPatternsAsParameters`
option (#21474) (camc314)
- cf2d281 linter/typescript: Implement explicit-member-accessibility
(#21447) (Hunter Tunnicliff)
- d48de6f linter/unicorn: Add help messages to 3 rule diagnostics
(#21459) (Mukunda Rao Katta)
- cffdc2e linter: Backfill rule version metadata (#21391) (Old Autumn)

### 🐛 Bug Fixes

- 1e69b91 linter/no-useless-assignment: Improve diagnostic spans
(#21581) (camc314)
- f272594 linter/plugins: Align `RuleMeta.replacedBy` type with ESLint
(#21544) (bab)
- 4d57851 linter/eslint: Enhance `no-empty-function` rule to support
async and generator functions in VariableDeclarator (#21542) (Mikhail
Baev)
- 00fc136 codegen: Preserve coverage comments before object properties
(#21312) (bab)
- a56b7b9 oxlint: Dont enable gitlab formatter by default (#21501)
(camc314)
- 9c9b6a2 linter/array-callback-return: Ignore non-exit CFG dead ends
(#21497) (camc314)
- 61088e0 linter/unicorn: Handle computed property access in
`prefer-dom-node-remove` rule (#21470) (Mikhail Baev)
- eab5934 linter: Report an error on unsupported `extends` values
(#21406) (John Costa)
- 3289ba0 linter/valid-expect-in-promise: Check a jest fn to be `test`
instead of `describe` (#21422) (Said Atrahouch)
- 4417fe3 linter/prefer-ending-with-an-expect: Ignore vi.mock factory
callbacks (#21414) (Cédric Exbrayat)
- a904883 linter/consistent-type-imports: Ignore vue/svelte/astro files
(#21415) (bab)
- 2498fe6 linter/no-unused-vars: Allow segments of dotted namespace
declarations (#21416) (bab)
- 44b5b35 linter: Preserve vitest-compatible jest rules when applying
overrides (#21389) (Cameron)
- 7bd8331 linter/prefer-ending-with-an-expect: Add missing `version`
docs (#21390) (Said Atrahouch)
- 43d8f0d linter/no-useless-assignment: Ignore writes read by closures
(#21380) (camc314)

### 📚 Documentation

- c1eeae3 linter: Add version to `rule.json` (#21547) (camchenry)
- 0ec6ab2 linter: Improve the `vitest/no-importing-vitest-globals` rule
documentation. (#21557) (connorshea)
# Oxfmt
### 💥 BREAKING CHANGES

- 24fb7eb allocator: [**BREAKING**] Rename `Box` and `Vec` methods
(#21395) (overlookmotel)

### 🚀 Features

- 5aa7fe1 oxfmt: Add `--disable-nested-config` CLI flag (#21514)
(leaysgur)
- b5cb8d1 oxfmt: Update prettier to 3.8.3 (#21451) (leaysgur)
- 16713d5 oxfmt/cli: Support per-directory config (#21103) (leaysgur)
- 952de06 oxfmt/lsp: Support per-directory config (#21081) (leaysgur)

### 🐛 Bug Fixes

- a501a53 formatter: Handle comments after pipe in single-member union
types (#21487) (John Costa)
- 6f49fad oxfmt: Respect nested config.`ignorePatterns` (#21489)
(leaysgur)
- 7c98d52 oxfmt: Do not panic on finding invalid nested config (#21461)
(leaysgur)
- 41bb2d5 formatter: Preserve more `intrinsic` parens (#21449)
(leaysgur)
- f894750 formatter: Preserve parens around `intrinsic` in type alias
annotation (#21410) (Dunqing)

### ⚡ Performance

- df27b48 oxfmt: Skip ancestors check when no nested config found
(#21517) (leaysgur)
- 5e1522a oxfmt: Do not occupy the rayon thread solely for handover
(#21408) (leaysgur)

Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
camchenry pushed a commit that referenced this pull request Apr 21, 2026
## Summary

This PR covers the Oxc-side export path for rule `version` metadata from
#19890.

It makes `version` available to non-`ruledocs` consumers, then threads
that metadata through the existing export surfaces used by docs/tooling:

- add `version` to `RuleTableRow`
- include `version` in `oxlint` rules JSON output
- include `version` in generated rule doc frontmatter for
`website_linter`
- add regression coverage for the JSON and doc-page export paths

This replaces the earlier stacked fork PR now that its two prerequisites
have already landed:

- #21391: metadata backfill + guardrails
- #21392: release automation

## Notes

- This PR is intentionally scoped to the `oxc` repository only.
- The website rendering change should remain a follow-up in
`oxc-project/website`.
- Compared with the earlier stacked branch, this version is rebased onto
current `main` and aligns with the now-merged compile-time `version`
invariant.

## Testing

```bash
cargo fmt --all
cargo lintgen
cargo test -p oxlint output_formatter::json::test::all_rules_json_includes_version_metadata -- --nocapture
cargo test -p oxlint lint::test::test_rules_json_output -- --nocapture
cargo test -p website_linter
cargo test -p oxc_linter --test rule_configuration_documentation_test --features ruledocs
cargo test -p oxc_linter --features ruledocs
```

## AI Usage Disclosure

I used AI assistance to help inspect the prior stacked PR state, rebase
the export slice onto the current `main`, and prepare the replacement PR
text. I manually reviewed the resulting changes, ran the checks listed
above, and remain responsible for the final code and submission.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants