@@ -3071,10 +3071,10 @@ ruleTester.run('prop-types', rule, {
3071
3071
} , {
3072
3072
code : [
3073
3073
'class Hello extends Component {' ,
3074
- ' static propTypes = forbidExtraProps( {' ,
3074
+ ' static propTypes = {' ,
3075
3075
' bar: PropTypes.func' ,
3076
- ' }) ' ,
3077
- ' shouldComponentUpdate (nextProps) {' ,
3076
+ ' }' ,
3077
+ ' componentWillReceiveProps (nextProps) {' ,
3078
3078
' if (nextProps.foo) {' ,
3079
3079
' return;' ,
3080
3080
' }' ,
@@ -3085,9 +3085,6 @@ ruleTester.run('prop-types', rule, {
3085
3085
'}'
3086
3086
] . join ( '\n' ) ,
3087
3087
parser : 'babel-eslint' ,
3088
- settings : Object . assign ( { } , settings , {
3089
- propWrapperFunctions : [ 'forbidExtraProps' ]
3090
- } ) ,
3091
3088
errors : [
3092
3089
{ message : '\'foo\' is missing in props validation' }
3093
3090
]
@@ -3098,7 +3095,8 @@ ruleTester.run('prop-types', rule, {
3098
3095
' bar: PropTypes.func' ,
3099
3096
' }' ,
3100
3097
' componentWillReceiveProps(nextProps) {' ,
3101
- ' if (nextProps.foo) {' ,
3098
+ ' const {foo} = nextProps;' ,
3099
+ ' if (foo) {' ,
3102
3100
' return;' ,
3103
3101
' }' ,
3104
3102
' }' ,
@@ -3117,8 +3115,7 @@ ruleTester.run('prop-types', rule, {
3117
3115
' static propTypes = {' ,
3118
3116
' bar: PropTypes.func' ,
3119
3117
' }' ,
3120
- ' componentWillReceiveProps(nextProps) {' ,
3121
- ' const {foo} = nextProps;' ,
3118
+ ' componentWillReceiveProps({foo}) {' ,
3122
3119
' if (foo) {' ,
3123
3120
' return;' ,
3124
3121
' }' ,
@@ -3135,9 +3132,6 @@ ruleTester.run('prop-types', rule, {
3135
3132
} , {
3136
3133
code : [
3137
3134
'class Hello extends Component {' ,
3138
- ' static propTypes = {' ,
3139
- ' bar: PropTypes.func' ,
3140
- ' }' ,
3141
3135
' componentWillReceiveProps({foo}) {' ,
3142
3136
' if (foo) {' ,
3143
3137
' return;' ,
@@ -3146,16 +3140,41 @@ ruleTester.run('prop-types', rule, {
3146
3140
' render() {' ,
3147
3141
' return <div bar={this.props.bar} />;' ,
3148
3142
' }' ,
3143
+ '}' ,
3144
+ 'Hello.propTypes = {' ,
3145
+ ' bar: PropTypes.func' ,
3146
+ ' }'
3147
+ ] . join ( '\n' ) ,
3148
+ errors : [
3149
+ { message : '\'foo\' is missing in props validation' }
3150
+ ]
3151
+ } , {
3152
+ code : [
3153
+ 'class Hello extends Component {' ,
3154
+ ' static propTypes = forbidExtraProps({' ,
3155
+ ' bar: PropTypes.func' ,
3156
+ ' })' ,
3157
+ ' shouldComponentUpdate(nextProps) {' ,
3158
+ ' if (nextProps.foo) {' ,
3159
+ ' return;' ,
3160
+ ' }' ,
3161
+ ' }' ,
3162
+ ' render() {' ,
3163
+ ' return <div bar={this.props.bar} />;' ,
3164
+ ' }' ,
3149
3165
'}'
3150
3166
] . join ( '\n' ) ,
3151
3167
parser : 'babel-eslint' ,
3168
+ settings : Object . assign ( { } , settings , {
3169
+ propWrapperFunctions : [ 'forbidExtraProps' ]
3170
+ } ) ,
3152
3171
errors : [
3153
3172
{ message : '\'foo\' is missing in props validation' }
3154
3173
]
3155
3174
} , {
3156
3175
code : [
3157
3176
'class Hello extends Component {' ,
3158
- ' componentWillReceiveProps ({foo}) {' ,
3177
+ ' shouldComponentUpdate ({foo}) {' ,
3159
3178
' if (foo) {' ,
3160
3179
' return;' ,
3161
3180
' }' ,
0 commit comments