File tree Expand file tree Collapse file tree 1 file changed +4
-26
lines changed
packages/eslint-plugin/src/rules Expand file tree Collapse file tree 1 file changed +4
-26
lines changed Original file line number Diff line number Diff line change 11import {
2+ ASTUtils ,
23 AST_NODE_TYPES ,
34 TSESLint ,
45 TSESTree ,
@@ -340,31 +341,6 @@ export default util.createRule<Options, MessageIds>({
340341 ) ;
341342 }
342343
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-
368344 /**
369345 * Checks the current context for shadowed variables.
370346 * @param {Scope } scope Fixme
@@ -404,7 +380,9 @@ export default util.createRule<Options, MessageIds>({
404380 }
405381
406382 // 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 ;
408386 if ( ! shadowed ) {
409387 continue ;
410388 }
You can’t perform that action at this time.
0 commit comments