mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
fix: typecheck hook false positives, add 11 session-manager tests
- Fix post-edit-typecheck.js error filtering: use relative/absolute path matching instead of basename, preventing false positives when multiple files share the same name (e.g., src/utils.ts vs tests/utils.ts) - Add writeSessionContent tests (create, overwrite, invalid path) - Add appendSessionContent test (append to existing file) - Add deleteSession tests (delete existing, non-existent) - Add sessionExists tests (file, non-existent, directory) - Add getSessionStats empty content edge case - Add post-edit-typecheck stdout passthrough test - Total: 391 → 402 tests, all passing
This commit is contained in:
@@ -59,13 +59,21 @@ process.stdin.on("end", () => {
|
||||
} catch (err) {
|
||||
// tsc exits non-zero when there are errors — filter to edited file
|
||||
const output = (err.stdout || "") + (err.stderr || "");
|
||||
// Compute paths that uniquely identify the edited file.
|
||||
// tsc output uses paths relative to its cwd (the tsconfig dir),
|
||||
// so check for the relative path, absolute path, and original path.
|
||||
// Avoid bare basename matching — it causes false positives when
|
||||
// multiple files share the same name (e.g., src/utils.ts vs tests/utils.ts).
|
||||
const relPath = path.relative(dir, resolvedPath);
|
||||
const candidates = new Set([filePath, resolvedPath, relPath]);
|
||||
const relevantLines = output
|
||||
.split("\n")
|
||||
.filter(
|
||||
(line) =>
|
||||
line.includes(filePath) ||
|
||||
line.includes(path.basename(filePath)),
|
||||
)
|
||||
.filter((line) => {
|
||||
for (const candidate of candidates) {
|
||||
if (line.includes(candidate)) return true;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.slice(0, 10);
|
||||
|
||||
if (relevantLines.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user