@@ -829,10 +829,10 @@ ruleTester.run('no-unused-prop-types', rule, {
829
829
type PropsA = { a: string }
830
830
type PropsB = { b: string }
831
831
type Props = PropsA & PropsB;
832
-
832
+
833
833
class MyComponent extends React.Component {
834
834
props: Props;
835
-
835
+
836
836
render() {
837
837
return <div>{this.props.a} - {this.props.b}</div>
838
838
}
@@ -848,7 +848,7 @@ ruleTester.run('no-unused-prop-types', rule, {
848
848
849
849
class Bar extends React.Component {
850
850
props: Props & PropsC;
851
-
851
+
852
852
render() {
853
853
return <div>{this.props.foo} - {this.props.bar} - {this.props.zap}</div>
854
854
}
@@ -864,7 +864,7 @@ ruleTester.run('no-unused-prop-types', rule, {
864
864
865
865
class Bar extends React.Component {
866
866
props: Props & PropsC;
867
-
867
+
868
868
render() {
869
869
return <div>{this.props.foo} - {this.props.bar} - {this.props.zap}</div>
870
870
}
@@ -876,12 +876,12 @@ ruleTester.run('no-unused-prop-types', rule, {
876
876
type PropsB = { foo: string };
877
877
type PropsC = { bar: string };
878
878
type Props = PropsB & {
879
- zap: string
879
+ zap: string
880
880
};
881
881
882
882
class Bar extends React.Component {
883
883
props: Props & PropsC;
884
-
884
+
885
885
render() {
886
886
return <div>{this.props.foo} - {this.props.bar} - {this.props.zap}</div>
887
887
}
@@ -893,12 +893,12 @@ ruleTester.run('no-unused-prop-types', rule, {
893
893
type PropsB = { foo: string };
894
894
type PropsC = { bar: string };
895
895
type Props = {
896
- zap: string
896
+ zap: string
897
897
} & PropsB;
898
898
899
899
class Bar extends React.Component {
900
900
props: Props & PropsC;
901
-
901
+
902
902
render() {
903
903
return <div>{this.props.foo} - {this.props.bar} - {this.props.zap}</div>
904
904
}
@@ -2208,6 +2208,78 @@ ruleTester.run('no-unused-prop-types', rule, {
2208
2208
` ,
2209
2209
settings : { react : { flowVersion : '0.53' } } ,
2210
2210
parser : 'babel-eslint'
2211
+ } , {
2212
+ // Issue #1068
2213
+ code : `
2214
+ class MyComponent extends Component {
2215
+ static propTypes = {
2216
+ validate: PropTypes.bool,
2217
+ options: PropTypes.array,
2218
+ value: ({options, value, validate}) => {
2219
+ if (!validate) return;
2220
+ if (options.indexOf(value) < 0)
2221
+ throw new Errow('oops');
2222
+ }
2223
+ }
2224
+
2225
+ render() {
2226
+ return <ul>
2227
+ {this.props.options.map(option =>
2228
+ <li className={this.props.value == option && "active"}>{option}</li>
2229
+ )}
2230
+ </ul>
2231
+ }
2232
+ }
2233
+ ` ,
2234
+ parser : 'babel-eslint'
2235
+ } , {
2236
+ // Issue #1068
2237
+ code : `
2238
+ class MyComponent extends Component {
2239
+ static propTypes = {
2240
+ validate: PropTypes.bool,
2241
+ options: PropTypes.array,
2242
+ value: function ({options, value, validate}) {
2243
+ if (!validate) return;
2244
+ if (options.indexOf(value) < 0)
2245
+ throw new Errow('oops');
2246
+ }
2247
+ }
2248
+
2249
+ render() {
2250
+ return <ul>
2251
+ {this.props.options.map(option =>
2252
+ <li className={this.props.value == option && "active"}>{option}</li>
2253
+ )}
2254
+ </ul>
2255
+ }
2256
+ }
2257
+ ` ,
2258
+ parser : 'babel-eslint'
2259
+ } , {
2260
+ // Issue #1068
2261
+ code : `
2262
+ class MyComponent extends Component {
2263
+ static propTypes = {
2264
+ validate: PropTypes.bool,
2265
+ options: PropTypes.array,
2266
+ value({options, value, validate}) {
2267
+ if (!validate) return;
2268
+ if (options.indexOf(value) < 0)
2269
+ throw new Errow('oops');
2270
+ }
2271
+ }
2272
+
2273
+ render() {
2274
+ return <ul>
2275
+ {this.props.options.map(option =>
2276
+ <li className={this.props.value == option && "active"}>{option}</li>
2277
+ )}
2278
+ </ul>
2279
+ }
2280
+ }
2281
+ ` ,
2282
+ parser : 'babel-eslint'
2211
2283
}
2212
2284
] ,
2213
2285
@@ -2796,10 +2868,10 @@ ruleTester.run('no-unused-prop-types', rule, {
2796
2868
type PropsA = { a: string }
2797
2869
type PropsB = { b: string }
2798
2870
type Props = PropsA & PropsB;
2799
-
2871
+
2800
2872
class MyComponent extends React.Component {
2801
2873
props: Props;
2802
-
2874
+
2803
2875
render() {
2804
2876
return <div>{this.props.a}</div>
2805
2877
}
@@ -2818,7 +2890,7 @@ ruleTester.run('no-unused-prop-types', rule, {
2818
2890
2819
2891
class Bar extends React.Component {
2820
2892
props: Props & PropsC;
2821
-
2893
+
2822
2894
render() {
2823
2895
return <div>{this.props.foo} - {this.props.bar}</div>
2824
2896
}
@@ -2833,12 +2905,12 @@ ruleTester.run('no-unused-prop-types', rule, {
2833
2905
type PropsB = { foo: string };
2834
2906
type PropsC = { bar: string };
2835
2907
type Props = PropsB & {
2836
- zap: string
2908
+ zap: string
2837
2909
};
2838
2910
2839
2911
class Bar extends React.Component {
2840
2912
props: Props & PropsC;
2841
-
2913
+
2842
2914
render() {
2843
2915
return <div>{this.props.foo} - {this.props.bar}</div>
2844
2916
}
@@ -2853,12 +2925,12 @@ ruleTester.run('no-unused-prop-types', rule, {
2853
2925
type PropsB = { foo: string };
2854
2926
type PropsC = { bar: string };
2855
2927
type Props = {
2856
- zap: string
2928
+ zap: string
2857
2929
} & PropsB;
2858
2930
2859
2931
class Bar extends React.Component {
2860
2932
props: Props & PropsC;
2861
-
2933
+
2862
2934
render() {
2863
2935
return <div>{this.props.foo} - {this.props.bar}</div>
2864
2936
}
0 commit comments