Skip to content

Commit

Permalink
Fix prop-types to correcly assign props to components (fixes #991)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Jan 8, 2017
1 parent 13806f1 commit bad47d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ module.exports = {
}

var component = components.get(utils.getParentComponent());
var usedPropTypes = component && component.usedPropTypes || [];
var usedPropTypes = (component && component.usedPropTypes || []).slice();

switch (type) {
case 'direct':
Expand Down
13 changes: 13 additions & 0 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,19 @@ ruleTester.run('prop-types', rule, {
jsx: true
}
}
}, {
code: [
'export class Example extends Component {',
' static propTypes = {',
' onDelete: React.PropTypes.func.isRequired',
' }',
' handleDeleteConfirm = () => {',
' this.props.onDelete();',
' };',
' handleSubmit = async ({certificate, key}) => {};',
'}'
].join('\n'),
parser: 'babel-eslint'
}
],

Expand Down

0 comments on commit bad47d6

Please sign in to comment.