style: Change ESLint configuration from error type to warning type. Format the code.

This commit is contained in:
Revone 2023-11-16 11:55:40 +08:00
parent dd2701dab7
commit be6ad5473b
19 changed files with 52 additions and 55 deletions

View file

@ -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
}

View file

@ -21,8 +21,7 @@ export class AVLTreeNode<V = any, N extends AVLTreeNode<V, N> = AVLTreeNodeNeste
export class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTreeNodeNested<V>>>
extends BST<V, N>
implements IBinaryTree<V, N>
{
implements IBinaryTree<V, N> {
/**
* 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<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTr
// Balance Restoration: If a balance issue is discovered after inserting a node, it requires balance restoration operations. Balance restoration includes four basic cases where rotation operations need to be performed to fix the balance:
switch (
this._balanceFactor(A) // second O(1)
) {
) {
case -2:
if (A && A.left) {
if (this._balanceFactor(A.left) <= 0) {

View file

@ -108,8 +108,7 @@ export class BinaryTreeNode<V = any, N extends BinaryTreeNode<V, N> = BinaryTree
* @template N - The type of the binary tree's nodes.
*/
export class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNode<V, BinaryTreeNodeNested<V>>>
implements IBinaryTree<V, N>
{
implements IBinaryTree<V, N> {
iterationType: IterationType = IterationType.ITERATIVE;
/**
@ -1695,7 +1694,7 @@ export class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = 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<BTNKey, void, undefined> {
* [Symbol.iterator](node = this.root): Generator<BTNKey, void, undefined> {
if (!node) {
return;
}

View file

@ -64,8 +64,7 @@ export class BSTNode<V = any, N extends BSTNode<V, N> = BSTNodeNested<V>> extend
export class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNested<V>>>
extends BinaryTree<V, N>
implements IBinaryTree<V, N>
{
implements IBinaryTree<V, N> {
/**
* The constructor function initializes a binary search tree with an optional comparator function.
* @param {BSTOptions} [options] - An optional object that contains additional configuration options

View file

@ -40,8 +40,7 @@ export class RedBlackTreeNode<V = any, N extends RedBlackTreeNode<V, N> = RedBla
*/
export class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = RedBlackTreeNode<V, RedBlackTreeNodeNested<V>>>
extends BST<V, N>
implements IBinaryTree<V, N>
{
implements IBinaryTree<V, N> {
NIL: N = new RedBlackTreeNode<V>(NaN) as unknown as N;
/**

View file

@ -37,8 +37,7 @@ export class TreeMultimapNode<
*/
export class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = TreeMultimapNode<V, TreeMultimapNodeNested<V>>>
extends AVLTree<V, N>
implements IBinaryTree<V, N>
{
implements IBinaryTree<V, N> {
/**
* The constructor function for a TreeMultimap class in TypeScript, which extends another class and sets an option to
* merge duplicated values.

View file

@ -64,8 +64,7 @@ export abstract class AbstractGraph<
E = any,
VO extends AbstractVertex<V> = AbstractVertex<V>,
EO extends AbstractEdge<E> = AbstractEdge<E>
> implements IGraph<V, E, VO, EO>
{
> implements IGraph<V, E, VO, EO> {
protected _vertices: Map<VertexKey, VO> = new Map<VertexKey, VO>();
get vertices(): Map<VertexKey, VO> {
@ -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);

View file

@ -46,14 +46,13 @@ export class DirectedEdge<E = any> extends AbstractEdge<E> {
}
export class DirectedGraph<
V = any,
E = any,
VO extends DirectedVertex<V> = DirectedVertex<V>,
EO extends DirectedEdge<E> = DirectedEdge<E>
>
V = any,
E = any,
VO extends DirectedVertex<V> = DirectedVertex<V>,
EO extends DirectedEdge<E> = DirectedEdge<E>
>
extends AbstractGraph<V, E, VO, EO>
implements IGraph<V, E, VO, EO>
{
implements IGraph<V, E, VO, EO> {
/**
* The constructor function initializes an instance of a class.
*/

View file

@ -43,14 +43,13 @@ export class UndirectedEdge<E = number> extends AbstractEdge<E> {
}
export class UndirectedGraph<
V = any,
E = any,
VO extends UndirectedVertex<V> = UndirectedVertex<V>,
EO extends UndirectedEdge<E> = UndirectedEdge<E>
>
V = any,
E = any,
VO extends UndirectedVertex<V> = UndirectedVertex<V>,
EO extends UndirectedEdge<E> = UndirectedEdge<E>
>
extends AbstractGraph<V, E, VO, EO>
implements IGraph<V, E, VO, EO>
{
implements IGraph<V, E, VO, EO> {
/**
* The constructor initializes a new Map object to store edges.
*/

View file

@ -459,7 +459,7 @@ export class HashMap<K = any, V = any> {
*
* 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];

View file

@ -1 +1,2 @@
export class TreeMap {}
export class TreeMap {
}

View file

@ -1 +1,2 @@
export class TreeSet {}
export class TreeSet {
}

View file

@ -826,7 +826,7 @@ export class DoublyLinkedList<E = any> {
/**
* The function returns an iterator that iterates over the values of a linked list.
*/
*[Symbol.iterator]() {
* [Symbol.iterator]() {
let current = this.head;
while (current) {

View file

@ -773,7 +773,7 @@ export class SinglyLinkedList<E = any> {
/**
* The function returns an iterator that iterates over the values of a linked list.
*/
*[Symbol.iterator]() {
* [Symbol.iterator]() {
let current = this.head;
while (current) {

View file

@ -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.

View file

@ -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<E = any> extends DoublyLinkedList<E> {}
export class Deque<E = any> extends DoublyLinkedList<E> {
}
// O(1) time complexity of obtaining the value
// O(n) time complexity of adding at the beginning and the end

View file

@ -300,7 +300,7 @@ export class Queue<E = any> {
return new Queue(this.nodes.slice(this.offset));
}
*[Symbol.iterator]() {
* [Symbol.iterator]() {
for (const item of this.nodes) {
yield item;
}

View file

@ -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();

View file

@ -74,7 +74,8 @@ class MyGraph<
describe('AbstractGraph Operation Test', () => {
const myGraph: MyGraph<number, string> = new MyGraph<number, string>();
beforeEach(() => {});
beforeEach(() => {
});
it('should edge cases', function () {
myGraph.addVertex('A', 1);
myGraph.addVertex('B', 2);