Skip to content

Commit 65eb9b6

Browse files
committed
add test cases
1 parent ac47d4b commit 65eb9b6

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

tests/lib/rules/prop-types.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3435,6 +3435,18 @@ ruleTester.run('prop-types', rule, {
34353435
`,
34363436
features: ['ts', 'no-babel'],
34373437
},
3438+
{
3439+
code: `
3440+
import React, { ForwardRefRenderFunction } from 'react'
3441+
3442+
type IfooProps = { e: string };
3443+
const Foo: ForwardRefRenderFunction<HTMLDivElement, IfooProps> = (props, ref) => {
3444+
const { e } = props;
3445+
return <div ref={ref}>hello</div>;
3446+
};
3447+
`,
3448+
features: ['ts', 'no-babel'],
3449+
},
34383450
{
34393451
code: `
34403452
import React from 'react'
@@ -3459,6 +3471,39 @@ ruleTester.run('prop-types', rule, {
34593471
`,
34603472
features: ['ts', 'no-babel'],
34613473
},
3474+
{
3475+
code: `
3476+
import React from 'react'
3477+
type IfooProps = { e: string };
3478+
const Foo= React.forwardRef<HTMLDivElement, IfooProps>(function Foo(props, ref) {
3479+
const { e } = props;
3480+
return <div ref={ref}>hello</div>;
3481+
});
3482+
`,
3483+
features: ['ts', 'no-babel'],
3484+
},
3485+
{
3486+
code: `
3487+
import React from 'react'
3488+
interface IfooProps { e: string }
3489+
const Foo= React.forwardRef<HTMLDivElement, IfooProps>(function Foo(props, ref) {
3490+
const { e } = props;
3491+
return <div ref={ref}>hello</div>;
3492+
});
3493+
`,
3494+
features: ['ts', 'no-babel'],
3495+
},
3496+
{
3497+
code: `
3498+
import React, { forwardRef } from 'react'
3499+
interface IfooProps { e: string }
3500+
const Foo= forwardRef<HTMLDivElement, IfooProps>(function Foo(props, ref) {
3501+
const { e } = props;
3502+
return <div ref={ref}>hello</div>;
3503+
});
3504+
`,
3505+
features: ['ts', 'no-babel'],
3506+
},
34623507
{
34633508
code: `
34643509
import React, { forwardRef as X } from 'react'
@@ -7235,6 +7280,42 @@ ruleTester.run('prop-types', rule, {
72357280
},
72367281
],
72377282
features: ['ts', 'no-babel'],
7283+
},
7284+
{
7285+
code: `
7286+
import React from 'react'
7287+
7288+
type IfooProps = { e: string };
7289+
const Foo= React.forwardRef<HTMLDivElement, IfooProps>(function Foo(props, ref) {
7290+
const { l } = props;
7291+
return <div ref={ref}>hello</div>;
7292+
});
7293+
`,
7294+
errors: [
7295+
{
7296+
messageId: 'missingPropType',
7297+
data: { name: 'l' },
7298+
},
7299+
],
7300+
features: ['ts', 'no-babel'],
7301+
},
7302+
{
7303+
code: `
7304+
import React, { forwardRef } from 'react'
7305+
7306+
type IfooProps = { e: string };
7307+
const Foo= forwardRef<HTMLDivElement, IfooProps>(function Foo(props, ref) {
7308+
const { l } = props;
7309+
return <div ref={ref}>hello</div>;
7310+
});
7311+
`,
7312+
errors: [
7313+
{
7314+
messageId: 'missingPropType',
7315+
data: { name: 'l' },
7316+
},
7317+
],
7318+
features: ['ts', 'no-babel'],
72387319
}
72397320
)),
72407321
});

0 commit comments

Comments
 (0)