From d8f365bfd418af52aeeddc06cc74a4cf1c22f70c Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sun, 17 May 2026 04:17:45 +0900 Subject: [PATCH] test(guard): add merge-conflict guard to prevent unresolved git conflicts in source files Unresolved git merge conflict markers (<<<<<<<, =======, >>>>>>>) in TypeScript source files break parsing and can cause the plugin to fail at runtime or tests to hang with cryptic errors. This guard scans all .ts/.tsx/.json files under src/ and fails the test suite if any conflict markers are found. Closes #debugging-hang-investigation --- src/hooks/shared/merge-conflict-guard.test.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/hooks/shared/merge-conflict-guard.test.ts diff --git a/src/hooks/shared/merge-conflict-guard.test.ts b/src/hooks/shared/merge-conflict-guard.test.ts new file mode 100644 index 000000000..0a66c21df --- /dev/null +++ b/src/hooks/shared/merge-conflict-guard.test.ts @@ -0,0 +1,39 @@ +import { describe, expect, test } from "bun:test" +import { readdirSync, readFileSync } from "fs" +import { join } from "path" + +function* walk(dir: string): Generator { + for (const entry of readdirSync(dir, { withFileTypes: true })) { + const path = join(dir, entry.name) + if (entry.isDirectory()) { + if (entry.name === "node_modules" || entry.name === ".git" || entry.name === "dist") { + continue + } + yield* walk(path) + } else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx") || entry.name.endsWith(".json"))) { + yield path + } + } +} + +function hasConflictMarkers(content: string): boolean { + const lines = content.split("\n") + return lines.some((line) => + line.startsWith("<<<<<<< ") || + line === "=======" || + line.startsWith(">>>>>>> ") + ) +} + +describe("#given source files in src/", () => { + test("#then no file contains unresolved git merge conflict markers", () => { + const conflicts: string[] = [] + for (const path of walk(join(import.meta.dir, "../../../src"))) { + const content = readFileSync(path, "utf-8") + if (hasConflictMarkers(content)) { + conflicts.push(path) + } + } + expect(conflicts).toEqual([]) + }) +})