@@ -3608,7 +3608,7 @@ ruleTester.run('prop-types', rule, {
3608
3608
{
3609
3609
code : `
3610
3610
import React, { forwardRef } from "react";
3611
-
3611
+
3612
3612
export type Props = { children: React.ReactNode; type: "submit" | "button" };
3613
3613
3614
3614
export const FancyButton = forwardRef<HTMLButtonElement, Props>((props, ref) => (
@@ -3681,7 +3681,7 @@ ruleTester.run('prop-types', rule, {
3681
3681
label: string,
3682
3682
disabled?: boolean
3683
3683
} & {};
3684
-
3684
+
3685
3685
const Button: React.FC<ButtonProps> = ({ children, icon, label, disabled }: ButtonProps) => {
3686
3686
return <div />;
3687
3687
}
@@ -3696,11 +3696,11 @@ ruleTester.run('prop-types', rule, {
3696
3696
const {baz} = Foo
3697
3697
return <div>{baz} {bar}</div>
3698
3698
}
3699
-
3699
+
3700
3700
Foo.propTypes = {
3701
3701
bar: PropTypes.string.isRequired,
3702
3702
}
3703
-
3703
+
3704
3704
Foo.baz = 'hi'
3705
3705
` ,
3706
3706
} ,
@@ -3710,14 +3710,42 @@ ruleTester.run('prop-types', rule, {
3710
3710
type Props = {
3711
3711
'data-hover': string
3712
3712
}
3713
-
3713
+
3714
3714
function MyComponent({
3715
3715
'data-hover': dataHover
3716
3716
}: Props) {
3717
3717
return <span data-hover={dataHover} />
3718
3718
}
3719
3719
` ,
3720
3720
features : [ 'types' ] ,
3721
+ } ,
3722
+ {
3723
+ code : `
3724
+ import React, { PropTypes } from 'react';
3725
+
3726
+ function MyComponent({ name }) {
3727
+ const someParams = {
3728
+ userName: name,
3729
+ greeting: 'Hi there',
3730
+ };
3731
+
3732
+ function getMessage({ userName, greeting }) {
3733
+ return <span>\`\${greeting} \${userName}\`</span>;
3734
+ }
3735
+
3736
+ return (
3737
+ <div>
3738
+ { getMessage(someParams) }
3739
+ </div>
3740
+ );
3741
+ }
3742
+
3743
+ MyComponent.propTypes = {
3744
+ name: PropTypes.string.isRequired,
3745
+ };
3746
+
3747
+ export default MyComponent;
3748
+ ` ,
3721
3749
}
3722
3750
) ) ,
3723
3751
@@ -7494,7 +7522,7 @@ ruleTester.run('prop-types', rule, {
7494
7522
{
7495
7523
code : `
7496
7524
import React, { forwardRef } from "react";
7497
-
7525
+
7498
7526
export type Props = { children: React.ReactNode; type: "submit" | "button" };
7499
7527
7500
7528
export const FancyButton = forwardRef<HTMLButtonElement, Props>((props, ref) => (
@@ -7514,7 +7542,7 @@ ruleTester.run('prop-types', rule, {
7514
7542
{
7515
7543
code : `
7516
7544
import React, { forwardRef } from "react";
7517
-
7545
+
7518
7546
export interface IProps { children: React.ReactNode; type: "submit" | "button" };
7519
7547
7520
7548
export const FancyButton = forwardRef<HTMLButtonElement, IProps>((props, ref) => (
0 commit comments