@@ -124,15 +124,18 @@ module.exports = {
124124 }
125125 }
126126
127- function reportErrorIfClassPropertyCasingTypo ( node , propertyName ) {
127+ function reportErrorIfPropertyCasingTypo ( node , propertyName , isClassProperty ) {
128128 if ( propertyName === 'propTypes' || propertyName === 'contextTypes' || propertyName === 'childContextTypes' ) {
129129 checkValidPropObject ( node ) ;
130130 }
131131 STATIC_CLASS_PROPERTIES . forEach ( CLASS_PROP => {
132132 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' ;
133136 context . report ( {
134137 node : node ,
135- message : 'Typo in static class property declaration'
138+ message : message
136139 } ) ;
137140 }
138141 } ) ;
@@ -175,7 +178,7 @@ module.exports = {
175178
176179 const tokens = context . getFirstTokens ( node , 2 ) ;
177180 const propertyName = tokens [ 1 ] . value ;
178- reportErrorIfClassPropertyCasingTypo ( node . value , propertyName ) ;
181+ reportErrorIfPropertyCasingTypo ( node . value , propertyName , true ) ;
179182 } ,
180183
181184 MemberExpression : function ( node ) {
@@ -195,16 +198,29 @@ module.exports = {
195198 ( utils . isES6Component ( relatedComponent . node ) || utils . isReturningJSX ( relatedComponent . node ) ) &&
196199 ( node . parent && node . parent . type === 'AssignmentExpression' && node . parent . right )
197200 ) {
198- reportErrorIfClassPropertyCasingTypo ( node . parent . right , propertyName ) ;
201+ reportErrorIfPropertyCasingTypo ( node . parent . right , propertyName , true ) ;
199202 }
200203 } ,
201204
202- MethodDefinition : function ( node ) {
205+ MethodDefinition : function ( node ) {
203206 if ( ! utils . isES6Component ( node . parent . parent ) ) {
204207 return ;
205208 }
206209
207210 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+ } ) ;
208224 }
209225 } ;
210226 } )
0 commit comments