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>
18 lines
853 B
TypeScript
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}`;
|
|
}
|