Skip to content

Commit e7d82a3

Browse files
committed
eslint & editorconfig
1 parent 8927f49 commit e7d82a3

12 files changed

+610
-25
lines changed

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
root = true
2+
[*]
3+
charset = utf-8
4+
indent_style = space
5+
indent_size = 2
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true

.eslintrc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true,
5+
"node": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/recommended"
10+
],
11+
"parser": "@typescript-eslint/parser",
12+
"parserOptions": {
13+
"ecmaVersion": 12,
14+
"sourceType": "module"
15+
},
16+
"plugins": [
17+
"@typescript-eslint"
18+
],
19+
"rules": {
20+
"@typescript-eslint/explicit-module-boundary-types": "off",
21+
"@typescript-eslint/no-non-null-assertion": "off",
22+
"no-constant-condition": "off",
23+
"@typescript-eslint/no-explicit-any": "off",
24+
"indent": [
25+
"error",
26+
2
27+
],
28+
"linebreak-style": [
29+
"error",
30+
"unix"
31+
],
32+
"quotes": [
33+
"error",
34+
"single"
35+
],
36+
"semi": [
37+
"error",
38+
"always"
39+
]
40+
}
41+
}

.husky/pre-commit

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
npm test
4+
yarn lint
5+
yarn test

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
2222

2323
<!-- ALL-CONTRIBUTORS-LIST:END -->
2424

25-
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
25+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"build": "tsc",
99
"dev": "nodemon src/index.ts",
1010
"test": "jest",
11+
"lint": "eslint src",
1112
"prepare": "husky install"
1213
},
1314
"repository": "git+https://github.com/always-maap/TS-Collection.git",
@@ -29,11 +30,15 @@
2930
"@babel/preset-typescript": "^7.13.0",
3031
"@types/jest": "^26.0.20",
3132
"@types/node": "^14.6.4",
33+
"@typescript-eslint/eslint-plugin": "^4.27.0",
34+
"@typescript-eslint/parser": "^4.27.0",
3235
"all-contributors-cli": "^6.20.0",
3336
"babel-jest": "^26.6.3",
37+
"eslint": "^7.29.0",
3438
"husky": "^5.1.3",
3539
"jest": "^26.6.3",
3640
"nodemon": "^2.0.4",
41+
"prettier": "^2.3.1",
3742
"ts-node": "^9.0.0",
3843
"typescript": "^4.0.2"
3944
}

src/BreadthFirstSearch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export interface IBreadthFirstSearch<T> {
77

88
export class BreadthFirstSearch<T> extends BinarySearchTree<T> implements IBreadthFirstSearch<T> {
99
traverse() {
10-
let node: BSTNode<T> | null = this.root,
11-
data: Array<T> = [],
10+
let node: BSTNode<T> | null = this.root;
11+
const data: Array<T> = [],
1212
queue = new Queue<BSTNode<T> | null>();
1313
queue.enqueue(node);
1414
while (queue.size) {

src/DepthFirstSearch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface IDepthFirstSearch<T> {
88

99
export class DepthFirstSearch<T> extends BinarySearchTree<T> implements IDepthFirstSearch<T> {
1010
preOrder() {
11-
let data: Array<T> = [];
11+
const data: Array<T> = [];
1212
const traverse = (node: BSTNode<T> | null) => {
1313
if (node === null) return;
1414
data.push(node.value);
@@ -20,7 +20,7 @@ export class DepthFirstSearch<T> extends BinarySearchTree<T> implements IDepthFi
2020
}
2121

2222
postOrder() {
23-
let data: Array<T> = [];
23+
const data: Array<T> = [];
2424
const traverse = (node: BSTNode<T> | null) => {
2525
if (node === null) return;
2626
if (node.left) traverse(node.left);
@@ -32,7 +32,7 @@ export class DepthFirstSearch<T> extends BinarySearchTree<T> implements IDepthFi
3232
}
3333

3434
inOrder() {
35-
let data: Array<T> = [];
35+
const data: Array<T> = [];
3636
const traverse = (node: BSTNode<T> | null) => {
3737
if (node === null) return;
3838
if (node.left) traverse(node.left);

src/DoublyLinkedList.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface IDoublyLinkedList<T> {
2626
export class DoublyLinkedList<T> implements IDoublyLinkedList<T> {
2727
private _head: LinkedListNode<T> | null = null;
2828
private _tail: LinkedListNode<T> | null = null;
29-
private length: number = 0;
29+
private length = 0;
3030

3131
push(val: T) {
3232
const newNode = new LinkedListNode(val);

src/Queue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class Queue<T> implements Queue<T> {
3939

4040
dequeue(): T | undefined {
4141
if (!this.first) return undefined;
42-
let nodeToBeRemove = this.first;
42+
const nodeToBeRemove = this.first;
4343
if (this.first === this.last) {
4444
this.last = null;
4545
}

src/QuickSort.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const pivot = (arr: Array<Number>, start = 0, end = arr.length - 1) => {
1+
const pivot = (arr: Array<number>, start = 0, end = arr.length - 1) => {
22
const pivot = arr[start];
33
let swapIndex = start;
44
for (let i = start + 1; i <= end; i++) {

0 commit comments

Comments
 (0)