Skip to content

Commit 5a00096

Browse files
jzabalaljharb
authored andcommitted
[Test] no-unused-prop-types: add test assigning this.props to a variable
Closes #2177.
1 parent 90d2cdf commit 5a00096

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/lib/rules/no-unused-prop-types.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3667,6 +3667,28 @@ ruleTester.run('no-unused-prop-types', rule, {
36673667
};
36683668
`,
36693669
parser: parsers['@TYPESCRIPT_ESLINT']
3670+
},
3671+
{
3672+
code: `
3673+
class App extends Component {
3674+
static propTypes = {
3675+
notifications: PropTypes.array.isRequired
3676+
};
3677+
customizeNotifications() {
3678+
const props = this.props;
3679+
return props.notifications.map((notification) => notification);
3680+
}
3681+
render() {
3682+
const notifications = this.customizeNotifications();
3683+
return (
3684+
<View>
3685+
{notifications.map((notification) => <Text>{notification}</Text>)}
3686+
</View>
3687+
);
3688+
}
3689+
}
3690+
`,
3691+
parser: parsers.BABEL_ESLINT
36703692
}
36713693
])
36723694
),

0 commit comments

Comments
 (0)