@@ -19,8 +19,6 @@ const parserOptions = {
19
19
}
20
20
} ;
21
21
22
- require ( 'babel-eslint' ) ;
23
-
24
22
// -----------------------------------------------------------------------------
25
23
// Tests
26
24
// -----------------------------------------------------------------------------
@@ -190,6 +188,18 @@ ruleTester.run('forbid-prop-types', rule, {
190
188
'}'
191
189
] . join ( '\n' ) ,
192
190
parser : 'babel-eslint'
191
+ } , {
192
+ // Proptypes declared with a spread property
193
+ code : [
194
+ 'class Test extends react.component {' ,
195
+ ' static get propTypes() {' ,
196
+ ' return {' ,
197
+ ' intl: React.propTypes.number,' ,
198
+ ' ...propTypes' ,
199
+ ' };' ,
200
+ ' };' ,
201
+ '}'
202
+ ] . join ( '\n' )
193
203
} , {
194
204
code : [
195
205
'var First = createReactClass({' ,
@@ -351,6 +361,19 @@ ruleTester.run('forbid-prop-types', rule, {
351
361
] . join ( '\n' ) ,
352
362
parser : 'babel-eslint' ,
353
363
options : [ { checkContextTypes : true } ]
364
+ } , {
365
+ // Proptypes declared with a spread property
366
+ code : [
367
+ 'class Test extends react.component {' ,
368
+ ' static get childContextTypes() {' ,
369
+ ' return {' ,
370
+ ' intl: React.childContextTypes.number,' ,
371
+ ' ...childContextTypes' ,
372
+ ' };' ,
373
+ ' };' ,
374
+ '}'
375
+ ] . join ( '\n' ) ,
376
+ options : [ { checkContextTypes : true } ]
354
377
} , {
355
378
code : [
356
379
'var First = createReactClass({' ,
@@ -512,6 +535,19 @@ ruleTester.run('forbid-prop-types', rule, {
512
535
] . join ( '\n' ) ,
513
536
parser : 'babel-eslint' ,
514
537
options : [ { checkChildContextTypes : true } ]
538
+ } , {
539
+ // Proptypes declared with a spread property
540
+ code : [
541
+ 'class Test extends react.component {' ,
542
+ ' static get childContextTypes() {' ,
543
+ ' return {' ,
544
+ ' intl: React.childContextTypes.number,' ,
545
+ ' ...childContextTypes' ,
546
+ ' };' ,
547
+ ' };' ,
548
+ '}'
549
+ ] . join ( '\n' ) ,
550
+ options : [ { checkChildContextTypes : true } ]
515
551
} ] ,
516
552
517
553
invalid : [ {
@@ -753,6 +789,21 @@ ruleTester.run('forbid-prop-types', rule, {
753
789
] . join ( '\n' ) ,
754
790
parser : 'babel-eslint' ,
755
791
errors : 2
792
+ } , {
793
+ code : [
794
+ 'class Component extends React.Component {' ,
795
+ ' static get propTypes() {' ,
796
+ ' return {' ,
797
+ ' a: PropTypes.array,' ,
798
+ ' o: PropTypes.object' ,
799
+ ' };' ,
800
+ ' };' ,
801
+ ' render() {' ,
802
+ ' return <div />;' ,
803
+ ' }' ,
804
+ '}'
805
+ ] . join ( '\n' ) ,
806
+ errors : 2
756
807
} , {
757
808
code : [
758
809
'class Component extends React.Component {' ,
@@ -770,6 +821,24 @@ ruleTester.run('forbid-prop-types', rule, {
770
821
settings : {
771
822
propWrapperFunctions : [ 'forbidExtraProps' ]
772
823
}
824
+ } , {
825
+ code : [
826
+ 'class Component extends React.Component {' ,
827
+ ' static get propTypes() {' ,
828
+ ' return forbidExtraProps({' ,
829
+ ' a: PropTypes.array,' ,
830
+ ' o: PropTypes.object' ,
831
+ ' });' ,
832
+ ' }' ,
833
+ ' render() {' ,
834
+ ' return <div />;' ,
835
+ ' }' ,
836
+ '}'
837
+ ] . join ( '\n' ) ,
838
+ errors : 2 ,
839
+ settings : {
840
+ propWrapperFunctions : [ 'forbidExtraProps' ]
841
+ }
773
842
} , {
774
843
code : [
775
844
'var Hello = createReactClass({' ,
@@ -839,6 +908,26 @@ ruleTester.run('forbid-prop-types', rule, {
839
908
column : 5 ,
840
909
type : 'Property'
841
910
} ]
911
+ } , {
912
+ code : [
913
+ 'class Foo extends Component {' ,
914
+ ' static get contextTypes() {' ,
915
+ ' return {' ,
916
+ ' a: PropTypes.any' ,
917
+ ' };' ,
918
+ ' }' ,
919
+ ' render() {' ,
920
+ ' return <div />;' ,
921
+ ' }' ,
922
+ '}'
923
+ ] . join ( '\n' ) ,
924
+ options : [ { checkContextTypes : true } ] ,
925
+ errors : [ {
926
+ message : ANY_ERROR_MESSAGE ,
927
+ line : 4 ,
928
+ column : 7 ,
929
+ type : 'Property'
930
+ } ]
842
931
} , {
843
932
code : [
844
933
'class Foo extends Component {' ,
@@ -907,6 +996,25 @@ ruleTester.run('forbid-prop-types', rule, {
907
996
settings : {
908
997
propWrapperFunctions : [ 'forbidExtraProps' ]
909
998
}
999
+ } , {
1000
+ code : [
1001
+ 'class Component extends React.Component {' ,
1002
+ ' static get contextTypes() {' ,
1003
+ ' return forbidExtraProps({' ,
1004
+ ' a: PropTypes.array,' ,
1005
+ ' o: PropTypes.object' ,
1006
+ ' });' ,
1007
+ ' }' ,
1008
+ ' render() {' ,
1009
+ ' return <div />;' ,
1010
+ ' }' ,
1011
+ '}'
1012
+ ] . join ( '\n' ) ,
1013
+ errors : 2 ,
1014
+ options : [ { checkContextTypes : true } ] ,
1015
+ settings : {
1016
+ propWrapperFunctions : [ 'forbidExtraProps' ]
1017
+ }
910
1018
} , {
911
1019
code : [
912
1020
'class Component extends React.Component {' ,
@@ -989,6 +1097,25 @@ ruleTester.run('forbid-prop-types', rule, {
989
1097
checkContextTypes : true
990
1098
} ] ,
991
1099
errors : 1
1100
+ } , {
1101
+ code : [
1102
+ 'class Component extends React.Component {' ,
1103
+ ' static get contextTypes() {' ,
1104
+ ' return {' ,
1105
+ ' retailer: PropTypes.instanceOf(Map).isRequired,' ,
1106
+ ' requestRetailer: PropTypes.func.isRequired' ,
1107
+ ' };' ,
1108
+ ' }' ,
1109
+ ' render() {' ,
1110
+ ' return <div />;' ,
1111
+ ' }' ,
1112
+ '}'
1113
+ ] . join ( '\n' ) ,
1114
+ options : [ {
1115
+ forbid : [ 'instanceOf' ] ,
1116
+ checkContextTypes : true
1117
+ } ] ,
1118
+ errors : 1
992
1119
} , {
993
1120
code : [
994
1121
'class Component extends React.Component {' ,
@@ -1073,6 +1200,26 @@ ruleTester.run('forbid-prop-types', rule, {
1073
1200
column : 5 ,
1074
1201
type : 'Property'
1075
1202
} ]
1203
+ } , {
1204
+ code : [
1205
+ 'class Foo extends Component {' ,
1206
+ ' static get childContextTypes() {' ,
1207
+ ' return {' ,
1208
+ ' a: PropTypes.any' ,
1209
+ ' };' ,
1210
+ ' }' ,
1211
+ ' render() {' ,
1212
+ ' return <div />;' ,
1213
+ ' }' ,
1214
+ '}'
1215
+ ] . join ( '\n' ) ,
1216
+ options : [ { checkChildContextTypes : true } ] ,
1217
+ errors : [ {
1218
+ message : ANY_ERROR_MESSAGE ,
1219
+ line : 4 ,
1220
+ column : 7 ,
1221
+ type : 'Property'
1222
+ } ]
1076
1223
} , {
1077
1224
code : [
1078
1225
'class Foo extends Component {' ,
@@ -1141,6 +1288,25 @@ ruleTester.run('forbid-prop-types', rule, {
1141
1288
settings : {
1142
1289
propWrapperFunctions : [ 'forbidExtraProps' ]
1143
1290
}
1291
+ } , {
1292
+ code : [
1293
+ 'class Component extends React.Component {' ,
1294
+ ' static get childContextTypes() {' ,
1295
+ ' return forbidExtraProps({' ,
1296
+ ' a: PropTypes.array,' ,
1297
+ ' o: PropTypes.object' ,
1298
+ ' });' ,
1299
+ ' }' ,
1300
+ ' render() {' ,
1301
+ ' return <div />;' ,
1302
+ ' }' ,
1303
+ '}'
1304
+ ] . join ( '\n' ) ,
1305
+ errors : 2 ,
1306
+ options : [ { checkChildContextTypes : true } ] ,
1307
+ settings : {
1308
+ propWrapperFunctions : [ 'forbidExtraProps' ]
1309
+ }
1144
1310
} , {
1145
1311
code : [
1146
1312
'class Component extends React.Component {' ,
0 commit comments