@@ -54,6 +54,20 @@ module.exports = function(context) {
5454 return ignored . indexOf ( name ) !== - 1 ;
5555 }
5656
57+ /**
58+ * Checks if the component must be validated
59+ * @param {Object } component The component to process
60+ * @returns {Boolean } True if the component must be validated, false if not.
61+ */
62+ function mustBeValidated ( component ) {
63+ return (
64+ component &&
65+ component . isReactComponent &&
66+ component . usedPropTypes &&
67+ ! component . ignorePropsValidation
68+ ) ;
69+ }
70+
5771 /**
5872 * Checks if the prop is declared
5973 * @param {String } name Name of the prop to check.
@@ -145,9 +159,6 @@ module.exports = function(context) {
145159 * @param {Object } component The component to process
146160 */
147161 function reportUndeclaredPropTypes ( component ) {
148- if ( ! component || ! component . usedPropTypes || component . ignorePropsValidation === true ) {
149- return ;
150- }
151162 var name ;
152163 for ( var i = 0 , j = component . usedPropTypes . length ; i < j ; i ++ ) {
153164 name = component . usedPropTypes [ i ] . name ;
@@ -208,7 +219,7 @@ module.exports = function(context) {
208219 var list = componentList . getList ( ) ;
209220 // Report undeclared proptypes for all classes
210221 for ( var component in list ) {
211- if ( ! list . hasOwnProperty ( component ) ) {
222+ if ( ! list . hasOwnProperty ( component ) || ! mustBeValidated ( list [ component ] ) ) {
212223 continue ;
213224 }
214225 reportUndeclaredPropTypes ( list [ component ] ) ;
@@ -219,7 +230,9 @@ module.exports = function(context) {
219230 if ( ! componentUtil . isReactComponent ( context , node ) ) {
220231 return ;
221232 }
222- componentList . set ( context , node ) ;
233+ componentList . set ( context , node , {
234+ isReactComponent : true
235+ } ) ;
223236 }
224237 } ;
225238
0 commit comments