Skip to content

Commit 8e2db56

Browse files
committed
test(plugins/x): add ref alias test cases to 'no-forward-ref'
1 parent 22d1110 commit 8e2db56

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/plugins/eslint-plugin-react-x/src/rules/no-forward-ref.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,26 @@ ruleTester.run(RULE_NAME, rule, {
241241
},
242242
},
243243
},
244+
{
245+
code: /* tsx */ `
246+
import * as React from 'react'
247+
const Component = React.forwardRef<HTMLElement, { foo: string }>(function Component({ foo }, r) {
248+
return <div ref={r}>{foo}</div>;
249+
});
250+
`,
251+
errors: [{ messageId: "noForwardRef" }],
252+
output: /* tsx */ `
253+
import * as React from 'react'
254+
const Component = function Component({ ref: r, foo }: { foo: string } & { ref: React.RefObject<HTMLElement> }) {
255+
return <div ref={r}>{foo}</div>;
256+
};
257+
`,
258+
settings: {
259+
"react-x": {
260+
version: "19.0.0",
261+
},
262+
},
263+
},
244264
],
245265
valid: [
246266
{

0 commit comments

Comments
 (0)