Skip to content

Commit

Permalink
Merge pull request #1312 from DianaSuvorova/fixes_816
Browse files Browse the repository at this point in the history
Adds more test cases.

Fixes #816.
  • Loading branch information
ljharb committed Jul 23, 2017
2 parents 8bfafe1 + 5488fff commit 3c7a065
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/lib/rules/no-unused-prop-types.js
Expand Up @@ -1858,6 +1858,39 @@ ruleTester.run('no-unused-prop-types', rule, {
'}'
].join('\n'),
parserOptions: Object.assign({}, parserOptions, {ecmaVersion: 2017})
},
{
// Destructured assignment with Shape propTypes issue #816
code: [
'export default class NavigationButton extends React.Component {',
' static propTypes = {',
' route: PropTypes.shape({',
' getBarTintColor: PropTypes.func.isRequired,',
' }).isRequired,',
' };',

' renderTitle() {',
' const { route } = this.props;',
' return <Title tintColor={route.getBarTintColor()}>TITLE</Title>;',
' }',
'}'
].join('\n'),
parser: 'babel-eslint'
}, {
// Destructured assignment without Shape propTypes issue #816
code: [
'const Component = ({ children: aNode }) => (',
' <div>{aNode}</div>',
');',

'Component.defaultProps = {',
' children: null,',
'};',

'Component.propTypes = {',
' children: React.PropTypes.node,',
'};'
].join('\n')
}
],

Expand Down Expand Up @@ -3189,8 +3222,29 @@ ruleTester.run('no-unused-prop-types', rule, {
}, {
message: '\'prop2.*\' PropType is defined but prop is never used'
}]
}, {
// Destructured assignment with Shape propTypes with skipShapeProps off issue #816
code: [
'export default class NavigationButton extends React.Component {',
' static propTypes = {',
' route: PropTypes.shape({',
' getBarTintColor: PropTypes.func.isRequired,',
' }).isRequired,',
' };',

' renderTitle() {',
' const { route } = this.props;',
' return <Title tintColor={route.getBarTintColor()}>TITLE</Title>;',
' }',
'}'
].join('\n'),
parser: 'babel-eslint',
options: [{skipShapeProps: false}],
errors: [{
message: '\'route.getBarTintColor\' PropType is defined but prop is never used'
}]
}

/* , {
// Enable this when the following issue is fixed
// https://github.com/yannickcr/eslint-plugin-react/issues/296
Expand Down

0 comments on commit 3c7a065

Please sign in to comment.