From af4388a9cfd166fc6afe738b703249ab3e6f83ea Mon Sep 17 00:00:00 2001 From: Djavid Gabibiyan Date: Wed, 13 Jul 2022 17:24:49 +0500 Subject: [PATCH] chore: various linter fixes across packages --- packages/dash-spv/lib/blockstore.js | 1 - packages/dash-spv/lib/consensus.js | 6 +++--- packages/dash-spv/lib/merkleproofs.js | 4 ++-- packages/dash-spv/lib/spvchain.js | 12 ++++++------ packages/dash-spv/test/data/headers.js | 2 +- packages/dashmate/src/commands/group/stop.js | 2 +- packages/dashmate/src/docker/DockerCompose.js | 4 ++-- .../lib/test/createFaucetClient.js | 1 - 8 files changed, 15 insertions(+), 17 deletions(-) diff --git a/packages/dash-spv/lib/blockstore.js b/packages/dash-spv/lib/blockstore.js index 832d2481e67..1ed82a8c1cf 100644 --- a/packages/dash-spv/lib/blockstore.js +++ b/packages/dash-spv/lib/blockstore.js @@ -53,5 +53,4 @@ class BlockStore { } } - module.exports = BlockStore; diff --git a/packages/dash-spv/lib/consensus.js b/packages/dash-spv/lib/consensus.js index 54adedfe97d..8ef5fefd047 100644 --- a/packages/dash-spv/lib/consensus.js +++ b/packages/dash-spv/lib/consensus.js @@ -6,7 +6,7 @@ const MIN_TIMESTAMP_HEADERS = 11; const MIN_DGW_HEADERS = 24; function getMedianTimestamp(headers) { - const timestamps = headers.map(h => h.time); + const timestamps = headers.map((h) => h.time); const median = (arr) => { const mid = Math.floor(arr.length / 2); const nums = [...arr].sort((a, b) => a - b); @@ -22,7 +22,7 @@ function hasGreaterThanMedianTimestamp(newHeader, previousHeaders) { const headerNormalised = utils.normalizeHeader(newHeader); const normalizedLatestHeaders = previousHeaders.slice( Math.max(previousHeaders.length - MIN_TIMESTAMP_HEADERS, 0), - ).map(h => utils.normalizeHeader(h)); + ).map((h) => utils.normalizeHeader(h)); return getMedianTimestamp(normalizedLatestHeaders) < headerNormalised.time; } @@ -32,7 +32,7 @@ function isValidBlockHeader(newHeader, previousHeaders, network = 'mainnet') { && newHeader.validTimestamp() && hasGreaterThanMedianTimestamp(newHeader, previousHeaders) && hasValidTarget( - utils.getDgwBlock(newHeader), previousHeaders.map(h => utils.getDgwBlock(h)), network, + utils.getDgwBlock(newHeader), previousHeaders.map((h) => utils.getDgwBlock(h)), network, ); } return newHeader.validProofOfWork() diff --git a/packages/dash-spv/lib/merkleproofs.js b/packages/dash-spv/lib/merkleproofs.js index d9b3a12c144..dca09952c35 100644 --- a/packages/dash-spv/lib/merkleproofs.js +++ b/packages/dash-spv/lib/merkleproofs.js @@ -11,10 +11,10 @@ const merkleproofs = { validateTxProofs: (merkleBlock, transactions) => { let txToFilter = transactions.slice(); if (typeof transactions[0] === 'string') { - txToFilter = txToFilter.map(tx => DashUtil.toHash(tx).toString('hex')); + txToFilter = txToFilter.map((tx) => DashUtil.toHash(tx).toString('hex')); } return merkleBlock.validMerkleTree - && txToFilter.filter(tx => merkleBlock.hasTransaction(tx)).length === transactions.length; + && txToFilter.filter((tx) => merkleBlock.hasTransaction(tx)).length === transactions.length; }, }; diff --git a/packages/dash-spv/lib/spvchain.js b/packages/dash-spv/lib/spvchain.js index f35ae5a90e5..7f905907691 100644 --- a/packages/dash-spv/lib/spvchain.js +++ b/packages/dash-spv/lib/spvchain.js @@ -1,7 +1,7 @@ const BlockStore = require('./blockstore'); const config = require('../config/config'); const Consensus = require('./consensus'); -const utils = require('../lib/utils'); +const utils = require('./utils'); const SpvChain = class { constructor(chainType, confirms = 100, startBlock) { @@ -130,9 +130,9 @@ const SpvChain = class { /** @private */ isDuplicate(compareHash) { - return this.getAllBranches().map(branch => branch.map(node => node.hash)) - .concat(this.orphanBlocks.map(orphan => orphan.hash)) - .filter(hash => hash === compareHash).length > 0; + return this.getAllBranches().map((branch) => branch.map((node) => node.hash)) + .concat(this.orphanBlocks.map((orphan) => orphan.hash)) + .filter((hash) => hash === compareHash).length > 0; } /** @private */ @@ -254,7 +254,7 @@ const SpvChain = class { return blockInDB; } - return this.getLongestChain().filter(h => h.hash === hash)[0]; + return this.getLongestChain().filter((h) => h.hash === hash)[0]; }); } @@ -295,7 +295,7 @@ const SpvChain = class { return true; } } - const normalizedHeaders = headers.map(h => utils.normalizeHeader(h)); + const normalizedHeaders = headers.map((h) => utils.normalizeHeader(h)); const isOrphan = !SpvChain.isParentChild(normalizedHeaders[0], this.getTipHeader()); const allValid = normalizedHeaders.reduce( diff --git a/packages/dash-spv/test/data/headers.js b/packages/dash-spv/test/data/headers.js index d9e7bedc842..eb9cae85ee1 100644 --- a/packages/dash-spv/test/data/headers.js +++ b/packages/dash-spv/test/data/headers.js @@ -213,4 +213,4 @@ const headers = [ }, ]; -module.exports = headers.map(h => utils.normalizeHeader(h)); +module.exports = headers.map((h) => utils.normalizeHeader(h)); diff --git a/packages/dashmate/src/commands/group/stop.js b/packages/dashmate/src/commands/group/stop.js index 78a7033fe2b..a220ccea4a4 100644 --- a/packages/dashmate/src/commands/group/stop.js +++ b/packages/dashmate/src/commands/group/stop.js @@ -51,7 +51,7 @@ class GroupStopCommand extends GroupBaseCommand { try { await tasks.run({ isVerbose, - isForce + isForce, }); } catch (e) { throw new MuteOneLineError(e); diff --git a/packages/dashmate/src/docker/DockerCompose.js b/packages/dashmate/src/docker/DockerCompose.js index ec6c1c7ccb8..3872a9a408c 100644 --- a/packages/dashmate/src/docker/DockerCompose.js +++ b/packages/dashmate/src/docker/DockerCompose.js @@ -374,11 +374,11 @@ class DockerCompose { throw new Error(`Update Docker to version ${DockerCompose.DOCKER_MIN_VERSION} or higher`); } - let version + let version; // Check docker compose try { - ({out: version} = await dockerCompose.version()); + ({ out: version } = await dockerCompose.version()); } catch (e) { throw new Error('Docker Compose V2 is not available in your system'); } diff --git a/packages/platform-test-suite/lib/test/createFaucetClient.js b/packages/platform-test-suite/lib/test/createFaucetClient.js index 52e9fd3a089..99d94e70952 100644 --- a/packages/platform-test-suite/lib/test/createFaucetClient.js +++ b/packages/platform-test-suite/lib/test/createFaucetClient.js @@ -1,5 +1,4 @@ const Dash = require('dash'); -const path = require('path'); let storageAdapter;