@@ -96,9 +96,9 @@ export default createEslintRule<Options, MessageId>({
96
96
97
97
let selector : Selector
98
98
99
- let dependencies : string [ ] = [ ]
99
+ let dependencies : string [ ] = extractDependencies ( declaration . id )
100
100
if ( declaration . init ) {
101
- dependencies = extractDependencies ( declaration . init )
101
+ dependencies . push ( ... extractDependencies ( declaration . init ) )
102
102
selector = 'initialized'
103
103
} else {
104
104
selector = 'uninitialized'
@@ -246,37 +246,37 @@ function extractDependencies(init: TSESTree.Expression): string[] {
246
246
}
247
247
248
248
if ( nodeValue . type === 'Property' ) {
249
- traverseNode ( nodeValue . key )
250
- traverseNode ( nodeValue . value )
249
+ checkNode ( nodeValue . key )
250
+ checkNode ( nodeValue . value )
251
251
}
252
252
253
253
if ( nodeValue . type === 'ConditionalExpression' ) {
254
- traverseNode ( nodeValue . test )
255
- traverseNode ( nodeValue . consequent )
256
- traverseNode ( nodeValue . alternate )
254
+ checkNode ( nodeValue . test )
255
+ checkNode ( nodeValue . consequent )
256
+ checkNode ( nodeValue . alternate )
257
257
}
258
258
259
259
if (
260
260
'expression' in nodeValue &&
261
261
typeof nodeValue . expression !== 'boolean'
262
262
) {
263
- traverseNode ( nodeValue . expression )
263
+ checkNode ( nodeValue . expression )
264
264
}
265
265
266
266
if ( 'object' in nodeValue ) {
267
- traverseNode ( nodeValue . object )
267
+ checkNode ( nodeValue . object )
268
268
}
269
269
270
270
if ( 'callee' in nodeValue ) {
271
- traverseNode ( nodeValue . callee )
271
+ checkNode ( nodeValue . callee )
272
272
}
273
273
274
274
if ( 'left' in nodeValue ) {
275
- traverseNode ( nodeValue . left )
275
+ checkNode ( nodeValue . left )
276
276
}
277
277
278
278
if ( 'right' in nodeValue ) {
279
- traverseNode ( nodeValue . right as TSESTree . Node )
279
+ checkNode ( nodeValue . right as TSESTree . Node )
280
280
}
281
281
282
282
if ( 'elements' in nodeValue ) {
@@ -285,37 +285,33 @@ function extractDependencies(init: TSESTree.Expression): string[] {
285
285
)
286
286
287
287
for ( let element of elements ) {
288
- traverseNode ( element )
288
+ checkNode ( element )
289
289
}
290
290
}
291
291
292
292
if ( 'argument' in nodeValue && nodeValue . argument ) {
293
- traverseNode ( nodeValue . argument )
293
+ checkNode ( nodeValue . argument )
294
294
}
295
295
296
296
if ( 'arguments' in nodeValue ) {
297
297
for ( let argument of nodeValue . arguments ) {
298
- traverseNode ( argument )
298
+ checkNode ( argument )
299
299
}
300
300
}
301
301
302
302
if ( 'properties' in nodeValue ) {
303
303
for ( let property of nodeValue . properties ) {
304
- traverseNode ( property )
304
+ checkNode ( property )
305
305
}
306
306
}
307
307
308
308
if ( 'expressions' in nodeValue ) {
309
309
for ( let nodeExpression of nodeValue . expressions ) {
310
- traverseNode ( nodeExpression )
310
+ checkNode ( nodeExpression )
311
311
}
312
312
}
313
313
}
314
314
315
- function traverseNode ( nodeValue : TSESTree . Node ) : void {
316
- checkNode ( nodeValue )
317
- }
318
-
319
- traverseNode ( init )
315
+ checkNode ( init )
320
316
return dependencies
321
317
}
0 commit comments