Skip to content

Commit 63f5a27

Browse files
committed
Upgrade dependencies and fix ESLint issues.
1 parent 4d8baf8 commit 63f5a27

File tree

36 files changed

+6154
-3342
lines changed

36 files changed

+6154
-3342
lines changed

package-lock.json

+6,103-3,288
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@
3535
"devDependencies": {
3636
"@babel/cli": "^7.10.5",
3737
"@babel/preset-env": "^7.10.4",
38-
"@types/jest": "^24.9.1",
39-
"eslint": "^6.8.0",
40-
"eslint-config-airbnb": "^17.1.1",
38+
"@types/jest": "^26.0.7",
39+
"eslint": "^7.5.0",
40+
"eslint-config-airbnb": "^18.2.0",
4141
"eslint-plugin-import": "^2.22.0",
42-
"eslint-plugin-jest": "^22.21.0",
42+
"eslint-plugin-jest": "^23.18.2",
4343
"eslint-plugin-jsx-a11y": "^6.3.1",
4444
"eslint-plugin-react": "^7.20.3",
45-
"husky": "^2.7.0",
46-
"jest": "^24.9.0"
45+
"husky": "^4.2.5",
46+
"jest": "^26.1.0"
4747
},
4848
"dependencies": {}
4949
}

src/algorithms/cryptography/polynomial-hash/PolynomialHash.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default class PolynomialHash {
2020
* @return {number}
2121
*/
2222
hash(word) {
23-
const charCodes = Array.from(word).map(char => this.charToNumber(char));
23+
const charCodes = Array.from(word).map((char) => this.charToNumber(char));
2424

2525
let hash = 0;
2626
for (let charIndex = 0; charIndex < charCodes.length; charIndex += 1) {

src/algorithms/graph/articulation-points/articulationPoints.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default function articulationPoints(graph) {
6666
// Get minimum low discovery time from all neighbors.
6767
/** @param {GraphVertex} neighbor */
6868
visitedSet[currentVertex.getKey()].lowDiscoveryTime = currentVertex.getNeighbors()
69-
.filter(earlyNeighbor => earlyNeighbor.getKey() !== previousVertex.getKey())
69+
.filter((earlyNeighbor) => earlyNeighbor.getKey() !== previousVertex.getKey())
7070
/**
7171
* @param {number} lowestDiscoveryTime
7272
* @param {GraphVertex} neighbor

src/algorithms/graph/bridges/graphBridges.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default function graphBridges(graph) {
5353

5454
// Check if current node is connected to any early node other then previous one.
5555
visitedSet[currentVertex.getKey()].lowDiscoveryTime = currentVertex.getNeighbors()
56-
.filter(earlyNeighbor => earlyNeighbor.getKey() !== previousVertex.getKey())
56+
.filter((earlyNeighbor) => earlyNeighbor.getKey() !== previousVertex.getKey())
5757
.reduce(
5858
/**
5959
* @param {number} lowestDiscoveryTime

src/algorithms/graph/detect-cycle/detectUndirectedCycleUsingDisjointSet.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import DisjointSet from '../../../data-structures/disjoint-set/DisjointSet';
88
export default function detectUndirectedCycleUsingDisjointSet(graph) {
99
// Create initial singleton disjoint sets for each graph vertex.
1010
/** @param {GraphVertex} graphVertex */
11-
const keyExtractor = graphVertex => graphVertex.getKey();
11+
const keyExtractor = (graphVertex) => graphVertex.getKey();
1212
const disjointSet = new DisjointSet(keyExtractor);
13-
graph.getAllVertices().forEach(graphVertex => disjointSet.makeSet(graphVertex));
13+
graph.getAllVertices().forEach((graphVertex) => disjointSet.makeSet(graphVertex));
1414

1515
// Go trough all graph edges one by one and check if edge vertices are from the
1616
// different sets. In this case joint those sets together. Do this until you find

src/algorithms/graph/eulerian-path/eulerianPath.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default function eulerianPath(graph) {
7575
[edgeToDelete] = currentEdges;
7676
} else {
7777
// If there are many edges left then we need to peek any of those except bridges.
78-
[edgeToDelete] = currentEdges.filter(edge => !bridges[edge.getKey()]);
78+
[edgeToDelete] = currentEdges.filter((edge) => !bridges[edge.getKey()]);
7979
}
8080

8181
// Detect next current vertex.

src/algorithms/graph/hamiltonian-cycle/hamiltonianCycle.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function isSafe(adjacencyMatrix, verticesIndices, cycle, vertexCandidate) {
2020
}
2121

2222
// Check if vertexCandidate is being added to the path for the first time.
23-
const candidateDuplicate = cycle.find(vertex => vertex.getKey() === vertexCandidate.getKey());
23+
const candidateDuplicate = cycle.find((vertex) => vertex.getKey() === vertexCandidate.getKey());
2424

2525
return !candidateDuplicate;
2626
}
@@ -61,7 +61,7 @@ function hamiltonianCycleRecursive({
6161
cycle,
6262
}) {
6363
// Clone cycle in order to prevent it from modification by other DFS branches.
64-
const currentCycle = [...cycle].map(vertex => new GraphVertex(vertex.value));
64+
const currentCycle = [...cycle].map((vertex) => new GraphVertex(vertex.value));
6565

6666
if (vertices.length === currentCycle.length) {
6767
// Hamiltonian path is found.

src/algorithms/graph/kruskal/kruskal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function kruskal(graph) {
3333
const sortedEdges = new QuickSort(sortingCallbacks).sort(graph.getAllEdges());
3434

3535
// Create disjoint sets for all graph vertices.
36-
const keyCallback = graphVertex => graphVertex.getKey();
36+
const keyCallback = (graphVertex) => graphVertex.getKey();
3737
const disjointSet = new DisjointSet(keyCallback);
3838

3939
graph.getAllVertices().forEach((graphVertex) => {

src/algorithms/linked-list/reverse-traversal/__test__/reverseTraversal.test.js

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ describe('reverseTraversal', () => {
2121
});
2222
});
2323

24-
2524
// it('should reverse traversal the linked list with callback', () => {
2625
// const linkedList = new LinkedList();
2726
//

src/algorithms/math/fourier-transform/__test__/FourierTester.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export default class FourierTester {
244244
const { input, output: expectedOutput } = testCase;
245245

246246
// Try to split input signal into sequence of pure sinusoids.
247-
const formattedInput = input.map(sample => sample.amplitude);
247+
const formattedInput = input.map((sample) => sample.amplitude);
248248
const currentOutput = fourierTransform(formattedInput);
249249

250250
// Check the signal has been split into proper amount of sub-signals.

src/algorithms/math/fourier-transform/fastFourierTransform.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ export default function fastFourierTransform(inputData, inverse = false) {
4646
for (let blockLength = 2; blockLength <= N; blockLength *= 2) {
4747
const imaginarySign = inverse ? -1 : 1;
4848
const phaseStep = new ComplexNumber({
49-
re: Math.cos(2 * Math.PI / blockLength),
50-
im: imaginarySign * Math.sin(2 * Math.PI / blockLength),
49+
re: Math.cos((2 * Math.PI) / blockLength),
50+
im: imaginarySign * Math.sin((2 * Math.PI) / blockLength),
5151
});
5252

5353
for (let blockStart = 0; blockStart < N; blockStart += blockLength) {

src/algorithms/math/pascal-triangle/pascalTriangle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function pascalTriangle(lineNumber) {
99

1010
for (let numIndex = 1; numIndex < currentLineSize; numIndex += 1) {
1111
// See explanation of this formula in README.
12-
currentLine[numIndex] = currentLine[numIndex - 1] * (lineNumber - numIndex + 1) / numIndex;
12+
currentLine[numIndex] = (currentLine[numIndex - 1] * (lineNumber - numIndex + 1)) / numIndex;
1313
}
1414

1515
return currentLine;

src/algorithms/math/radian/__test__/degreeToRadian.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('degreeToRadian', () => {
66
expect(degreeToRadian(45)).toBe(Math.PI / 4);
77
expect(degreeToRadian(90)).toBe(Math.PI / 2);
88
expect(degreeToRadian(180)).toBe(Math.PI);
9-
expect(degreeToRadian(270)).toBe(3 * Math.PI / 2);
9+
expect(degreeToRadian(270)).toBe((3 * Math.PI) / 2);
1010
expect(degreeToRadian(360)).toBe(2 * Math.PI);
1111
});
1212
});

src/algorithms/math/radian/__test__/radianToDegree.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('radianToDegree', () => {
66
expect(radianToDegree(Math.PI / 4)).toBe(45);
77
expect(radianToDegree(Math.PI / 2)).toBe(90);
88
expect(radianToDegree(Math.PI)).toBe(180);
9-
expect(radianToDegree(3 * Math.PI / 2)).toBe(270);
9+
expect(radianToDegree((3 * Math.PI) / 2)).toBe(270);
1010
expect(radianToDegree(2 * Math.PI)).toBe(360);
1111
});
1212
});

src/algorithms/search/interpolation-search/interpolationSearch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function interpolationSearch(sortedArray, seekElement) {
3131
}
3232

3333
// Do interpolation of the middle index.
34-
const middleIndex = leftIndex + Math.floor(valueDelta * indexDelta / rangeDelta);
34+
const middleIndex = leftIndex + Math.floor((valueDelta * indexDelta) / rangeDelta);
3535

3636
// If we've found the element just return its position.
3737
if (sortedArray[middleIndex] === seekElement) {

src/algorithms/sets/combinations/combineWithRepetitions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default function combineWithRepetitions(comboOptions, comboLength) {
77
// If the length of the combination is 1 then each element of the original array
88
// is a combination itself.
99
if (comboLength === 1) {
10-
return comboOptions.map(comboOption => [comboOption]);
10+
return comboOptions.map((comboOption) => [comboOption]);
1111
}
1212

1313
// Init combinations array.

src/algorithms/sets/combinations/combineWithoutRepetitions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default function combineWithoutRepetitions(comboOptions, comboLength) {
77
// If the length of the combination is 1 then each element of the original array
88
// is a combination itself.
99
if (comboLength === 1) {
10-
return comboOptions.map(comboOption => [comboOption]);
10+
return comboOptions.map((comboOption) => [comboOption]);
1111
}
1212

1313
// Init combinations array.

src/algorithms/sets/knapsack-problem/Knapsack.js

-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ export default class Knapsack {
150150
}
151151
}
152152

153-
154153
// Solve unbounded knapsack problem.
155154
// Greedy approach.
156155
solveUnboundedKnapsackProblem() {

src/algorithms/sets/permutations/permutateWithRepetitions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function permutateWithRepetitions(
88
permutationLength = permutationOptions.length,
99
) {
1010
if (permutationLength === 1) {
11-
return permutationOptions.map(permutationOption => [permutationOption]);
11+
return permutationOptions.map((permutationOption) => [permutationOption]);
1212
}
1313

1414
// Init permutations array.

src/algorithms/uncategorized/n-queens/nQueens.js

-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ function nQueensRecursive(solutions, previousQueensPositions, queensCount, rowIn
8181
return false;
8282
}
8383

84-
8584
/**
8685
* @param {number} queensCount
8786
* @return {QueenPosition[][]}

src/data-structures/bloom-filter/BloomFilter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default class BloomFilter {
1616
const hashValues = this.getHashValues(item);
1717

1818
// Set each hashValue index to true.
19-
hashValues.forEach(val => this.storage.setValue(val));
19+
hashValues.forEach((val) => this.storage.setValue(val));
2020
}
2121

2222
/**

src/data-structures/bloom-filter/__test__/BloomFilter.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('BloomFilter', () => {
5151
});
5252

5353
it('should insert strings correctly and return true when checking for inserted values', () => {
54-
people.forEach(person => bloomFilter.insert(person));
54+
people.forEach((person) => bloomFilter.insert(person));
5555

5656
expect(bloomFilter.mayContain('Bruce Wayne')).toBe(true);
5757
expect(bloomFilter.mayContain('Clark Kent')).toBe(true);

src/data-structures/disjoint-set/__test__/DisjointSet.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('DisjointSet', () => {
9494
});
9595

9696
it('should do basic manipulations on disjoint set with custom key extractor', () => {
97-
const keyExtractor = value => value.key;
97+
const keyExtractor = (value) => value.key;
9898

9999
const disjointSet = new DisjointSet(keyExtractor);
100100

src/data-structures/doubly-linked-list/DoublyLinkedList.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export default class DoublyLinkedList {
218218
* @return {DoublyLinkedList}
219219
*/
220220
fromArray(values) {
221-
values.forEach(value => this.append(value));
221+
values.forEach((value) => this.append(value));
222222

223223
return this;
224224
}
@@ -228,7 +228,7 @@ export default class DoublyLinkedList {
228228
* @return {string}
229229
*/
230230
toString(callback) {
231-
return this.toArray().map(node => node.toString(callback)).toString();
231+
return this.toArray().map((node) => node.toString(callback)).toString();
232232
}
233233

234234
/**

src/data-structures/doubly-linked-list/__test__/DoublyLinkedList.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ describe('DoublyLinkedList', () => {
164164
.append(nodeValue1)
165165
.prepend(nodeValue2);
166166

167-
const nodeStringifier = value => `${value.key}:${value.value}`;
167+
const nodeStringifier = (value) => `${value.key}:${value.value}`;
168168

169169
expect(linkedList.toString(nodeStringifier)).toBe('key2:2,key1:1');
170170
});
@@ -195,12 +195,12 @@ describe('DoublyLinkedList', () => {
195195
.append({ value: 2, key: 'test2' })
196196
.append({ value: 3, key: 'test3' });
197197

198-
const node = linkedList.find({ callback: value => value.key === 'test2' });
198+
const node = linkedList.find({ callback: (value) => value.key === 'test2' });
199199

200200
expect(node).toBeDefined();
201201
expect(node.value.value).toBe(2);
202202
expect(node.value.key).toBe('test2');
203-
expect(linkedList.find({ callback: value => value.key === 'test5' })).toBeNull();
203+
expect(linkedList.find({ callback: (value) => value.key === 'test5' })).toBeNull();
204204
});
205205

206206
it('should find node by means of custom compare function', () => {

src/data-structures/doubly-linked-list/__test__/DoublyLinkedListNode.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('DoublyLinkedListNode', () => {
4848
it('should convert node to string with custom stringifier', () => {
4949
const nodeValue = { value: 1, key: 'test' };
5050
const node = new DoublyLinkedListNode(nodeValue);
51-
const toStringCallback = value => `value: ${value.value}, key: ${value.key}`;
51+
const toStringCallback = (value) => `value: ${value.value}, key: ${value.key}`;
5252

5353
expect(node.toString(toStringCallback)).toBe('value: 1, key: test');
5454
});

src/data-structures/graph/GraphVertex.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default class GraphVertex {
6464
* @return {GraphEdge[]}
6565
*/
6666
getEdges() {
67-
return this.edges.toArray().map(linkedListNode => linkedListNode.value);
67+
return this.edges.toArray().map((linkedListNode) => linkedListNode.value);
6868
}
6969

7070
/**
@@ -80,7 +80,7 @@ export default class GraphVertex {
8080
*/
8181
hasEdge(requiredEdge) {
8282
const edgeNode = this.edges.find({
83-
callback: edge => edge === requiredEdge,
83+
callback: (edge) => edge === requiredEdge,
8484
});
8585

8686
return !!edgeNode;
@@ -92,7 +92,7 @@ export default class GraphVertex {
9292
*/
9393
hasNeighbor(vertex) {
9494
const vertexNode = this.edges.find({
95-
callback: edge => edge.startVertex === vertex || edge.endVertex === vertex,
95+
callback: (edge) => edge.startVertex === vertex || edge.endVertex === vertex,
9696
});
9797

9898
return !!vertexNode;
@@ -123,7 +123,7 @@ export default class GraphVertex {
123123
* @return {GraphVertex}
124124
*/
125125
deleteAllEdges() {
126-
this.getEdges().forEach(edge => this.deleteEdge(edge));
126+
this.getEdges().forEach((edge) => this.deleteEdge(edge));
127127

128128
return this;
129129
}

src/data-structures/hash-table/HashTable.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default class HashTable {
5252
const keyHash = this.hash(key);
5353
this.keys[key] = keyHash;
5454
const bucketLinkedList = this.buckets[keyHash];
55-
const node = bucketLinkedList.find({ callback: nodeValue => nodeValue.key === key });
55+
const node = bucketLinkedList.find({ callback: (nodeValue) => nodeValue.key === key });
5656

5757
if (!node) {
5858
// Insert new node.
@@ -71,7 +71,7 @@ export default class HashTable {
7171
const keyHash = this.hash(key);
7272
delete this.keys[key];
7373
const bucketLinkedList = this.buckets[keyHash];
74-
const node = bucketLinkedList.find({ callback: nodeValue => nodeValue.key === key });
74+
const node = bucketLinkedList.find({ callback: (nodeValue) => nodeValue.key === key });
7575

7676
if (node) {
7777
return bucketLinkedList.delete(node.value);
@@ -86,7 +86,7 @@ export default class HashTable {
8686
*/
8787
get(key) {
8888
const bucketLinkedList = this.buckets[this.hash(key)];
89-
const node = bucketLinkedList.find({ callback: nodeValue => nodeValue.key === key });
89+
const node = bucketLinkedList.find({ callback: (nodeValue) => nodeValue.key === key });
9090

9191
return node ? node.value.value : undefined;
9292
}

src/data-structures/hash-table/__test__/HashTable.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('HashTable', () => {
3535
expect(hashTable.has('b')).toBe(true);
3636
expect(hashTable.has('c')).toBe(true);
3737

38-
const stringifier = value => `${value.key}:${value.value}`;
38+
const stringifier = (value) => `${value.key}:${value.value}`;
3939

4040
expect(hashTable.buckets[0].toString(stringifier)).toBe('c:earth');
4141
expect(hashTable.buckets[1].toString(stringifier)).toBe('a:sky,d:ocean');

src/data-structures/linked-list/LinkedList.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export default class LinkedList {
180180
* @return {LinkedList}
181181
*/
182182
fromArray(values) {
183-
values.forEach(value => this.append(value));
183+
values.forEach((value) => this.append(value));
184184

185185
return this;
186186
}
@@ -205,7 +205,7 @@ export default class LinkedList {
205205
* @return {string}
206206
*/
207207
toString(callback) {
208-
return this.toArray().map(node => node.toString(callback)).toString();
208+
return this.toArray().map((node) => node.toString(callback)).toString();
209209
}
210210

211211
/**

src/data-structures/linked-list/__test__/LinkedList.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ describe('LinkedList', () => {
146146
.append(nodeValue1)
147147
.prepend(nodeValue2);
148148

149-
const nodeStringifier = value => `${value.key}:${value.value}`;
149+
const nodeStringifier = (value) => `${value.key}:${value.value}`;
150150

151151
expect(linkedList.toString(nodeStringifier)).toBe('key2:2,key1:1');
152152
});
@@ -177,12 +177,12 @@ describe('LinkedList', () => {
177177
.append({ value: 2, key: 'test2' })
178178
.append({ value: 3, key: 'test3' });
179179

180-
const node = linkedList.find({ callback: value => value.key === 'test2' });
180+
const node = linkedList.find({ callback: (value) => value.key === 'test2' });
181181

182182
expect(node).toBeDefined();
183183
expect(node.value.value).toBe(2);
184184
expect(node.value.key).toBe('test2');
185-
expect(linkedList.find({ callback: value => value.key === 'test5' })).toBeNull();
185+
expect(linkedList.find({ callback: (value) => value.key === 'test5' })).toBeNull();
186186
});
187187

188188
it('should create linked list from array', () => {

0 commit comments

Comments
 (0)