From 9a0c98ac8b60b5d3341f05eccc9a472810bc82b8 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Mon, 12 Jul 2021 21:08:04 -0300 Subject: [PATCH] 17782: removes linter warnings for cwl-svg code. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- src/lib/cwl-svg/graph/edge.ts | 8 ++++---- src/lib/cwl-svg/graph/workflow.ts | 10 ---------- src/lib/cwl-svg/plugins/deletion/deletion.ts | 2 +- src/lib/cwl-svg/plugins/edge-hover/edge-hover.ts | 8 ++++---- src/lib/cwl-svg/plugins/port-drag/port-drag.ts | 2 +- src/lib/cwl-svg/plugins/selection/selection.ts | 4 ++-- src/lib/cwl-svg/utils/dom-events.ts | 1 + src/lib/cwl-svg/utils/geometry.ts | 2 +- src/lib/cwl-svg/utils/html-utils.ts | 2 +- 9 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/lib/cwl-svg/graph/edge.ts b/src/lib/cwl-svg/graph/edge.ts index 74fb0afc..334a5148 100644 --- a/src/lib/cwl-svg/graph/edge.ts +++ b/src/lib/cwl-svg/graph/edge.ts @@ -10,8 +10,8 @@ export class Edge { return ""; } - const [sourceSide, sourceStepId, sourcePort] = edge.source.id.split("/"); - const [destSide, destStepId, destPort] = edge.destination.id.split("/"); + const [, sourceStepId, sourcePort] = edge.source.id.split("/"); + const [, destStepId, destPort] = edge.destination.id.split("/"); const sourceVertex = containerNode.querySelector(`.node[data-id="${sourceStepId}"] .output-port[data-port-id="${sourcePort}"] .io-port`) as SVGGElement; const destVertex = containerNode.querySelector(`.node[data-id="${destStepId}"] .input-port[data-port-id="${destPort}"] .io-port`) as SVGGElement; @@ -65,8 +65,8 @@ export class Edge { const ns = "http://www.w3.org/2000/svg"; const edge = document.createElementNS(ns, "g"); - const [sourceSide, sourceStepId, sourcePort] = (connectionIDs.source || "//").split("/"); - const [destSide, destStepId, destPort] = (connectionIDs.destination || "//").split("/"); + const [, sourceStepId, sourcePort] = (connectionIDs.source || "//").split("/"); + const [, destStepId, destPort] = (connectionIDs.destination || "//").split("/"); edge.classList.add("edge"); if (sourceStepId) { diff --git a/src/lib/cwl-svg/graph/workflow.ts b/src/lib/cwl-svg/graph/workflow.ts index cb6f2281..f0cd1c4e 100644 --- a/src/lib/cwl-svg/graph/workflow.ts +++ b/src/lib/cwl-svg/graph/workflow.ts @@ -181,21 +181,11 @@ export class Workflow { * If there is a missing sbg:x or sbg:y property on any node model, * graph should be arranged to avoid random placement. */ - let arrangeNecessary = false; - let nodeTemplate = ""; for (const node of nodes) { const patched = GraphNode.patchModelPorts(node); - const missingX = isNaN(parseInt(patched.customProps["sbg:x"], 10)); - const missingY = isNaN(parseInt(patched.customProps["sbg:y"], 10)); - - if (missingX || missingY) { - arrangeNecessary = true; - } - nodeTemplate += GraphNode.makeTemplate(patched); - } this.workflow.innerHTML += nodeTemplate; diff --git a/src/lib/cwl-svg/plugins/deletion/deletion.ts b/src/lib/cwl-svg/plugins/deletion/deletion.ts index f3e6498f..3af75434 100644 --- a/src/lib/cwl-svg/plugins/deletion/deletion.ts +++ b/src/lib/cwl-svg/plugins/deletion/deletion.ts @@ -29,7 +29,7 @@ export class DeletionPlugin extends PluginBase { } private onDelete(ev: KeyboardEvent) { - if (ev.which !== 8 && ev.which !== 46 || !(ev.target instanceof SVGElement)) { + if ((ev.which !== 8 && ev.which !== 46) || !(ev.target instanceof SVGElement)) { return; } diff --git a/src/lib/cwl-svg/plugins/edge-hover/edge-hover.ts b/src/lib/cwl-svg/plugins/edge-hover/edge-hover.ts index 01f1ad54..9d3b423b 100644 --- a/src/lib/cwl-svg/plugins/edge-hover/edge-hover.ts +++ b/src/lib/cwl-svg/plugins/edge-hover/edge-hover.ts @@ -36,17 +36,17 @@ export class SVGEdgeHoverPlugin extends PluginBase { const target = ev.target as SVGGElement; let tipEl: SVGGElement; - const onMouseMove = ((ev: MouseEvent) => { + const onMouseMove = (ev: MouseEvent) => { const coords = this.workflow.transformScreenCTMtoCanvas(ev.clientX, ev.clientY); tipEl.setAttribute("x", String(coords.x)); tipEl.setAttribute("y", String(coords.y - 16)); - }).bind(this); + }; - const onMouseLeave = ((ev: MouseEvent) => { + const onMouseLeave = (ev: MouseEvent) => { tipEl.remove(); target.removeEventListener("mousemove", onMouseMove); target.removeEventListener("mouseleave", onMouseLeave) - }).bind(this); + }; this.modelListener = this.workflow.model.on("connection.remove", (source, destination) => { if (!tipEl) return; diff --git a/src/lib/cwl-svg/plugins/port-drag/port-drag.ts b/src/lib/cwl-svg/plugins/port-drag/port-drag.ts index 10f30e07..e5d11e3a 100644 --- a/src/lib/cwl-svg/plugins/port-drag/port-drag.ts +++ b/src/lib/cwl-svg/plugins/port-drag/port-drag.ts @@ -265,7 +265,7 @@ export class SVGPortDragPlugin extends PluginBase { private updateEdge(fromX: number, fromY: number, toX: number, toY: number): void { const subEdges = this.edgeGroup!.children as HTMLCollectionOf; - for (let subEdge of subEdges) { + for (let subEdge of subEdges as any) { const path = Workflow.makeConnectionPath( fromX, diff --git a/src/lib/cwl-svg/plugins/selection/selection.ts b/src/lib/cwl-svg/plugins/selection/selection.ts index a4e7a312..443e60ad 100644 --- a/src/lib/cwl-svg/plugins/selection/selection.ts +++ b/src/lib/cwl-svg/plugins/selection/selection.ts @@ -146,12 +146,12 @@ export class SelectionPlugin extends PluginBase { let element: SVGElement | undefined; - if (element = this.workflow.findParent(target, "node")) { + if ((element = this.workflow.findParent(target, "node"))) { this.selectNode(element); this.selection.set(element.getAttribute("data-connection-id")!, "node"); this.emitChange(element); - } else if (element = this.workflow.findParent(target, "edge")) { + } else if ((element = this.workflow.findParent(target, "edge"))) { this.selectEdge(element); const cid = [ element.getAttribute("data-source-connection"), diff --git a/src/lib/cwl-svg/utils/dom-events.ts b/src/lib/cwl-svg/utils/dom-events.ts index 4f8132a0..d7ae43f1 100644 --- a/src/lib/cwl-svg/utils/dom-events.ts +++ b/src/lib/cwl-svg/utils/dom-events.ts @@ -31,6 +31,7 @@ export class DomEvents { const selected = Array.from(this.root.querySelectorAll(selector)); target = ev.target as HTMLElement; while (target) { + // eslint-disable-next-line if (selected.find(el => el === target)) { break; } diff --git a/src/lib/cwl-svg/utils/geometry.ts b/src/lib/cwl-svg/utils/geometry.ts index 11b066d9..348a7e20 100644 --- a/src/lib/cwl-svg/utils/geometry.ts +++ b/src/lib/cwl-svg/utils/geometry.ts @@ -16,7 +16,7 @@ export class Geometry { } else { // node still has parent elements const {e, f} = node.transform.baseVal.getItem(0).matrix; - return getPosition(node.parentNode, e + addE, f + addF); + return getPosition(node.parentNode as SVGGElement, e + addE, f + addF); } }; diff --git a/src/lib/cwl-svg/utils/html-utils.ts b/src/lib/cwl-svg/utils/html-utils.ts index 07b5405d..b7bad2b3 100644 --- a/src/lib/cwl-svg/utils/html-utils.ts +++ b/src/lib/cwl-svg/utils/html-utils.ts @@ -10,6 +10,6 @@ export class HtmlUtils { }; public static escapeHTML(source: string): string { - return String(source).replace(/[&<>"'\/]/g, s => HtmlUtils.entityMap[s]); + return String(source).replace(/[&<>"'/]/g, s => HtmlUtils.entityMap[s]); } } -- 2.30.2