Skip to content

Commit bfff83b

Browse files
committed
WIP getReferences
1 parent 7714756 commit bfff83b

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/rules/reactivity/rule.ts

+12-15
Original file line numberDiff line numberDiff line change
@@ -123,24 +123,21 @@ export default createRule({
123123
): Array<VirtualReference> {
124124
node = ignoreTransparentWrappers(node, "up");
125125
const parsedPathOuter = path != null ? parsePath(path) : null;
126-
const eqCount = parsedPathOuter?.reduce((c, segment) => c + +(segment === '='), 0) ?? 0;
126+
const eqCount = parsedPathOuter?.reduce((c, segment) => c + +(segment === "="), 0) ?? 0;
127127
if (eqCount > 1) {
128-
throw new Error(`'${path}' must have 0 or 1 '=' characters, has ${eqCount}`)
128+
throw new Error(`'${path}' must have 0 or 1 '=' characters, has ${eqCount}`);
129129
}
130130
const hasEq = eqCount === 1;
131131

132-
let declarationScope = hasEq ? null : context.getScope();
132+
const declarationScope = hasEq ? null : context.getScope();
133133

134134
function* recursiveGenerator(node: T.Node, parsedPath: Array<string> | null) {
135-
136-
137-
if (!parsedPath) {
138-
yield VirtualReference(node);
139-
} else if (node.parent?.type === "VariableDeclarator" && node.parent.init === node) {
140-
yield getReferences(node.parent.id);
141-
} else if (node.type === "Identifier") {
142-
143-
}
135+
if (!parsedPath) {
136+
yield VirtualReference(node);
137+
} else if (node.parent?.type === "VariableDeclarator" && node.parent.init === node) {
138+
yield getReferences(node.parent.id);
139+
} else if (node.type === "Identifier") {
140+
}
144141
const { id } = node.parent;
145142
if (id.type === "Identifier") {
146143
const variable = findVariable(context.getScope(), id);
@@ -173,9 +170,9 @@ export default createRule({
173170
} else {
174171
}
175172
}
176-
177-
178-
return Array.from(recursiveGenerator(node, parsePath(path)));
173+
174+
return Array.from(recursiveGenerator(node, parsePath(path)));
175+
}
179176
}
180177

181178
function distributeReferences(root: ReactivityScope, references: Array<VirtualReference>) {

0 commit comments

Comments
 (0)