From a7f5bd1c2438f95252f5515d7226b491dfb5183b Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Fri, 24 May 2024 11:27:56 -0400
Subject: lint fixes

---
 .../collectionFreeForm/CollectionFreeFormView.tsx  | 66 +++++++++++-----------
 1 file changed, 32 insertions(+), 34 deletions(-)

(limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx')

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index be96b914c..b6e1fca77 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -894,7 +894,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
                             const inkList = strokeToTVals.get(inkView);
                             if (inkList !== undefined) {
                                 const tValOffset = ActiveEraserWidth() / 1050; // to prevent tVals from being added when too close, but scaled by eraser width
-                                const inList = inkList.some(val => Math.abs(val - (t + Math.floor(i / 4))) <= tValOffset);
+                                const inList = inkList.some(ival => Math.abs(ival - (t + Math.floor(i / 4))) <= tValOffset);
                                 if (!inList) {
                                     inkList.push(t + Math.floor(i / 4));
                                 }
@@ -1007,7 +1007,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
         let segment2: Segment = [];
         const { inkData } = (ink?.ComponentView as InkingStroke).inkScaledData();
         let intersections: number[] = []; // list of the ink stroke's intersections
-        let segmentIndexes: number[] = []; // list of indexes of the curve's segment where each intersection occured
+        const segmentIndexes: number[] = []; // list of indexes of the curve's segment where each intersection occured
 
         // loops through each segment and adds intersections to the list
         for (let i = 0; i < inkData.length - 3; i += 4) {
@@ -1034,7 +1034,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
 
         if (intersections.length) {
             // this is the indexes of the closest intersection(s)
-            let closestTs = this.getClosestTs(intersections, excludeT, 0, intersections.length - 1);
+            const closestTs = this.getClosestTs(intersections, excludeT, 0, intersections.length - 1);
 
             // find the segments that need to be split
             let splitSegment1 = -1; // stays -1 if left end is deleted
@@ -1095,23 +1095,22 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
                     } else if (hasSplit && !continueErasing) {
                         segment2.push(inkSegment);
                     }
-                } else {
-                    // case where last end is erased
-                    if (currCurveT === segmentIndexes[0] && isClosedCurve) {
-                        if (isClosedCurve && currCurveT === segmentIndexes.lastElement()) {
-                            segment1.push(inkSegment.split(intersections[0] - currCurveT, intersections.lastElement() - currCurveT));
-                            continueErasing = true;
-                        } else {
-                            segment1.push(inkSegment.split(intersections[0] - currCurveT, 1));
-                        }
-                        hasSplit = true;
-                    } else if (currCurveT === splitSegment1) {
-                        segment1.push(inkSegment.split(0, intersections[closestTs[0]] - currCurveT));
-                        hasSplit = true;
+                }
+                // case where last end is erased
+                else if (currCurveT === segmentIndexes[0] && isClosedCurve) {
+                    if (isClosedCurve && currCurveT === segmentIndexes.lastElement()) {
+                        segment1.push(inkSegment.split(intersections[0] - currCurveT, intersections.lastElement() - currCurveT));
                         continueErasing = true;
-                    } else if ((isClosedCurve && hasSplit && !continueErasing) || (!isClosedCurve && !hasSplit)) {
-                        segment1.push(inkSegment);
+                    } else {
+                        segment1.push(inkSegment.split(intersections[0] - currCurveT, 1));
                     }
+                    hasSplit = true;
+                } else if (currCurveT === splitSegment1) {
+                    segment1.push(inkSegment.split(0, intersections[closestTs[0]] - currCurveT));
+                    hasSplit = true;
+                    continueErasing = true;
+                } else if ((isClosedCurve && hasSplit && !continueErasing) || (!isClosedCurve && !hasSplit)) {
+                    segment1.push(inkSegment);
                 }
             }
         }
@@ -1144,22 +1143,21 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
     getClosestTs = (tVals: number[], excludeT: number, startIndex: number, endIndex: number): number[] => {
         if (tVals[startIndex] >= excludeT) {
             return [-1, startIndex];
-        } else if (tVals[endIndex] < excludeT) {
+        }
+        if (tVals[endIndex] < excludeT) {
             return [endIndex, -1];
-        } else {
-            const mid = Math.floor((startIndex + endIndex) / 2);
-            if (excludeT >= tVals[mid]) {
-                if (mid + 1 <= endIndex && tVals[mid + 1] > excludeT) {
-                    return [mid, mid + 1];
-                } else {
-                    return this.getClosestTs(tVals, excludeT, mid + 1, endIndex);
-                }
-            } else if (mid - 1 >= startIndex && tVals[mid - 1] < excludeT) {
-                return [mid - 1, mid];
-            } else {
-                return this.getClosestTs(tVals, excludeT, startIndex, mid - 1);
+        }
+        const mid = Math.floor((startIndex + endIndex) / 2);
+        if (excludeT >= tVals[mid]) {
+            if (mid + 1 <= endIndex && tVals[mid + 1] > excludeT) {
+                return [mid, mid + 1];
             }
+            return this.getClosestTs(tVals, excludeT, mid + 1, endIndex);
+        }
+        if (mid - 1 >= startIndex && tVals[mid - 1] < excludeT) {
+            return [mid - 1, mid];
         }
+        return this.getClosestTs(tVals, excludeT, startIndex, mid - 1);
     };
 
     // for some reason bezier.js doesn't handle the case of intersecting a linear curve, so we wrap the intersection
@@ -1212,10 +1210,10 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
                     if (apt.d !== undefined && apt.d < 1 && apt.t !== undefined && !tVals.includes(apt.t)) {
                         tVals.push(apt.t);
                     }
-                    this.bintersects(curve, otherCurve).forEach((val: string | number, i: number) => {
+                    this.bintersects(curve, otherCurve).forEach((val: string | number, ival: number) => {
                         // Converting the Bezier.js Split type to a t-value number.
                         const t = +val.toString().split('/')[0];
-                        if (i % 2 === 0 && !tVals.includes(t)) tVals.push(t); // bcz: Hack!  don't know why but intersection points are doubled from bezier.js (but not identical).
+                        if (ival % 2 === 0 && !tVals.includes(t)) tVals.push(t); // bcz: Hack!  don't know why but intersection points are doubled from bezier.js (but not identical).
                     });
                     if (bpt.d !== undefined && bpt.d < 1 && bpt.t !== undefined && !tVals.includes(bpt.t)) {
                         tVals.push(bpt.t);
@@ -1775,8 +1773,8 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
             ({ code, first }) => {
                 if (!code.includes('dashDiv')) {
                     const script = CompileScript(code, { params: { docView: 'any' }, typecheck: false, editable: true });
-                    // eslint-disable-next-line no-eval
                     if (script.compiled) script.run({ this: this.DocumentView?.() });
+                    // eslint-disable-next-line no-eval
                 } else code && !first && eval?.(code);
             },
             { fireImmediately: true }
-- 
cgit v1.2.3-70-g09d2

