Skip to content

Commit cea8591

Browse files
committed
Add failing and working tests that were raised in the issue
1 parent f0dcaca commit cea8591

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,51 @@ ruleTester.run('no-unused-prop-types', rule, {
14391439
'}'
14401440
].join('\n'),
14411441
parser: 'babel-eslint'
1442+
}, {
1443+
// The next two test cases are related to: https://github.com/yannickcr/eslint-plugin-react/issues/1183
1444+
code: [
1445+
'export default function SomeComponent(props) {',
1446+
' const callback = () => {',
1447+
' props.a(props.b);',
1448+
' };',
1449+
'',
1450+
' const anotherCallback = () => {};',
1451+
'',
1452+
' return (',
1453+
' <SomeOtherComponent',
1454+
' name={props.c}',
1455+
' callback={callback}',
1456+
' />',
1457+
' );',
1458+
'}',
1459+
'',
1460+
'SomeComponent.propTypes = {',
1461+
' a: React.PropTypes.func.isRequired,',
1462+
' b: React.PropTypes.string.isRequired,',
1463+
' c: React.PropTypes.string.isRequired,',
1464+
'};'
1465+
].join('\n')
1466+
}, {
1467+
code: [
1468+
'export default function SomeComponent(props) {',
1469+
' const callback = () => {',
1470+
' props.a(props.b);',
1471+
' };',
1472+
'',
1473+
' return (',
1474+
' <SomeOtherComponent',
1475+
' name={props.c}',
1476+
' callback={callback}',
1477+
' />',
1478+
' );',
1479+
'}',
1480+
'',
1481+
'SomeComponent.propTypes = {',
1482+
' a: React.PropTypes.func.isRequired,',
1483+
' b: React.PropTypes.string.isRequired,',
1484+
' c: React.PropTypes.string.isRequired,',
1485+
'};'
1486+
].join('\n')
14421487
}
14431488
],
14441489

0 commit comments

Comments
 (0)