@@ -154,7 +154,7 @@ module.exports = {
154154 while ( node ) {
155155 const component = components . get ( node ) ;
156156
157- const isDeclared = component && component . confidence == = 2
157+ const isDeclared = component && component . confidence > = 2
158158 && internalIsDeclaredInComponent ( component . declaredPropTypes || { } , names ) ;
159159
160160 if ( isDeclared ) {
@@ -186,13 +186,36 @@ module.exports = {
186186 } ) ;
187187 }
188188
189+ /**
190+ * @param {Object } component The current component to process
191+ * @param {Array } list The all components to process
192+ * @returns {Boolean } True if the component is nested False if not.
193+ */
194+ function checkNestedComponent ( component , list ) {
195+ const componentIsMemo = component . node . callee && component . node . callee . name === 'memo' ;
196+ const argumentIsForwardRef = component . node . arguments && component . node . arguments [ 0 ] . callee && component . node . arguments [ 0 ] . callee . name === 'forwardRef' ;
197+ if ( componentIsMemo && argumentIsForwardRef ) {
198+ const forwardComponent = list . find (
199+ ( innerComponent ) => (
200+ innerComponent . node . range [ 0 ] === component . node . arguments [ 0 ] . range [ 0 ]
201+ && innerComponent . node . range [ 0 ] === component . node . arguments [ 0 ] . range [ 0 ]
202+ ) ) ;
203+
204+ const isValidated = mustBeValidated ( forwardComponent ) ;
205+ const isIgnorePropsValidation = forwardComponent . ignorePropsValidation ;
206+
207+ return isIgnorePropsValidation || isValidated ;
208+ }
209+ }
210+
189211 return {
190212 'Program:exit' ( ) {
191213 const list = components . list ( ) ;
192214 // Report undeclared proptypes for all classes
193215 values ( list )
194216 . filter ( ( component ) => mustBeValidated ( component ) )
195217 . forEach ( ( component ) => {
218+ if ( checkNestedComponent ( component , values ( list ) ) ) return ;
196219 reportUndeclaredPropTypes ( component ) ;
197220 } ) ;
198221 } ,
0 commit comments