From 7e09de1836c2c3818054a86aea598c4906973f9a Mon Sep 17 00:00:00 2001 From: Caleb Morris Date: Tue, 14 Jul 2015 13:22:48 -0700 Subject: [PATCH 1/2] Changed oneOfType to actually keep the child types --- lib/rules/prop-types.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rules/prop-types.js b/lib/rules/prop-types.js index 12720d2c63..365c491fc9 100644 --- a/lib/rules/prop-types.js +++ b/lib/rules/prop-types.js @@ -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 From 6296ca3e099932cd33789fb8447a9f8425ad53a5 Mon Sep 17 00:00:00 2001 From: Caleb Morris Date: Wed, 15 Jul 2015 12:07:37 -0700 Subject: [PATCH 2/2] Added unit test for oneOfType with non-complex type possibilties --- tests/lib/rules/prop-types.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index 6ca24512ac..56c4b607a9 100644 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -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
Hello
;', + ' }', + '}', + '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 {',