vscode-drawio
vscode-drawio copied to clipboard
Code Review suggestion: Refact the if block
In the code
https://github.com/hediet/vscode-drawio/blob/fe9426343bdd75bf981b7e5f7f731c2c46543194/drawio-custom-plugins/src/linkSelectedNodeWithData.ts#L24-L35
my suggestion is to negate the condition and return. This way we can improve readability.
if (cell == null)
return;
const data = getLinkedData(cell);
const label = getLabelTextOfCell(cell);
if (!data && !label.match(/#([a-zA-Z0-9_]+)/)) {
return;
}
sendEvent({ event: "nodeSelected", label, linkedData: data });
evt.consume();
});
https://github.com/hediet/vscode-drawio/issues/342#tasklist-block-f58d4eed-5010-4184-aaf4-9eba6531b67a
Feel free to provide a PR!