Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ async function initialise() {
config.rules[r] = true;
}
} else {
config.rules[r] = true;
if (rule.meta && rule.meta.hasOwnProperty('default')) {
config.rules[r] = rule.meta.default;
} else {
config.rules[r] = true;
}
}
}
console.log("module.exports = "+JSON.stringify(config,null,4))
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ module.exports = {
"no-overlapping-nodes": require("./no-overlapping-nodes"),
"no-unconnected-http-nodes": require("./no-unconnected-http-nodes"),
"no-unnamed-functions": require("./no-unnamed-functions"),
"no-unnamed-links": require("./no-unnamed-links")
"no-unnamed-links": require("./no-unnamed-links"),
"no-cross-links": require("./no-cross-links")
}
64 changes: 64 additions & 0 deletions lib/rules/no-cross-links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
function findCrossTabLinks(flowSet) {
const linkIns = new Map();
const linkOuts = [];
const tabLabel = new Map();

flowSet.flows.forEach((tab) => {
tabLabel.set(tab.id, (tab.config && tab.config.label) || "");
});

flowSet.nodes.forEach((n) => {
if (n.type === "link in") linkIns.set(n.id, n);
if (n.type === "link out") linkOuts.push(n);
});

const results = [];

for (const out of linkOuts) {
const targets = (out.outboundWires || []).flat();

for (const wire of targets) {
const destNode = wire.destinationNode;
if (!destNode) continue;
const inn = linkIns.get(destNode.id);
if (inn) {
if (out.z !== inn.z) {
results.push({
from: out.id,
fromName: out.config.name || "",
fromTab: out.z,
fromTabLabel: tabLabel.get(out.z) || "",
to: inn.id,
toName: inn.config.name || "",
toTab: inn.z,
toTabLabel: tabLabel.get(inn.z) || "",
});
}
}
}
}
return results;
}

module.exports = {
meta: {
type: "problem",
severity: "warn",
docs: { description: "Detect link nodes that cross tabs" },
default: false,
},

create(context) {
return {
start(flowSet) {
const crossTab = findCrossTabLinks(flowSet);
crossTab.forEach((link) => {
context.report({
location: [link.to, link.from],
message: `Cross tab link node found, between flow "${link.toTabLabel}" and flow "${link.fromTabLabel}"`,
});
});
},
};
},
};