feat(linter/no-regex-spaces): implement fixer#16837
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 implements an autofixer for the no-regex-spaces ESLint rule, which flags and fixes multiple consecutive spaces in regular expressions by replacing them with explicit quantifiers (e.g., → {2}).
Key Changes
- Updated rule category from
pendingtofixto indicate fixer support - Added
fix_spaceshelper method that generates the replacement string{n}where n is the number of consecutive spaces - Updated all diagnostic calls to use
diagnostic_with_fixinstead ofdiagnostic
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #16837 will not alter performanceComparing Summary
Footnotes
|
efc0643 to
7f0def3
Compare
There was a problem hiding this comment.
The new fixer depends heavily on the meaning of Span across literal vs constructor forms; if any path returns pattern-relative spans rather than source spans, fixer.replace(span, ...) can produce incorrect edits. The replacement logic (" {N}") is correct but non-obvious; documenting the invariant would reduce future maintenance risk. One fix expectation suggests the rule may be fixing an unexpected occurrence when multiple consecutive-space runs exist, which should be confirmed against intended/ESLint behavior.
Summary of changes
What changed
- Enabled autofix support for
eslint/no-regex-spacesby switching the rule metadata frompendingtofix. - Added fixer wiring for all report sites:
- Replaced
ctx.diagnostic(...)withctx.diagnostic_with_fix(..., |fixer| ...)forRegExpLiteral,RegExp(...), andnew RegExp(...)cases.
- Replaced
- Introduced a helper
fix_spaces(fixer, span)that replaces the reported span with a quantifier string like" {N}"based onspan.size(). - Expanded tests to include an
.expect_fix(...)table with many input→output cases validating the new autofixer behavior.
Files touched: crates/oxc_linter/src/rules/eslint/no_regex_spaces.rs
7f0def3 to
b3bd81f
Compare
Merge activity
|
b3bd81f to
08bf389
Compare

No description provided.