@@ -818,6 +818,34 @@ ruleTester.run('prop-types', rule, {
818818 '};'
819819 ] . join ( '\n' ) ,
820820 parser : 'babel-eslint'
821+ } , {
822+ code : [
823+ 'function HelloComponent() {' ,
824+ ' class Hello extends React.Component {' ,
825+ ' render() {' ,
826+ ' return <div>Hello {this.props.name}</div>;' ,
827+ ' }' ,
828+ ' }' ,
829+ ' Hello.propTypes = { name: React.PropTypes.string };' ,
830+ ' return Hello;' ,
831+ '}' ,
832+ 'module.exports = HelloComponent();'
833+ ] . join ( '\n' ) ,
834+ parser : 'babel-eslint'
835+ } , {
836+ code : [
837+ 'function HelloComponent() {' ,
838+ ' var Hello = React.createClass({' ,
839+ ' propTypes: { name: React.PropTypes.string },' ,
840+ ' render: function() {' ,
841+ ' return <div>Hello {this.props.name}</div>;' ,
842+ ' }' ,
843+ ' });' ,
844+ ' return Hello;' ,
845+ '}' ,
846+ 'module.exports = HelloComponent();'
847+ ] . join ( '\n' ) ,
848+ parser : 'babel-eslint'
821849 }
822850 ] ,
823851
@@ -1326,6 +1354,38 @@ ruleTester.run('prop-types', rule, {
13261354 { message : '\'source\' is missing in props validation for Hello' } ,
13271355 { message : '\'source.uri\' is missing in props validation for Hello' }
13281356 ]
1357+ } , {
1358+ code : [
1359+ 'function HelloComponent() {' ,
1360+ ' class Hello extends React.Component {' ,
1361+ ' render() {' ,
1362+ ' return <div>Hello {this.props.name}</div>;' ,
1363+ ' }' ,
1364+ ' }' ,
1365+ ' return Hello;' ,
1366+ '}' ,
1367+ 'module.exports = HelloComponent();'
1368+ ] . join ( '\n' ) ,
1369+ parser : 'babel-eslint' ,
1370+ errors : [
1371+ { message : '\'name\' is missing in props validation for Hello' }
1372+ ]
1373+ } , {
1374+ code : [
1375+ 'function HelloComponent() {' ,
1376+ ' var Hello = React.createClass({' ,
1377+ ' render: function() {' ,
1378+ ' return <div>Hello {this.props.name}</div>;' ,
1379+ ' }' ,
1380+ ' });' ,
1381+ ' return Hello;' ,
1382+ '}' ,
1383+ 'module.exports = HelloComponent();'
1384+ ] . join ( '\n' ) ,
1385+ parser : 'babel-eslint' ,
1386+ errors : [
1387+ { message : '\'name\' is missing in props validation for Hello' }
1388+ ]
13291389 }
13301390 ]
13311391} ) ;
0 commit comments