File tree Expand file tree Collapse file tree 1 file changed +8
-16
lines changed
packages/eslint-plugin-svelte/src/rules Expand file tree Collapse file tree 1 file changed +8
-16
lines changed Original file line number Diff line number Diff line change @@ -12,32 +12,24 @@ function findVariableForName(
12
12
expectedName : string
13
13
) : { hasConflict : boolean ; variable : Variable | null } {
14
14
const scope = getScope ( context , node ) ;
15
- let hasConflict = false ;
16
15
let variable : Variable | null = null ;
17
16
18
17
for ( const ref of scope . references ) {
19
18
if ( ref . identifier . name === expectedName ) {
20
- hasConflict = true ;
21
- break ;
19
+ return { hasConflict : true , variable : null } ;
22
20
}
23
21
}
24
22
25
- if ( ! hasConflict ) {
26
- for ( const v of scope . variables ) {
27
- if ( hasConflict && variable ) {
28
- break ;
29
- }
30
- if ( v . name === expectedName ) {
31
- hasConflict = true ;
32
- continue ;
33
- }
34
- if ( v . name === name ) {
35
- variable = v ;
36
- }
23
+ for ( const v of scope . variables ) {
24
+ if ( v . name === expectedName ) {
25
+ return { hasConflict : true , variable : null } ;
26
+ }
27
+ if ( v . name === name ) {
28
+ variable = v ;
37
29
}
38
30
}
39
31
40
- return { hasConflict, variable } ;
32
+ return { hasConflict : false , variable } ;
41
33
}
42
34
43
35
function createFixer ( node : TSESTree . Node , variable : Variable | null , name : string ) {
You can’t perform that action at this time.
0 commit comments