Skip to content

fix(linter/forward-ref-uses-ref): dont suggest removing wrapper in invalid positions#15388

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/11-06-fix_linter_forward-ref-uses-ref_dont_suggest_removing_wrapper_in_invalid_positions
Nov 6, 2025
Merged

fix(linter/forward-ref-uses-ref): dont suggest removing wrapper in invalid positions#15388
graphite-app[bot] merged 1 commit intomainfrom
c/11-06-fix_linter_forward-ref-uses-ref_dont_suggest_removing_wrapper_in_invalid_positions

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Nov 6, 2025

fixes #15384

Copy link
Contributor Author

camc314 commented Nov 6, 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 force-pushed the c/11-06-fix_linter_no-template-curly-in-string_remove_fixer branch from 810777f to 9745e86 Compare November 6, 2025 15:48
@camc314 camc314 force-pushed the c/11-06-fix_linter_forward-ref-uses-ref_dont_suggest_removing_wrapper_in_invalid_positions branch from 880ee63 to 8641b47 Compare November 6, 2025 15:48
@graphite-app graphite-app bot changed the base branch from c/11-06-fix_linter_no-template-curly-in-string_remove_fixer to graphite-base/15388 November 6, 2025 15:53
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 6, 2025

CodSpeed Performance Report

Merging #15388 will not alter performance

Comparing c/11-06-fix_linter_forward-ref-uses-ref_dont_suggest_removing_wrapper_in_invalid_positions (ddd9f9f) with main (dac2a9c)1

Summary

✅ 4 untouched
⏩ 33 skipped2

Footnotes

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

  2. 33 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.

@graphite-app graphite-app bot force-pushed the c/11-06-fix_linter_forward-ref-uses-ref_dont_suggest_removing_wrapper_in_invalid_positions branch from 8641b47 to 2db4f2c Compare November 6, 2025 15:59
@graphite-app graphite-app bot force-pushed the graphite-base/15388 branch from 9745e86 to dac2a9c Compare November 6, 2025 15:59
@graphite-app graphite-app bot changed the base branch from graphite-base/15388 to main November 6, 2025 15:59
@graphite-app graphite-app bot force-pushed the c/11-06-fix_linter_forward-ref-uses-ref_dont_suggest_removing_wrapper_in_invalid_positions branch from 2db4f2c to 816a762 Compare November 6, 2025 15:59
Copilot AI review requested due to automatic review settings November 6, 2025 16:07
@camc314 camc314 force-pushed the c/11-06-fix_linter_forward-ref-uses-ref_dont_suggest_removing_wrapper_in_invalid_positions branch from 816a762 to 6cf27f1 Compare November 6, 2025 16:07
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 improves the forward_ref_uses_ref rule by conditionally offering fix suggestions based on the context of anonymous function expressions. When an anonymous function expression is used in a statement context (e.g., forwardRef(function(a) {})), removing the forwardRef wrapper would result in invalid syntax, so only the "add ref parameter" fix is offered. For other cases (arrow functions, named function expressions, or anonymous functions in expression contexts), both fixes are provided.

  • Added logic to detect when removing forwardRef would be unsafe
  • Extracted the "add ref parameter" fix into a reusable closure
  • Updated test cases to reflect the new conditional fix behavior
Comments suppressed due to low confidence (1)

crates/oxc_linter/src/rules/react/forward_ref_uses_ref.rs:15

  • The help message suggests both fixes are always available ('Add a ref parameter, or remove forwardRef'), but the code now conditionally provides only the add-ref fix in some cases. Consider making the help message dynamic or more general to avoid misleading users when only one fix is available.
        .with_help("Add a `ref` parameter, or remove `forwardRef`")

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

@camc314 camc314 force-pushed the c/11-06-fix_linter_forward-ref-uses-ref_dont_suggest_removing_wrapper_in_invalid_positions branch from 6cf27f1 to e7ebbd3 Compare November 6, 2025 17:04
@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 6, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the c/11-06-fix_linter_forward-ref-uses-ref_dont_suggest_removing_wrapper_in_invalid_positions branch from e7ebbd3 to ddd9f9f Compare November 6, 2025 17:10
@graphite-app graphite-app bot merged commit ddd9f9f into main Nov 6, 2025
20 checks passed
@graphite-app graphite-app bot deleted the c/11-06-fix_linter_forward-ref-uses-ref_dont_suggest_removing_wrapper_in_invalid_positions branch November 6, 2025 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linter fixer bug: forward_ref_uses_ref produces invalid function declaration

2 participants