File tree 1 file changed +4
-26
lines changed
packages/eslint-plugin/src/rules
1 file changed +4
-26
lines changed Original file line number Diff line number Diff line change 1
1
import {
2
+ ASTUtils ,
2
3
AST_NODE_TYPES ,
3
4
TSESLint ,
4
5
TSESTree ,
@@ -340,31 +341,6 @@ export default util.createRule<Options, MessageIds>({
340
341
) ;
341
342
}
342
343
343
- /**
344
- * Finds the variable by a given name in a given scope and its upper scopes.
345
- * @param initScope A scope to start find.
346
- * @param name A variable name to find.
347
- * @returns A found variable or `null`.
348
- */
349
- function getVariableByName (
350
- initScope : TSESLint . Scope . Scope | null ,
351
- name : string ,
352
- ) : TSESLint . Scope . Variable | null {
353
- let scope = initScope ;
354
-
355
- while ( scope ) {
356
- const variable = scope . set . get ( name ) ;
357
-
358
- if ( variable ) {
359
- return variable ;
360
- }
361
-
362
- scope = scope . upper ;
363
- }
364
-
365
- return null ;
366
- }
367
-
368
344
/**
369
345
* Checks the current context for shadowed variables.
370
346
* @param {Scope } scope Fixme
@@ -404,7 +380,9 @@ export default util.createRule<Options, MessageIds>({
404
380
}
405
381
406
382
// Gets shadowed variable.
407
- const shadowed = getVariableByName ( scope . upper , variable . name ) ;
383
+ const shadowed = scope . upper
384
+ ? ASTUtils . findVariable ( scope . upper , variable . name )
385
+ : null ;
408
386
if ( ! shadowed ) {
409
387
continue ;
410
388
}
You can’t perform that action at this time.
0 commit comments