@@ -54,7 +54,7 @@ function getDestructuringAssignmentParent(scope, node) {
5454 ) {
5555 return null ;
5656 }
57- return declaration . defs [ 0 ] . node . init . name ;
57+ return declaration . defs [ 0 ] . node . init ;
5858}
5959
6060const identifierSelector =
@@ -94,17 +94,19 @@ module.exports = {
9494 return ;
9595 }
9696 const name = node . name ;
97- const parentName = getDestructuringAssignmentParent (
97+ const parent = getDestructuringAssignmentParent (
9898 context . getScope ( ) ,
9999 node
100100 ) ;
101+ const parentName = parent ?. name ;
101102 if ( ! isTarget ( nameMap , name ) && ! isTarget ( nameMap , parentName ) ) {
102103 return ;
103104 }
104105
105106 const defs = globalScope . set . get ( name ) ?. defs ;
106107 if ( parentName && isTarget ( nameMap , parentName ) ) {
107- if ( ! defs || defs [ 0 ] . name . name !== 'primordials' ) {
108+ if ( defs ?. [ 0 ] . name . name !== 'primordials' &&
109+ ! reported . has ( parent . range [ 0 ] ) ) {
108110 reported . add ( node . range [ 0 ] ) ;
109111 const into = renameMap . get ( name ) ;
110112 context . report ( {
@@ -147,7 +149,20 @@ module.exports = {
147149 }
148150 } ) ;
149151 }
150- }
152+ } ,
153+ VariableDeclarator ( node ) {
154+ const name = node . init ?. name ;
155+ if ( name !== undefined && isTarget ( nameMap , name ) &&
156+ node . id . type === 'Identifier' &&
157+ ! globalScope . set . get ( name ) ?. defs . length ) {
158+ reported . add ( node . init . range [ 0 ] ) ;
159+ context . report ( {
160+ node,
161+ messageId : 'error' ,
162+ data : { name } ,
163+ } ) ;
164+ }
165+ } ,
151166 } ;
152167 }
153168} ;
0 commit comments