Skip to content

Commit

Permalink
Fix lint on sub-expression example tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eyelidlessness committed Mar 12, 2024
1 parent 1154b74 commit 4b0c15d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/tree-sitter-xpath/e2e/sub-expression-queries.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import Parser from 'web-tree-sitter';
import { resolve as resolvePath } from 'node:path';
import Parser from 'web-tree-sitter';

const { describe } = test;
const it = test;
Expand Down Expand Up @@ -2387,10 +2387,18 @@ describe('Parsing subexpressions', () => {
const parsed = parser.parse(expression);
const visited = new Set<number>();

// Workaround: `SyntaxNode.id` was removed from the `web-tree-sitter`
// types in a recent release. It's unclear if that was a mistake, but we
// likely won't maintain these tests or logic that requires this id
// indefinitely anyway.
const getNodeId = (node: Parser.SyntaxNode): number => {
return node.walk().nodeId;
};

const allCaptures = pathExpressionsQuery.captures(parsed.rootNode);
const captures = allCaptures.filter((capture) => {
const { node } = capture;
const { id } = node;
const id = getNodeId(node);

if (visited.has(id)) {
return false;
Expand All @@ -2403,7 +2411,7 @@ describe('Parsing subexpressions', () => {
node.parent!
);

if (potentiallyVisited.some((ancestor) => visited.has(ancestor.id))) {
if (potentiallyVisited.some((ancestor) => visited.has(getNodeId(ancestor)))) {
return false;
}

Expand Down

0 comments on commit 4b0c15d

Please sign in to comment.