diff --git a/.eslintrc.js b/.eslintrc.js index 0953b89..9f9729b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,8 +1,8 @@ module.exports = { "parser": "@typescript-eslint/parser", "plugins": [ - "import", - "@typescript-eslint" + "@typescript-eslint", + "eslint-plugin-import" ], "extends": [ "plugin:@typescript-eslint/recommended", @@ -17,7 +17,7 @@ module.exports = { "@typescript-eslint/no-var-requires": "off", "@typescript-eslint/no-non-null-assertion": "off", "lines-around-comment": [ - "error", + "warn", { "beforeLineComment": false, "beforeBlockComment": true, @@ -29,7 +29,7 @@ module.exports = { ], "newline-before-return": "off", "import/newline-after-import": [ - "error", + "warn", { "count": 1 } diff --git a/src/data-structures/binary-tree/avl-tree.ts b/src/data-structures/binary-tree/avl-tree.ts index 04ce1b1..2a294af 100644 --- a/src/data-structures/binary-tree/avl-tree.ts +++ b/src/data-structures/binary-tree/avl-tree.ts @@ -21,8 +21,7 @@ export class AVLTreeNode = AVLTreeNodeNeste export class AVLTree = AVLTreeNode>> extends BST - implements IBinaryTree -{ + implements IBinaryTree { /** * This is a constructor function for an AVL tree data structure in TypeScript. * @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be passed to the @@ -210,7 +209,7 @@ export class AVLTree = AVLTreeNode = BinaryTree * @template N - The type of the binary tree's nodes. */ export class BinaryTree = BinaryTreeNode>> - implements IBinaryTree -{ + implements IBinaryTree { iterationType: IterationType = IterationType.ITERATIVE; /** @@ -1695,7 +1694,7 @@ export class BinaryTree = BinaryTreeNode * @returns The `*[Symbol.iterator]` method returns a generator object that yields the keys of the * binary tree nodes in a specific order. */ - *[Symbol.iterator](node = this.root): Generator { + * [Symbol.iterator](node = this.root): Generator { if (!node) { return; } diff --git a/src/data-structures/binary-tree/bst.ts b/src/data-structures/binary-tree/bst.ts index d2f1d86..0937cc5 100644 --- a/src/data-structures/binary-tree/bst.ts +++ b/src/data-structures/binary-tree/bst.ts @@ -64,8 +64,7 @@ export class BSTNode = BSTNodeNested> extend export class BST = BSTNode>> extends BinaryTree - implements IBinaryTree -{ + implements IBinaryTree { /** * The constructor function initializes a binary search tree with an optional comparator function. * @param {BSTOptions} [options] - An optional object that contains additional configuration options diff --git a/src/data-structures/binary-tree/rb-tree.ts b/src/data-structures/binary-tree/rb-tree.ts index 788a7f5..268e742 100644 --- a/src/data-structures/binary-tree/rb-tree.ts +++ b/src/data-structures/binary-tree/rb-tree.ts @@ -40,8 +40,7 @@ export class RedBlackTreeNode = RedBla */ export class RedBlackTree = RedBlackTreeNode>> extends BST - implements IBinaryTree -{ + implements IBinaryTree { NIL: N = new RedBlackTreeNode(NaN) as unknown as N; /** diff --git a/src/data-structures/binary-tree/tree-multimap.ts b/src/data-structures/binary-tree/tree-multimap.ts index 16fa249..cf320db 100644 --- a/src/data-structures/binary-tree/tree-multimap.ts +++ b/src/data-structures/binary-tree/tree-multimap.ts @@ -37,8 +37,7 @@ export class TreeMultimapNode< */ export class TreeMultimap = TreeMultimapNode>> extends AVLTree - implements IBinaryTree -{ + implements IBinaryTree { /** * The constructor function for a TreeMultimap class in TypeScript, which extends another class and sets an option to * merge duplicated values. diff --git a/src/data-structures/graph/abstract-graph.ts b/src/data-structures/graph/abstract-graph.ts index e064377..4a0931d 100644 --- a/src/data-structures/graph/abstract-graph.ts +++ b/src/data-structures/graph/abstract-graph.ts @@ -64,8 +64,7 @@ export abstract class AbstractGraph< E = any, VO extends AbstractVertex = AbstractVertex, EO extends AbstractEdge = AbstractEdge -> implements IGraph -{ +> implements IGraph { protected _vertices: Map = new Map(); get vertices(): Map { @@ -615,14 +614,14 @@ export abstract class AbstractGraph< } getMinDist && - distMap.forEach((d, v) => { - if (v !== srcVertex) { - if (d < minDist) { - minDist = d; - if (genPaths) minDest = v; - } + distMap.forEach((d, v) => { + if (v !== srcVertex) { + if (d < minDist) { + minDist = d; + if (genPaths) minDest = v; } - }); + } + }); genPaths && getPaths(minDest); diff --git a/src/data-structures/graph/directed-graph.ts b/src/data-structures/graph/directed-graph.ts index f6bc9b3..dd63391 100644 --- a/src/data-structures/graph/directed-graph.ts +++ b/src/data-structures/graph/directed-graph.ts @@ -46,14 +46,13 @@ export class DirectedEdge extends AbstractEdge { } export class DirectedGraph< - V = any, - E = any, - VO extends DirectedVertex = DirectedVertex, - EO extends DirectedEdge = DirectedEdge - > + V = any, + E = any, + VO extends DirectedVertex = DirectedVertex, + EO extends DirectedEdge = DirectedEdge +> extends AbstractGraph - implements IGraph -{ + implements IGraph { /** * The constructor function initializes an instance of a class. */ diff --git a/src/data-structures/graph/undirected-graph.ts b/src/data-structures/graph/undirected-graph.ts index 2e7fded..8f77120 100644 --- a/src/data-structures/graph/undirected-graph.ts +++ b/src/data-structures/graph/undirected-graph.ts @@ -43,14 +43,13 @@ export class UndirectedEdge extends AbstractEdge { } export class UndirectedGraph< - V = any, - E = any, - VO extends UndirectedVertex = UndirectedVertex, - EO extends UndirectedEdge = UndirectedEdge - > + V = any, + E = any, + VO extends UndirectedVertex = UndirectedVertex, + EO extends UndirectedEdge = UndirectedEdge +> extends AbstractGraph - implements IGraph -{ + implements IGraph { /** * The constructor initializes a new Map object to store edges. */ diff --git a/src/data-structures/hash/hash-map.ts b/src/data-structures/hash/hash-map.ts index 0720cc1..a6b6f95 100644 --- a/src/data-structures/hash/hash-map.ts +++ b/src/data-structures/hash/hash-map.ts @@ -459,7 +459,7 @@ export class HashMap { * * The above function is an iterator that yields key-value pairs from a linked list. */ - *[Symbol.iterator]() { + * [Symbol.iterator]() { let node = this._head; while (node !== this._sentinel) { yield <[K, V]>[node.key, node.value]; diff --git a/src/data-structures/hash/tree-map.ts b/src/data-structures/hash/tree-map.ts index fe86360..a6d743d 100644 --- a/src/data-structures/hash/tree-map.ts +++ b/src/data-structures/hash/tree-map.ts @@ -1 +1,2 @@ -export class TreeMap {} +export class TreeMap { +} diff --git a/src/data-structures/hash/tree-set.ts b/src/data-structures/hash/tree-set.ts index 591aeda..65f14db 100644 --- a/src/data-structures/hash/tree-set.ts +++ b/src/data-structures/hash/tree-set.ts @@ -1 +1,2 @@ -export class TreeSet {} +export class TreeSet { +} diff --git a/src/data-structures/linked-list/doubly-linked-list.ts b/src/data-structures/linked-list/doubly-linked-list.ts index d877137..2499e87 100644 --- a/src/data-structures/linked-list/doubly-linked-list.ts +++ b/src/data-structures/linked-list/doubly-linked-list.ts @@ -826,7 +826,7 @@ export class DoublyLinkedList { /** * The function returns an iterator that iterates over the values of a linked list. */ - *[Symbol.iterator]() { + * [Symbol.iterator]() { let current = this.head; while (current) { diff --git a/src/data-structures/linked-list/singly-linked-list.ts b/src/data-structures/linked-list/singly-linked-list.ts index 58323ab..c1a26f0 100644 --- a/src/data-structures/linked-list/singly-linked-list.ts +++ b/src/data-structures/linked-list/singly-linked-list.ts @@ -773,7 +773,7 @@ export class SinglyLinkedList { /** * The function returns an iterator that iterates over the values of a linked list. */ - *[Symbol.iterator]() { + * [Symbol.iterator]() { let current = this.head; while (current) { diff --git a/src/data-structures/matrix/vector2d.ts b/src/data-structures/matrix/vector2d.ts index 1b2ff44..2f62f4e 100644 --- a/src/data-structures/matrix/vector2d.ts +++ b/src/data-structures/matrix/vector2d.ts @@ -10,7 +10,8 @@ export class Vector2D { public x: number = 0, public y: number = 0, public w: number = 1 // needed for matrix multiplication - ) {} + ) { + } /** * The function checks if the x and y values of a point are both zero. diff --git a/src/data-structures/queue/deque.ts b/src/data-structures/queue/deque.ts index ec21a74..c6c2ed1 100644 --- a/src/data-structures/queue/deque.ts +++ b/src/data-structures/queue/deque.ts @@ -9,7 +9,8 @@ import { DoublyLinkedList } from '../linked-list'; // O(n) time complexity of obtaining the value // O(1) time complexity of adding at the beginning and the end -export class Deque extends DoublyLinkedList {} +export class Deque extends DoublyLinkedList { +} // O(1) time complexity of obtaining the value // O(n) time complexity of adding at the beginning and the end diff --git a/src/data-structures/queue/queue.ts b/src/data-structures/queue/queue.ts index 4de12e4..035950a 100644 --- a/src/data-structures/queue/queue.ts +++ b/src/data-structures/queue/queue.ts @@ -300,7 +300,7 @@ export class Queue { return new Queue(this.nodes.slice(this.offset)); } - *[Symbol.iterator]() { + * [Symbol.iterator]() { for (const item of this.nodes) { yield item; } diff --git a/test/integration/index.html b/test/integration/index.html index 2ff1a4a..e9b2d7f 100644 --- a/test/integration/index.html +++ b/test/integration/index.html @@ -35,7 +35,7 @@ console.error(e); } try { - const {AVLTree} = window.dataStructureTyped; + const { AVLTree } = window.dataStructureTyped; const avlTree = new AVLTree(); const $avlTree = document.createElement('li'); const $avlTreeSpan = document.createElement('span'); @@ -52,7 +52,7 @@ } try { - const {BinaryTree} = dataStructureTyped; + const { BinaryTree } = dataStructureTyped; const tree = new BinaryTree(); tree.add(3); tree.add(12); @@ -76,8 +76,8 @@ try { - const {OrderedMap} = sdsl; - const {RedBlackTree} = dataStructureTyped; + const { OrderedMap } = sdsl; + const { RedBlackTree } = dataStructureTyped; const cTree = new OrderedMap(); const tree = new RedBlackTree(); const tS = performance.now(); @@ -101,9 +101,9 @@ } try { - const {PriorityQueue: CPriorityQueue} = sdsl; - const {PriorityQueue} = dataStructureTyped; - const pq = new PriorityQueue({comparator: (a, b) => b - a}); + const { PriorityQueue: CPriorityQueue } = sdsl; + const { PriorityQueue } = dataStructureTyped; + const pq = new PriorityQueue({ comparator: (a, b) => b - a }); const tS = performance.now(); diff --git a/test/unit/data-structures/graph/abstract-graph.test.ts b/test/unit/data-structures/graph/abstract-graph.test.ts index a0df221..54b0ac0 100644 --- a/test/unit/data-structures/graph/abstract-graph.test.ts +++ b/test/unit/data-structures/graph/abstract-graph.test.ts @@ -74,7 +74,8 @@ class MyGraph< describe('AbstractGraph Operation Test', () => { const myGraph: MyGraph = new MyGraph(); - beforeEach(() => {}); + beforeEach(() => { + }); it('should edge cases', function () { myGraph.addVertex('A', 1); myGraph.addVertex('B', 2);