这个检查器承诺找出从领域代码到适配器代码的每条依赖路径,请找出缺陷。
JavaScript
function forbiddenDependencies(graph, domainModules, adapterModules) {
const violations = [];
for (const domain of domainModules) {
for (const dependency of graph.get(domain) ?? []) {
if (adapterModules.has(dependency)) {
violations.push(`${domain} -> ${dependency}`);
}
}
}
return violations;
}
const graph = new Map([
['order', ['shared-money']],
['shared-money', ['postgres-decimal']],
]);