fix(linter/forward-ref-uses-ref): dont suggest removing wrapper in invalid positions#15388
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. |
810777f to
9745e86
Compare
880ee63 to
8641b47
Compare
CodSpeed Performance ReportMerging #15388 will not alter performanceComparing Summary
Footnotes
|
8641b47 to
2db4f2c
Compare
9745e86 to
dac2a9c
Compare
2db4f2c to
816a762
Compare
816a762 to
6cf27f1
Compare
There was a problem hiding this comment.
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
forwardRefwould 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
refparameter, or removeforwardRef'), 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.
6cf27f1 to
e7ebbd3
Compare
Merge activity
|
e7ebbd3 to
ddd9f9f
Compare

fixes #15384