From df651865c164762fa75d208f498247c52e27e0ee Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Thu, 30 Aug 2018 14:53:04 +0100 Subject: [PATCH] Enable no-else-return --- .eslintrc.json | 2 +- lib/core/config.js | 3 +-- lib/core/plugin.js | 3 +-- lib/modules/blockchain_process/blockchain.js | 3 +-- lib/modules/code_generator/index.js | 16 +++++++--------- lib/modules/deployment/contract_deployer.js | 3 +-- lib/modules/whisper/index.js | 3 +-- lib/utils/utils.js | 3 +-- 8 files changed, 14 insertions(+), 22 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index d666951e9..547565ec6 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -113,7 +113,7 @@ "no-continue": "off", "no-div-regex": "error", "no-duplicate-imports": "error", - "no-else-return": "off", + "no-else-return": 2, "no-empty-function": "off", "no-eq-null": "error", "no-eval": "off", diff --git a/lib/core/config.js b/lib/core/config.js index eacff5268..3b7a13e07 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -160,9 +160,8 @@ Config.prototype._mergeConfig = function(configFilePath, defaultConfig, env, ena if (env) { return utils.recursiveMerge(configObject['default'] || {}, configObject[env]); - } else { - return configObject; } + return configObject; }; Config.prototype._getFileOrOject = function(object, filePath, property) { diff --git a/lib/core/plugin.js b/lib/core/plugin.js index 80e14ec05..38aadbc60 100644 --- a/lib/core/plugin.js +++ b/lib/core/plugin.js @@ -223,9 +223,8 @@ Plugin.prototype.runPipeline = function(args) { var shouldRunPipeline = utils.fileMatchesPattern(pipeline.matcthingFiles, args.targetFile); if (shouldRunPipeline) { return pipeline.cb.call(this, args); - } else { - return args.source; } + return args.source; }; module.exports = Plugin; diff --git a/lib/modules/blockchain_process/blockchain.js b/lib/modules/blockchain_process/blockchain.js index 65bb92e44..7f8ecaf2b 100644 --- a/lib/modules/blockchain_process/blockchain.js +++ b/lib/modules/blockchain_process/blockchain.js @@ -313,9 +313,8 @@ var BlockchainClient = function(blockchainConfig, client, env, onReadyCallback, // TODO add other clients at some point if (client === 'geth') { return new Blockchain({blockchainConfig, client: GethCommands, env, isDev, onReadyCallback, onExitCallback}); - } else { - throw new Error('unknown client'); } + throw new Error('unknown client'); }; module.exports = BlockchainClient; diff --git a/lib/modules/code_generator/index.js b/lib/modules/code_generator/index.js index 8c13819b0..699177895 100644 --- a/lib/modules/code_generator/index.js +++ b/lib/modules/code_generator/index.js @@ -117,7 +117,7 @@ class CodeGenerator { result += Templates.main_context(); result += Templates.load_manager(); result += Templates.define_when_env_loaded(); - + if (self.blockchainConfig === {} || self.blockchainConfig.enabled === false) { return result; } @@ -302,11 +302,10 @@ class CodeGenerator { self.events.request("version:get:web3", function(web3Version) { if (web3Version === "1.0.0-beta") { return next(null, fs.embarkPath("node_modules/web3")); - } else { - self.events.request("version:getPackageLocation", "web3", web3Version, function(err, location) { - return next(null, fs.dappPath(location)); - }); } + self.events.request("version:getPackageLocation", "web3", web3Version, function(err, location) { + return next(null, fs.dappPath(location)); + }); }); }, function getImports(web3Location, next) { @@ -362,11 +361,10 @@ class CodeGenerator { self.events.request("version:get:web3", function(web3Version) { if (web3Version === "1.0.0-beta") { return next(null, utils.joinPath(fs.embarkPath("node_modules/web3"))); - } else { - self.events.request("version:getPackageLocation", "web3", web3Version, function(err, location) { - return next(null, fs.dappPath(location)); - }); } + self.events.request("version:getPackageLocation", "web3", web3Version, function(err, location) { + return next(null, fs.dappPath(location)); + }); }); }, function getImports(web3Location, next) { diff --git a/lib/modules/deployment/contract_deployer.js b/lib/modules/deployment/contract_deployer.js index de935fa73..3e352a35f 100644 --- a/lib/modules/deployment/contract_deployer.js +++ b/lib/modules/deployment/contract_deployer.js @@ -235,9 +235,8 @@ class ContractDeployer { } catch(e) { if (e.message.indexOf('Invalid number of parameters for "undefined"') >= 0) { return next(new Error(__("attempted to deploy %s without specifying parameters", contract.className))); - } else { - return next(new Error(e)); } + return next(new Error(e)); } next(); }, diff --git a/lib/modules/whisper/index.js b/lib/modules/whisper/index.js index 7b4a6dfb1..b7471f8d9 100644 --- a/lib/modules/whisper/index.js +++ b/lib/modules/whisper/index.js @@ -38,9 +38,8 @@ class Whisper { self.web3.shh.getVersion(function (err, version) { if (err || version == "2") { return cb({name: 'Whisper', status: 'off'}); - } else { - return cb({name: 'Whisper (version ' + version + ')', status: 'on'}); } + return cb({name: 'Whisper (version ' + version + ')', status: 'on'}); }); }); } diff --git a/lib/utils/utils.js b/lib/utils/utils.js index 808a45fea..7ccbc620a 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -277,9 +277,8 @@ function isValidDomain(domain) { function isValidEthDomain(ethDomain) { if (!isValidDomain(ethDomain)) { return false; - } else { - return ethDomain.substring(ethDomain.lastIndexOf('.'), ethDomain.length) === '.eth'; } + return ethDomain.substring(ethDomain.lastIndexOf('.'), ethDomain.length) === '.eth'; } function decodeParams(typesArray, hexString) {