File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ module.exports = function(context) {
162162 var declaredPropTypes = component && component . declaredPropTypes || [ ] ;
163163 var ignorePropsValidation = false ;
164164
165- switch ( propTypes . type ) {
165+ switch ( propTypes && propTypes . type ) {
166166 case 'ObjectExpression' :
167167 for ( var i = 0 , j = propTypes . properties . length ; i < j ; i ++ ) {
168168 var key = propTypes . properties [ i ] . key ;
@@ -172,6 +172,8 @@ module.exports = function(context) {
172172 case 'MemberExpression' :
173173 declaredPropTypes . push ( propTypes . property . name ) ;
174174 break ;
175+ case null :
176+ break ;
175177 default :
176178 ignorePropsValidation = true ;
177179 break ;
Original file line number Diff line number Diff line change @@ -359,6 +359,25 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
359359 errors : [ {
360360 message : '\'lastname\' is missing in props validation for Hello'
361361 } ]
362+ } , {
363+ code : [
364+ 'class Hello extends React.Component {' ,
365+ ' static propTypes: { ' ,
366+ ' firstname: React.PropTypes.string' ,
367+ ' }' ,
368+ ' render() {' ,
369+ ' return <div>Hello {this.props.firstname}</div>;' ,
370+ ' }' ,
371+ '}'
372+ ] . join ( '\n' ) ,
373+ parser : 'babel-eslint' ,
374+ ecmaFeatures : {
375+ classes : true ,
376+ jsx : true
377+ } ,
378+ errors : [ {
379+ message : '\'firstname\' is missing in props validation for Hello'
380+ } ]
362381 }
363382 ]
364383} ) ;
You can’t perform that action at this time.
0 commit comments