Skip to content

Fixes #816 #1312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions tests/lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
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