import { readFileSync } from "node:fs"; import { describe, expect, it } from "vitest"; // CR-H10 回归守卫:errorCode 只应有一份权威实现(lib/generation/cards), // style 侧两个 hook 不得再各自本地定义 `function errorCode(`,须统一 import。 describe("errorCode 去重(CR-H10)", () => { it.each(["useRefine.ts", "useStyleLearn.ts"])( "%s 不再本地定义 errorCode,且从 generation/cards 引入", (file) => { const src = readFileSync(new URL(`./${file}`, import.meta.url), "utf-8"); expect(src).not.toMatch(/function\s+errorCode\s*\(/); expect(src).toMatch( /import\s*\{[^}]*\berrorCode\b[^}]*\}\s*from\s*["']@\/lib\/generation\/cards["']/, ); }, ); });