/** * 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}`; }