@@ -6,11 +6,17 @@ ruleTester.run(RULE_NAME, rule, {
66 {
77 code : /* tsx */ `
88 import { forwardRef } from 'react'
9- forwardRef((props) => {
9+ const Component = forwardRef((props) => {
1010 return null;
1111 });
1212 ` ,
1313 errors : [ { messageId : "noForwardRef" } ] ,
14+ output : /* tsx */ `
15+ import { forwardRef } from 'react'
16+ const Component = ({ ref, ...props }) => {
17+ return null;
18+ };
19+ ` ,
1420 settings : {
1521 "react-x" : {
1622 version : "19.0.0" ,
@@ -20,9 +26,13 @@ ruleTester.run(RULE_NAME, rule, {
2026 {
2127 code : /* tsx */ `
2228 import { forwardRef } from 'react'
23- forwardRef((props) => null);
29+ const Component = forwardRef((props) => null);
2430 ` ,
2531 errors : [ { messageId : "noForwardRef" } ] ,
32+ output : /* tsx */ `
33+ import { forwardRef } from 'react'
34+ const Component = ({ ref, ...props }) => null;
35+ ` ,
2636 settings : {
2737 "react-x" : {
2838 version : "19.0.0" ,
@@ -32,11 +42,17 @@ ruleTester.run(RULE_NAME, rule, {
3242 {
3343 code : /* tsx */ `
3444 import { forwardRef } from 'react'
35- forwardRef(function (props) {
45+ const Component = forwardRef(function (props) {
3646 return null;
3747 });
3848 ` ,
3949 errors : [ { messageId : "noForwardRef" } ] ,
50+ output : /* tsx */ `
51+ import { forwardRef } from 'react'
52+ const Component = function ({ ref, ...props }) {
53+ return null;
54+ };
55+ ` ,
4056 settings : {
4157 "react-x" : {
4258 version : "19.0.0" ,
@@ -46,11 +62,17 @@ ruleTester.run(RULE_NAME, rule, {
4662 {
4763 code : /* tsx */ `
4864 import { forwardRef } from 'react'
49- forwardRef(function Component(props) {
65+ const Component = forwardRef(function Component(props) {
5066 return null;
5167 });
5268 ` ,
5369 errors : [ { messageId : "noForwardRef" } ] ,
70+ output : /* tsx */ `
71+ import { forwardRef } from 'react'
72+ const Component = function Component({ ref, ...props }) {
73+ return null;
74+ };
75+ ` ,
5476 settings : {
5577 "react-x" : {
5678 version : "19.0.0" ,
@@ -60,11 +82,17 @@ ruleTester.run(RULE_NAME, rule, {
6082 {
6183 code : /* tsx */ `
6284 import * as React from 'react'
63- React.forwardRef((props) => {
85+ const Component = React.forwardRef((props) => {
6486 return null;
6587 });
6688 ` ,
6789 errors : [ { messageId : "noForwardRef" } ] ,
90+ output : /* tsx */ `
91+ import * as React from 'react'
92+ const Component = ({ ref, ...props }) => {
93+ return null;
94+ };
95+ ` ,
6896 settings : {
6997 "react-x" : {
7098 version : "19.0.0" ,
@@ -74,9 +102,13 @@ ruleTester.run(RULE_NAME, rule, {
74102 {
75103 code : /* tsx */ `
76104 import * as React from 'react'
77- React.forwardRef((props) => null);
105+ const Component = React.forwardRef((props) => null);
78106 ` ,
79107 errors : [ { messageId : "noForwardRef" } ] ,
108+ output : /* tsx */ `
109+ import * as React from 'react'
110+ const Component = ({ ref, ...props }) => null;
111+ ` ,
80112 settings : {
81113 "react-x" : {
82114 version : "19.0.0" ,
@@ -86,11 +118,17 @@ ruleTester.run(RULE_NAME, rule, {
86118 {
87119 code : /* tsx */ `
88120 import * as React from 'react'
89- React.forwardRef(function (props) {
121+ const Component = React.forwardRef(function (props) {
90122 return null;
91123 });
92124 ` ,
93125 errors : [ { messageId : "noForwardRef" } ] ,
126+ output : /* tsx */ `
127+ import * as React from 'react'
128+ const Component = function ({ ref, ...props }) {
129+ return null;
130+ };
131+ ` ,
94132 settings : {
95133 "react-x" : {
96134 version : "19.0.0" ,
@@ -100,11 +138,83 @@ ruleTester.run(RULE_NAME, rule, {
100138 {
101139 code : /* tsx */ `
102140 import * as React from 'react'
103- React.forwardRef(function Component(props) {
141+ const Component = React.forwardRef(function Component(props) {
104142 return null;
105143 });
106144 ` ,
107145 errors : [ { messageId : "noForwardRef" } ] ,
146+ output : /* tsx */ `
147+ import * as React from 'react'
148+ const Component = function Component({ ref, ...props }) {
149+ return null;
150+ };
151+ ` ,
152+ settings : {
153+ "react-x" : {
154+ version : "19.0.0" ,
155+ } ,
156+ } ,
157+ } ,
158+ {
159+ code : /* tsx */ `
160+ import * as React from 'react'
161+ const Component = React.forwardRef(function Component(props, ref) {
162+ return <div ref={ref} />;
163+ });
164+ ` ,
165+ errors : [ { messageId : "noForwardRef" } ] ,
166+ output : /* tsx */ `
167+ import * as React from 'react'
168+ const Component = function Component({ ref, ...props }) {
169+ return <div ref={ref} />;
170+ };
171+ ` ,
172+ settings : {
173+ "react-x" : {
174+ version : "19.0.0" ,
175+ } ,
176+ } ,
177+ } ,
178+ {
179+ code : /* tsx */ `
180+ import * as React from 'react'
181+ interface ComponentProps {
182+ foo: string;
183+ }
184+ const Component = React.forwardRef<HTMLElement, ComponentProps>(function Component(props, ref) {
185+ return <div ref={ref} />;
186+ });
187+ ` ,
188+ errors : [ { messageId : "noForwardRef" } ] ,
189+ output : /* tsx */ `
190+ import * as React from 'react'
191+ interface ComponentProps {
192+ foo: string;
193+ }
194+ const Component = function Component({ ref, ...props }: ComponentProps & { ref: React.RefObject<HTMLElement> }) {
195+ return <div ref={ref} />;
196+ };
197+ ` ,
198+ settings : {
199+ "react-x" : {
200+ version : "19.0.0" ,
201+ } ,
202+ } ,
203+ } ,
204+ {
205+ code : /* tsx */ `
206+ import * as React from 'react'
207+ const Component = React.forwardRef<HTMLElement, { foo: string }>(function Component(props, ref) {
208+ return <div ref={ref} />;
209+ });
210+ ` ,
211+ errors : [ { messageId : "noForwardRef" } ] ,
212+ output : /* tsx */ `
213+ import * as React from 'react'
214+ const Component = function Component({ ref, ...props }: { foo: string } & { ref: React.RefObject<HTMLElement> }) {
215+ return <div ref={ref} />;
216+ };
217+ ` ,
108218 settings : {
109219 "react-x" : {
110220 version : "19.0.0" ,
0 commit comments