Files
clean-architecture-frontend…/scripts/lib/architecture-violation-message.ts
T
DongHyeonkaandClaude Opus 5.5 b0f7944b41 fix(architecture): print why an import is forbidden and where to go (12-11)
Graph violations printed only the rule name and file pair, and ESLint only the
pattern. The graph now prints the import specifier and the rule's comment,
every rule has one, and ESLint pattern groups carry a message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 22:49:32 +09:00

18 lines
853 B
TypeScript

/**
* 12-11. One violation line names the rule, the edge and the import specifier
* as written, then the rule's `comment` from .dependency-cruiser.json: why the
* edge is forbidden and where the code should go instead.
*/
export function formatArchitectureViolation(
violation: Readonly<{ rule: string; source: string; target: string; cycle?: readonly string[] }>,
specifiers: readonly string[],
comment: string | undefined,
): string {
const imports = specifiers.length > 0
? ` (import ${specifiers.map((specifier) => JSON.stringify(specifier)).join(", ")})`
: "";
const cycle = violation.cycle ? ` (cycle group: ${violation.cycle.join(", ")})` : "";
const why = comment ? ` why: ${comment}\n` : "";
return `Architecture violation [${violation.rule}]: ${violation.source} -> ${violation.target}${imports}${cycle}\n${why}`;
}