17782: removes linter warnings for cwl-svg code.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Tue, 13 Jul 2021 00:08:04 +0000 (21:08 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Tue, 13 Jul 2021 00:08:04 +0000 (21:08 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

src/lib/cwl-svg/graph/edge.ts
src/lib/cwl-svg/graph/workflow.ts
src/lib/cwl-svg/plugins/deletion/deletion.ts
src/lib/cwl-svg/plugins/edge-hover/edge-hover.ts
src/lib/cwl-svg/plugins/port-drag/port-drag.ts
src/lib/cwl-svg/plugins/selection/selection.ts
src/lib/cwl-svg/utils/dom-events.ts
src/lib/cwl-svg/utils/geometry.ts
src/lib/cwl-svg/utils/html-utils.ts

index 74fb0afc9c3abfdcbba09e10033bbf1bf6034be9..334a5148629de38f3624bf5de48864ce14f79a6c 100644 (file)
@@ -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) {
index cb6f228184c5ec7a52b58ec8aa97c52eb628331c..f0cd1c4e1b55bf2ed028ef250feea10c6c7902ea 100644 (file)
@@ -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;
index f3e6498f9e7c57ee7eef563a26df0e303d111b26..3af75434b4a6a7f4780cc3e38b6b0de39f6efbf3 100644 (file)
@@ -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;
         }
 
index 01f1ad545b0ce9da6b0fe8fc5e26820ac967ac67..9d3b423bde27d9038a41b16cb1ecb8e5053ca28e 100644 (file)
@@ -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;
index 10f30e075225da803c8da91e875f384b96f7febb..e5d11e3a13a022763fe331f16db158b643b07b7f 100644 (file)
@@ -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<SVGPathElement>;
 
-        for (let subEdge of <any>subEdges) {
+        for (let subEdge of subEdges as any) {
 
             const path = Workflow.makeConnectionPath(
                 fromX,
index a4e7a31236bc9f2a3059d13f93e0acb1c37a8fa9..443e60ad9cf1150647c88246a06a387ac3ebb67b 100644 (file)
@@ -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"),
index 4f8132a06bb5c07cb4c7a394b945300d7b0f4979..d7ae43f12fe7f123d84a3cfa63aab5538fcf308b 100644 (file)
@@ -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;
                     }
index 11b066d97d5269126a7c0e38a19daa6fd3c0510f..348a7e200e327a03e473a2a7fc10457ad10737b7 100644 (file)
@@ -16,7 +16,7 @@ export class Geometry {
             } else {
                 // node still has parent elements
                 const {e, f} = node.transform.baseVal.getItem(0).matrix;
-                return getPosition(<SVGGElement>node.parentNode, e + addE, f + addF);
+                return getPosition(node.parentNode as SVGGElement, e + addE, f + addF);
             }
         };
 
index 07b5405d1c05ef2f09a929ca79a7bc2cd47256a4..b7bad2b355cb514efef785af2b3fc801ea7823e8 100644 (file)
@@ -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]);
     }
 }