We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
SourceCode#getAncestors
1 parent 4283fd8 commit 93e9ef6Copy full SHA for 93e9ef6
apps/oxlint/src-js/plugins/source_code.ts
@@ -520,12 +520,11 @@ export type SourceCode = typeof SOURCE_CODE;
520
function getAncestors(node: Node): Node[] {
521
const ancestors = [];
522
523
- for (
524
- let ancestor = (node as unknown as { parent: Node }).parent;
525
- ancestor;
526
- ancestor = (ancestor as unknown as { parent: Node }).parent
527
- ) {
528
- ancestors.push(ancestor);
+ while (true) {
+ // @ts-expect-error `parent` property should be present on `Node` type
+ node = node.parent;
+ if (node === null) break;
+ ancestors.push(node);
529
}
530
531
return ancestors.reverse();
0 commit comments