refactor(mobile): remove unused file tree walkers (#10003)

This commit is contained in:
Julius Marminge authored and GitHub committed 2026-09-05 00:26:51 -07:00
1 parent 393d1ffc9e
commit 8d48a3134f
2 files changed
+1 -34

No files matched your search

@@ -1,13 +1,7 @@
import { describe, expect, it } from "vite-plus/test";
import type { ProjectEntry } from "@t3tools/contracts";
import {
buildFileTree,
countFileNodes,
defaultExpandedTreePaths,
firstFilePath,
flattenFileTree,
} from "./fileTree";
import { buildFileTree, defaultExpandedTreePaths, flattenFileTree } from "./fileTree";
const entries = [
{ kind: "file", path: "README.md" },
@@ -30,8 +24,6 @@ describe("mobile file tree helpers", () => {
"directory:src/components",
"file:src/index.ts",
]);
expect(countFileNodes(tree)).toBe(4);
expect(firstFilePath(tree)).toBe("src/components/App.tsx");
});
it("flattens expanded directories and hides collapsed descendants", () => {
@@ -117,18 +117,6 @@ export function buildFileTree(entries: ReadonlyArray<ProjectEntry>): ReadonlyArr
return [...root.children.values()].sort(compareNodes).map(freezeNode);
}
export function countFileNodes(nodes: ReadonlyArray<FileTreeNode>): number {
let count = 0;
for (const node of nodes) {
if (node.kind === "file") {
count += 1;
} else {
count += countFileNodes(node.children);
}
}
return count;
}
export function defaultExpandedTreePaths(nodes: ReadonlyArray<FileTreeNode>): ReadonlySet<string> {
const expanded = new Set<string>();
for (const node of nodes) {
@@ -205,16 +193,3 @@ export function flattenFileTree(input: {
}
return output;
}
export function firstFilePath(nodes: ReadonlyArray<FileTreeNode>): string | null {
for (const node of nodes) {
if (node.kind === "file") {
return node.path;
}
const child = firstFilePath(node.children);
if (child !== null) {
return child;
}
}
return null;
}