diff --git a/web/src/engine/common/web-utils/.eslintrc.cjs b/web/src/engine/common/web-utils/.eslintrc.cjs new file mode 100644 index 0000000000..30334ae3dc --- /dev/null +++ b/web/src/engine/common/web-utils/.eslintrc.cjs @@ -0,0 +1,4 @@ +module.exports = { + // Temporarily ignored due to noise it would cause within the refactor + ignorePatterns: ["**/kmwstring.ts"] +}; diff --git a/web/src/engine/common/web-utils/build.sh b/web/src/engine/common/web-utils/build.sh index ac18e2984c..b8e28eae1b 100755 --- a/web/src/engine/common/web-utils/build.sh +++ b/web/src/engine/common/web-utils/build.sh @@ -32,7 +32,7 @@ builder_describe_outputs \ builder_parse "$@" function do_build() { - tsc --build $builder_verbose "$THIS_SCRIPT_PATH/tsconfig.json" + compile $SUBPROJECT_NAME # May be useful one day, for building a mass .d.ts for KMW as a whole. # So... tsc does declaration-bundling on its own pretty well, at least for local development. diff --git a/web/src/engine/common/web-utils/src/deepCopy.ts b/web/src/engine/common/web-utils/src/deepCopy.ts index 083b598cc4..c88f255660 100644 --- a/web/src/engine/common/web-utils/src/deepCopy.ts +++ b/web/src/engine/common/web-utils/src/deepCopy.ts @@ -15,7 +15,7 @@ export default function deepCopy { // Use of 'indices' here is a bit of a customization. // At the cost of (temporary) extra storage space, we can more efficiently enqueue // multiple elements simultaneously. - let queuedIndices: number[] = []; + const queuedIndices: number[] = []; let lastParent = -1; for(let i = end; i >= start; i--) { - let parent = PriorityQueue.parentIndex(i); + const parent = PriorityQueue.parentIndex(i); if(this.siftDown(i) && parent < start && lastParent != parent) { // We only need to queue examination for a heap node if its children have changed // and it isn't already being examined. @@ -95,8 +95,8 @@ export default class PriorityQueue { lastParent = -1; while(queuedIndices.length > 0) { - let index = queuedIndices.shift() as number; - let parent = PriorityQueue.parentIndex(index); + const index = queuedIndices.shift() as number; + const parent = PriorityQueue.parentIndex(index); if(this.siftDown(index) && parent >= 0 && lastParent != parent) { // We only need to queue examination for a heap node if its children have changed. queuedIndices.push(parent); @@ -131,10 +131,10 @@ export default class PriorityQueue { let index = this.heap.length; this.heap.push(element); - let parent = PriorityQueue.parentIndex; + const parent = PriorityQueue.parentIndex; let parentIndex = parent(index); while(index !== 0 && this.comparator(this.heap[index], this.heap[parentIndex]) < 0) { - let a = this.heap[index]; + const a = this.heap[index]; this.heap[index] = this.heap[parentIndex]; this.heap[parentIndex] = a; @@ -156,9 +156,9 @@ export default class PriorityQueue { return; } - let firstIndex = this.count + const firstIndex = this.count this.heap = this.heap.concat(elements); - let firstParent = PriorityQueue.parentIndex(firstIndex); + const firstParent = PriorityQueue.parentIndex(firstIndex); // The 'parent' of index 0 will return -1, which is illegal. this.heapify(firstParent >= 0 ? firstParent : 0, PriorityQueue.parentIndex(this.count-1)); @@ -175,7 +175,7 @@ export default class PriorityQueue { } const root = this.heap[0]; - let tail = this.heap.pop() as Type; + const tail = this.heap.pop() as Type; if(this.heap.length > 0) { this.heap[0] = tail; this.siftDown(0); @@ -195,8 +195,8 @@ export default class PriorityQueue { * @returns `true` if a swap occurred, `false` otherwise. */ private siftDown(index: number): boolean { - let leftIndex = PriorityQueue.leftChildIndex(index); - let rightIndex = PriorityQueue.rightChildIndex(index); + const leftIndex = PriorityQueue.leftChildIndex(index); + const rightIndex = PriorityQueue.rightChildIndex(index); let topMostIndex = index; if(leftIndex < this.heap.length && this.comparator(this.heap[leftIndex], this.heap[topMostIndex]) < 0) { @@ -208,7 +208,7 @@ export default class PriorityQueue { } if(topMostIndex != index) { - let a = this.heap[index]; + const a = this.heap[index]; this.heap[index] = this.heap[topMostIndex]; this.heap[topMostIndex] = a; diff --git a/web/src/engine/common/web-utils/src/version.ts b/web/src/engine/common/web-utils/src/version.ts index 27e865ee1e..145b336106 100644 --- a/web/src/engine/common/web-utils/src/version.ts +++ b/web/src/engine/common/web-utils/src/version.ts @@ -29,7 +29,7 @@ export default class Version { } if(Array.isArray(text)) { - let components = text as number[]; + const components = text as number[]; if(components.length < 2) { throw new Error("Version string must have at least a major and minor component!"); } else { @@ -39,15 +39,15 @@ export default class Version { } // else, standard constructor path. - let parts = text.split('.'); - let componentArray: number[] = []; + const parts = text.split('.'); + const componentArray: number[] = []; if(parts.length < 2) { throw new Error("Version string must have at least a major and minor component!"); } for(let i=0; i < parts.length; i++) { - let value = parseInt(parts[i], 10); + const value = parseInt(parts[i], 10); if(isNaN(value)) { throw new Error("Version string components must be numerical!"); } @@ -84,18 +84,18 @@ export default class Version { compareTo(other: Version): number { // If the version info depth differs, we need a flag to indicate which instance is shorter. - var isShorter: boolean = this.components.length < other.components.length; - var maxDepth: number = (this.components.length < other.components.length) ? this.components.length : other.components.length; + const isShorter: boolean = this.components.length < other.components.length; + const maxDepth: number = (this.components.length < other.components.length) ? this.components.length : other.components.length; - var i: number; + let i: number; for(i = 0; i < maxDepth; i++) { - let delta = this.components[i] - other.components[i]; + const delta = this.components[i] - other.components[i]; if(delta != 0) { return delta; } } - var longList = isShorter ? other.components : this.components; + const longList = isShorter ? other.components : this.components; do { if(longList[i] > 0) { return isShorter ? -1 : 1;