@@ -33,7 +33,7 @@ module.exports = {
3333 } ]
3434 } ,
3535
36- create : Components . detect ( function ( context , components , utils ) {
36+ create : Components . detect ( ( context , components , utils ) => {
3737 const configuration = context . options [ 0 ] || { } ;
3838 const allowRequiredDefaults = configuration . allowRequiredDefaults || false ;
3939 const propWrapperFunctions = new Set ( context . settings . propWrapperFunctions || [ ] ) ;
@@ -91,7 +91,7 @@ module.exports = {
9191 * @returns {ASTNode|null } Return null if the variable could not be found, ASTNode otherwise.
9292 */
9393 function findVariableByName ( name ) {
94- const variable = variableUtil . variablesInScope ( context ) . find ( ( item ) => item . name === name ) ;
94+ const variable = variableUtil . variablesInScope ( context ) . find ( item => item . name === name ) ;
9595
9696 if ( ! variable || ! variable . defs [ 0 ] || ! variable . defs [ 0 ] . node ) {
9797 return null ;
@@ -139,7 +139,7 @@ module.exports = {
139139
140140 function resolveUnionTypeAnnotation ( node ) {
141141 // Go through all the union and resolve any generic types.
142- return node . types . map ( function ( annotation ) {
142+ return node . types . map ( annotation => {
143143 if ( annotation . type === 'GenericTypeAnnotation' ) {
144144 return resolveGenericTypeAnnotation ( annotation ) ;
145145 }
@@ -154,17 +154,13 @@ module.exports = {
154154 * @returns {Object[] } Array of PropType object representations, to be consumed by `addPropTypesToComponent`.
155155 */
156156 function getPropTypesFromObjectExpression ( objectExpression ) {
157- const props = objectExpression . properties . filter ( function ( property ) {
158- return property . type !== 'ExperimentalSpreadProperty' ;
159- } ) ;
157+ const props = objectExpression . properties . filter ( property => property . type !== 'ExperimentalSpreadProperty' ) ;
160158
161- return props . map ( function ( property ) {
162- return {
163- name : property . key . name ,
164- isRequired : isRequiredPropType ( property . value ) ,
165- node : property
166- } ;
167- } ) ;
159+ return props . map ( property => ( {
160+ name : property . key . name ,
161+ isRequired : isRequiredPropType ( property . value ) ,
162+ node : property
163+ } ) ) ;
168164 }
169165
170166 /**
@@ -188,7 +184,7 @@ module.exports = {
188184
189185 case 'UnionTypeAnnotation' :
190186 const union = resolveUnionTypeAnnotation ( node . typeAnnotation ) ;
191- properties = union . reduce ( function ( acc , curr ) {
187+ properties = union . reduce ( ( acc , curr ) => {
192188 if ( ! curr ) {
193189 return acc ;
194190 }
@@ -206,11 +202,9 @@ module.exports = {
206202 break ;
207203 }
208204
209- const props = properties . filter ( function ( property ) {
210- return property . type === 'ObjectTypeProperty' ;
211- } ) ;
205+ const props = properties . filter ( property => property . type === 'ObjectTypeProperty' ) ;
212206
213- return props . map ( function ( property ) {
207+ return props . map ( property => {
214208 // the `key` property is not present in ObjectTypeProperty nodes, so we need to get the key name manually.
215209 const tokens = context . getFirstTokens ( property , 1 ) ;
216210 const name = tokens [ 0 ] . value ;
@@ -237,12 +231,10 @@ module.exports = {
237231 return 'unresolved' ;
238232 }
239233
240- return objectExpression . properties . map ( function ( defaultProp ) {
241- return {
242- name : defaultProp . key . name ,
243- node : defaultProp
244- } ;
245- } ) ;
234+ return objectExpression . properties . map ( defaultProp => ( {
235+ name : defaultProp . key . name ,
236+ node : defaultProp
237+ } ) ) ;
246238 }
247239
248240 /**
@@ -348,7 +340,7 @@ module.exports = {
348340 return ;
349341 }
350342
351- defaultProps . forEach ( function ( defaultProp ) {
343+ defaultProps . forEach ( defaultProp => {
352344 const prop = propFromName ( propTypes , defaultProp . name ) ;
353345
354346 if ( prop && ( allowRequiredDefaults || ! prop . isRequired ) ) {
@@ -567,7 +559,7 @@ module.exports = {
567559 }
568560
569561 // Search for the proptypes declaration
570- node . properties . forEach ( function ( property ) {
562+ node . properties . forEach ( property => {
571563 if ( property . type === 'ExperimentalSpreadProperty' ) {
572564 return ;
573565 }
0 commit comments