@@ -124,15 +124,18 @@ module.exports = {
124
124
}
125
125
}
126
126
127
- function reportErrorIfClassPropertyCasingTypo ( node , propertyName ) {
127
+ function reportErrorIfPropertyCasingTypo ( node , propertyName , isClassProperty ) {
128
128
if ( propertyName === 'propTypes' || propertyName === 'contextTypes' || propertyName === 'childContextTypes' ) {
129
129
checkValidPropObject ( node ) ;
130
130
}
131
131
STATIC_CLASS_PROPERTIES . forEach ( CLASS_PROP => {
132
132
if ( propertyName && CLASS_PROP . toLowerCase ( ) === propertyName . toLowerCase ( ) && CLASS_PROP !== propertyName ) {
133
+ const message = isClassProperty
134
+ ? 'Typo in static class property declaration'
135
+ : 'Typo in property declaration' ;
133
136
context . report ( {
134
137
node : node ,
135
- message : 'Typo in static class property declaration'
138
+ message : message
136
139
} ) ;
137
140
}
138
141
} ) ;
@@ -175,7 +178,7 @@ module.exports = {
175
178
176
179
const tokens = context . getFirstTokens ( node , 2 ) ;
177
180
const propertyName = tokens [ 1 ] . value ;
178
- reportErrorIfClassPropertyCasingTypo ( node . value , propertyName ) ;
181
+ reportErrorIfPropertyCasingTypo ( node . value , propertyName , true ) ;
179
182
} ,
180
183
181
184
MemberExpression : function ( node ) {
@@ -195,16 +198,29 @@ module.exports = {
195
198
( utils . isES6Component ( relatedComponent . node ) || utils . isReturningJSX ( relatedComponent . node ) ) &&
196
199
( node . parent && node . parent . type === 'AssignmentExpression' && node . parent . right )
197
200
) {
198
- reportErrorIfClassPropertyCasingTypo ( node . parent . right , propertyName ) ;
201
+ reportErrorIfPropertyCasingTypo ( node . parent . right , propertyName , true ) ;
199
202
}
200
203
} ,
201
204
202
- MethodDefinition : function ( node ) {
205
+ MethodDefinition : function ( node ) {
203
206
if ( ! utils . isES6Component ( node . parent . parent ) ) {
204
207
return ;
205
208
}
206
209
207
210
reportErrorIfLifecycleMethodCasingTypo ( node ) ;
211
+ } ,
212
+
213
+ ObjectExpression : function ( node ) {
214
+ const component = utils . isES5Component ( node ) && components . get ( node ) ;
215
+
216
+ if ( ! component ) {
217
+ return ;
218
+ }
219
+
220
+ node . properties . forEach ( property => {
221
+ reportErrorIfPropertyCasingTypo ( property . value , property . key . name , false ) ;
222
+ reportErrorIfLifecycleMethodCasingTypo ( property ) ;
223
+ } ) ;
208
224
}
209
225
} ;
210
226
} )
0 commit comments