Skip to content

feat(linter/no-regex-spaces): implement fixer#16837

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/12-14-feat_linter_no-regex-spaces_implement_fixer
Dec 14, 2025
Merged

feat(linter/no-regex-spaces): implement fixer#16837
graphite-app[bot] merged 1 commit intomainfrom
c/12-14-feat_linter_no-regex-spaces_implement_fixer

Conversation

@camc314
Copy link
Copy Markdown
Contributor

@camc314 camc314 commented Dec 14, 2025

No description provided.

@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Dec 14, 2025
Copy link
Copy Markdown
Contributor Author

camc314 commented Dec 14, 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.

@camc314 camc314 marked this pull request as ready for review December 14, 2025 15:46
Copilot AI review requested due to automatic review settings December 14, 2025 15:46
@camc314 camc314 self-assigned this Dec 14, 2025
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 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 pending to fix to indicate fixer support
  • Added fix_spaces helper method that generates the replacement string {n} where n is the number of consecutive spaces
  • Updated all diagnostic calls to use diagnostic_with_fix instead of diagnostic

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

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Dec 14, 2025

CodSpeed Performance Report

Merging #16837 will not alter performance

Comparing c/12-14-feat_linter_no-regex-spaces_implement_fixer (7f0def3) with main (652a2bf)

Summary

✅ 4 untouched
⏩ 41 skipped1

Footnotes

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

@camc314 camc314 force-pushed the c/12-14-feat_linter_no-regex-spaces_implement_fixer branch from efc0643 to 7f0def3 Compare December 14, 2025 15:52
Copy link
Copy Markdown

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

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

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-spaces by switching the rule metadata from pending to fix.
  • Added fixer wiring for all report sites:
    • Replaced ctx.diagnostic(...) with ctx.diagnostic_with_fix(..., |fixer| ...) for RegExpLiteral, RegExp(...), and new RegExp(...) cases.
  • Introduced a helper fix_spaces(fixer, span) that replaces the reported span with a quantifier string like " {N}" based on span.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

@charliecreates charliecreates bot removed the request for review from CharlieHelps December 14, 2025 15:52
@camc314 camc314 force-pushed the c/12-14-feat_linter_no-regex-spaces_implement_fixer branch from 7f0def3 to b3bd81f Compare December 14, 2025 16:06
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Dec 14, 2025
Copy link
Copy Markdown
Contributor Author

camc314 commented Dec 14, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the c/12-14-feat_linter_no-regex-spaces_implement_fixer branch from b3bd81f to 08bf389 Compare December 14, 2025 16:12
@graphite-app graphite-app bot merged commit 08bf389 into main Dec 14, 2025
20 checks passed
@graphite-app graphite-app bot deleted the c/12-14-feat_linter_no-regex-spaces_implement_fixer branch December 14, 2025 16:17
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 14, 2025
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.

2 participants