Skip to content

Commit

Permalink
Merge pull request #153 from CalebMorris/fix/typeOfChildTypes
Browse files Browse the repository at this point in the history
Change oneOfType to actually keep the child types (fixes #148)
  • Loading branch information
yannickcr committed Jul 15, 2015
2 parents ab4da9f + 6296ca3 commit 4a91497
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,9 @@ module.exports = function(context) {
unionTypeDefinition.children = true;
return unionTypeDefinition;
}
unionTypeDefinition.children.push(type);
}

unionTypeDefinition.children.push(type);
}
if (unionTypeDefinition.length === 0) {
// no complex type found, simply accept everything
Expand Down
19 changes: 19 additions & 0 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,25 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
classes: true,
jsx: true
}
}, {
code: [
'class Hello extends React.Component {',
' render() {',
' this.props.a.length;',
' return <div>Hello</div>;',
' }',
'}',
'Hello.propTypes = {',
' a: React.PropTypes.oneOfType([',
' React.PropTypes.array,',
' React.PropTypes.string',
' ])',
'};'
].join('\n'),
ecmaFeatures: {
classes: true,
jsx: true
}
}, {
code: [
'class Hello extends React.Component {',
Expand Down

0 comments on commit 4a91497

Please sign in to comment.