Skip to content

Commit 5b85027

Browse files
committed
chore: rework with an early return
1 parent 1710e44 commit 5b85027

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

packages/eslint-plugin-svelte/src/rules/derived-has-same-inputs-outputs.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,24 @@ function findVariableForName(
1212
expectedName: string
1313
): { hasConflict: boolean; variable: Variable | null } {
1414
const scope = getScope(context, node);
15-
let hasConflict = false;
1615
let variable: Variable | null = null;
1716

1817
for (const ref of scope.references) {
1918
if (ref.identifier.name === expectedName) {
20-
hasConflict = true;
21-
break;
19+
return { hasConflict: true, variable: null };
2220
}
2321
}
2422

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;
3729
}
3830
}
3931

40-
return { hasConflict, variable };
32+
return { hasConflict: false, variable };
4133
}
4234

4335
function createFixer(node: TSESTree.Node, variable: Variable | null, name: string) {

0 commit comments

Comments
 (0)