Skip to content

Commit

Permalink
WIP getReferences
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwilsonvu committed Aug 26, 2023
1 parent 7714756 commit bfff83b
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/rules/reactivity/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,21 @@ export default createRule({
): Array<VirtualReference> {
node = ignoreTransparentWrappers(node, "up");
const parsedPathOuter = path != null ? parsePath(path) : null;
const eqCount = parsedPathOuter?.reduce((c, segment) => c + +(segment === '='), 0) ?? 0;
const eqCount = parsedPathOuter?.reduce((c, segment) => c + +(segment === "="), 0) ?? 0;
if (eqCount > 1) {
throw new Error(`'${path}' must have 0 or 1 '=' characters, has ${eqCount}`)
throw new Error(`'${path}' must have 0 or 1 '=' characters, has ${eqCount}`);
}
const hasEq = eqCount === 1;

let declarationScope = hasEq ? null : context.getScope();
const declarationScope = hasEq ? null : context.getScope();

function* recursiveGenerator(node: T.Node, parsedPath: Array<string> | null) {


if (!parsedPath) {
yield VirtualReference(node);
} else if (node.parent?.type === "VariableDeclarator" && node.parent.init === node) {
yield getReferences(node.parent.id);
} else if (node.type === "Identifier") {

}
if (!parsedPath) {
yield VirtualReference(node);
} else if (node.parent?.type === "VariableDeclarator" && node.parent.init === node) {
yield getReferences(node.parent.id);
} else if (node.type === "Identifier") {
}
const { id } = node.parent;
if (id.type === "Identifier") {
const variable = findVariable(context.getScope(), id);
Expand Down Expand Up @@ -173,9 +170,9 @@ export default createRule({
} else {
}
}

return Array.from(recursiveGenerator(node, parsePath(path)));

return Array.from(recursiveGenerator(node, parsePath(path)));
}
}

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

0 comments on commit bfff83b

Please sign in to comment.