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) {
162
162
var declaredPropTypes = component && component . declaredPropTypes || [ ] ;
163
163
var ignorePropsValidation = false ;
164
164
165
- switch ( propTypes . type ) {
165
+ switch ( propTypes && propTypes . type ) {
166
166
case 'ObjectExpression' :
167
167
for ( var i = 0 , j = propTypes . properties . length ; i < j ; i ++ ) {
168
168
var key = propTypes . properties [ i ] . key ;
@@ -172,6 +172,8 @@ module.exports = function(context) {
172
172
case 'MemberExpression' :
173
173
declaredPropTypes . push ( propTypes . property . name ) ;
174
174
break ;
175
+ case null :
176
+ break ;
175
177
default :
176
178
ignorePropsValidation = true ;
177
179
break ;
Original file line number Diff line number Diff line change @@ -359,6 +359,25 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
359
359
errors : [ {
360
360
message : '\'lastname\' is missing in props validation for Hello'
361
361
} ]
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
+ } ]
362
381
}
363
382
]
364
383
} ) ;
You can’t perform that action at this time.
0 commit comments