@@ -64,7 +64,7 @@ Components.prototype.set = function (node, props) {
6464 return ;
6565 }
6666 const id = this . getId ( currentNode ) ;
67- this . list [ id ] = Object . assign ( { } , this . list [ id ] , props ) ;
67+ this . list [ id ] = { ... this . list [ id ] , ... props } ;
6868} ;
6969
7070/**
@@ -151,17 +151,12 @@ function componentRule(rule, context) {
151151 return false ;
152152 }
153153
154- const returnsJSX =
155- node [ property ] &&
156- node [ property ] . type === 'JSXElement'
157- ;
158- const returnsReactCreateElement =
159- node [ property ] &&
160- node [ property ] . callee &&
161- node [ property ] . callee . property &&
162- node [ property ] . callee . property . name === 'createElement'
163- ;
164-
154+ const returnsJSX = node [ property ]
155+ && node [ property ] . type === 'JSXElement' ;
156+ const returnsReactCreateElement = node [ property ]
157+ && node [ property ] . callee
158+ && node [ property ] . callee . property
159+ && node [ property ] . callee . property . name === 'createElement' ;
165160 return Boolean ( returnsJSX || returnsReactCreateElement ) ;
166161 } ,
167162
@@ -172,9 +167,9 @@ function componentRule(rule, context) {
172167 */
173168 getParentComponent : function ( ) {
174169 return (
175- utils . getParentES6Component ( ) ||
176- utils . getParentES5Component ( ) ||
177- utils . getParentStatelessComponent ( )
170+ utils . getParentES6Component ( )
171+ || utils . getParentES5Component ( )
172+ || utils . getParentStatelessComponent ( )
178173 ) ;
179174 } ,
180175
@@ -184,6 +179,7 @@ function componentRule(rule, context) {
184179 * @returns {ASTNode } component node, null if we are not in a component
185180 */
186181 getParentES5Component : function ( ) {
182+ // eslint-disable-next-line react/destructuring-assignment
187183 let scope = context . getScope ( ) ;
188184 while ( scope ) {
189185 const node = scope . block && scope . block . parent && scope . block . parent . parent ;
@@ -218,6 +214,7 @@ function componentRule(rule, context) {
218214 * @returns {ASTNode } component node, null if we are not in a component
219215 */
220216 getParentStatelessComponent : function ( ) {
217+ // eslint-disable-next-line react/destructuring-assignment
221218 let scope = context . getScope ( ) ;
222219 while ( scope ) {
223220 const node = scope . block ;
@@ -266,7 +263,7 @@ function componentRule(rule, context) {
266263 return null ;
267264 }
268265 let variableInScope ;
269- const variables = context . getScope ( ) . variables ;
266+ const { variables } = context . getScope ( ) ;
270267 for ( i = 0 , j = variables . length ; i < j ; i ++ ) { // eslint-disable-line no-plusplus
271268 if ( variables [ i ] . name === variableName ) {
272269 variableInScope = variables [ i ] ;
@@ -279,12 +276,12 @@ function componentRule(rule, context) {
279276
280277 // Find the variable declaration
281278 let defInScope ;
282- const defs = variableInScope . defs ;
279+ const { defs } = variableInScope ;
283280 for ( i = 0 , j = defs . length ; i < j ; i ++ ) { // eslint-disable-line no-plusplus
284281 if (
285- defs [ i ] . type === 'ClassName' ||
286- defs [ i ] . type === 'FunctionName' ||
287- defs [ i ] . type === 'Variable'
282+ defs [ i ] . type === 'ClassName'
283+ || defs [ i ] . type === 'FunctionName'
284+ || defs [ i ] . type === 'Variable'
288285 ) {
289286 defInScope = defs [ i ] ;
290287 break ;
@@ -392,7 +389,7 @@ function componentRule(rule, context) {
392389
393390 // Update the provided rule instructions to add the component detection
394391 const ruleInstructions = rule ( context , components , utils ) ;
395- const updatedRuleInstructions = Object . assign ( { } , ruleInstructions ) ;
392+ const updatedRuleInstructions = { ... ruleInstructions } ;
396393 Object . keys ( detectionInstructions ) . forEach ( ( instruction ) => {
397394 updatedRuleInstructions [ instruction ] = ( node ) => {
398395 detectionInstructions [ instruction ] ( node ) ;
0 commit comments