Skip to content

Commit f86ec7d

Browse files
committed
test(plugins/x): add '...rest' props test cases to 'no-forward-ref'
1 parent 91d8ee0 commit f86ec7d

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
@@ -261,6 +261,26 @@ ruleTester.run(RULE_NAME, rule, {
261261
},
262262
},
263263
},
264+
{
265+
code: /* tsx */ `
266+
import * as React from 'react'
267+
const Component = React.forwardRef<HTMLElement, { foo: string, bar: number }>(function Component({ foo, ...rest }, r) {
268+
return <div ref={r}>{foo}</div>;
269+
});
270+
`,
271+
errors: [{ messageId: "noForwardRef" }],
272+
output: /* tsx */ `
273+
import * as React from 'react'
274+
const Component = function Component({ ref: r, foo, ...rest }: { foo: string, bar: number } & { ref: React.RefObject<HTMLElement> }) {
275+
return <div ref={r}>{foo}</div>;
276+
};
277+
`,
278+
settings: {
279+
"react-x": {
280+
version: "19.0.0",
281+
},
282+
},
283+
},
264284
],
265285
valid: [
266286
{

0 commit comments

Comments
 (0)