@@ -356,7 +356,9 @@ module.exports = {
356356 const ignoreReadBeforeAssign = options . ignoreReadBeforeAssign === true ;
357357 const variables = [ ] ;
358358 let reportCount = 0 ;
359- let name = "" ;
359+ let checkedId = null ;
360+ let checkedName = "" ;
361+
360362
361363 /**
362364 * Reports given identifier nodes if all of the nodes should be declared
@@ -387,25 +389,30 @@ module.exports = {
387389 /*
388390 * First we check the declaration type and then depending on
389391 * if the type is a "VariableDeclarator" or its an "ObjectPattern"
390- * we compare the name from the first identifier, if the names are different
391- * we assign the new name and reset the count of reportCount and nodeCount in
392+ * we compare the name and id from the first identifier, if the names are different
393+ * we assign the new name, id and reset the count of reportCount and nodeCount in
392394 * order to check each block for the number of reported errors and base our fix
393395 * based on comparing nodes.length and nodesToReport.length.
394396 */
395397
396398 if ( firstDecParent . type === "VariableDeclarator" ) {
397399
398- if ( firstDecParent . id . name !== name ) {
399- name = firstDecParent . id . name ;
400+ if ( firstDecParent . id . name !== checkedName ) {
401+ checkedName = firstDecParent . id . name ;
400402 reportCount = 0 ;
401403 }
402404
403405 if ( firstDecParent . id . type === "ObjectPattern" ) {
404- if ( firstDecParent . init . name !== name ) {
405- name = firstDecParent . init . name ;
406+ if ( firstDecParent . init . name !== checkedName ) {
407+ checkedName = firstDecParent . init . name ;
406408 reportCount = 0 ;
407409 }
408410 }
411+
412+ if ( firstDecParent . id !== checkedId ) {
413+ checkedId = firstDecParent . id ;
414+ reportCount = 0 ;
415+ }
409416 }
410417 }
411418 }
0 commit comments