Skip to content

Commit 4a91497

Browse files
committed
Merge pull request #153 from CalebMorris/fix/typeOfChildTypes
Change oneOfType to actually keep the child types (fixes #148)
2 parents ab4da9f + 6296ca3 commit 4a91497

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/rules/prop-types.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,9 @@ module.exports = function(context) {
276276
unionTypeDefinition.children = true;
277277
return unionTypeDefinition;
278278
}
279-
unionTypeDefinition.children.push(type);
280279
}
280+
281+
unionTypeDefinition.children.push(type);
281282
}
282283
if (unionTypeDefinition.length === 0) {
283284
// no complex type found, simply accept everything

tests/lib/rules/prop-types.js

+19
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,25 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
351351
classes: true,
352352
jsx: true
353353
}
354+
}, {
355+
code: [
356+
'class Hello extends React.Component {',
357+
' render() {',
358+
' this.props.a.length;',
359+
' return <div>Hello</div>;',
360+
' }',
361+
'}',
362+
'Hello.propTypes = {',
363+
' a: React.PropTypes.oneOfType([',
364+
' React.PropTypes.array,',
365+
' React.PropTypes.string',
366+
' ])',
367+
'};'
368+
].join('\n'),
369+
ecmaFeatures: {
370+
classes: true,
371+
jsx: true
372+
}
354373
}, {
355374
code: [
356375
'class Hello extends React.Component {',

0 commit comments

Comments
 (0)