diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 1d2b8ec67..a13d74756 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,7 +2,6 @@ extends: "@elastic/eslint-config-kibana" rules: - no-var: warn no-unused-vars: warn semi: warn one-var: warn diff --git a/grunt/utils.js b/grunt/utils.js index 32b4b88dc..8a05e1473 100644 --- a/grunt/utils.js +++ b/grunt/utils.js @@ -6,7 +6,7 @@ const stable = pkg.config.supported_es_branches; const unstable = pkg.config.unstable_es_branches; const branches = [].concat(stable, unstable); -var utils = { +const utils = { branchSuffix: function (branch) { return branch === utils.branches._default ? '' : '_' + _.snakeCase(branch); }, diff --git a/src/lib/client_action.js b/src/lib/client_action.js index 975d7bdfe..d54c1e3e8 100644 --- a/src/lib/client_action.js +++ b/src/lib/client_action.js @@ -327,8 +327,8 @@ function exec(transport, spec, params, cb) { case 'method': request.method = _.toUpperString(params[key]); break; - default: - var paramSpec = spec.params[key]; + default: { + const paramSpec = spec.params[key]; if (paramSpec) { // param keys don't always match the param name, in those cases it's stored in the param def as "name" paramSpec.name = paramSpec.name || key; @@ -346,6 +346,7 @@ function exec(transport, spec, params, cb) { } else { query[key] = params[key]; } + } } } } diff --git a/src/lib/connectors/jquery.js b/src/lib/connectors/jquery.js index a61da5c38..51b4f3cd3 100644 --- a/src/lib/connectors/jquery.js +++ b/src/lib/connectors/jquery.js @@ -26,7 +26,7 @@ JqueryConnector.prototype.request = function (params, cb) { done: cb }; - var jqXHR = jQuery.ajax(ajax) + const jqXHR = jQuery.ajax(ajax) .done(function (data) { cb(null, data, jqXHR.statusCode(), { 'content-type': jqXHR.getResponseHeader('content-type') diff --git a/src/lib/log.js b/src/lib/log.js index fc4f4a511..6c53c8220 100644 --- a/src/lib/log.js +++ b/src/lib/log.js @@ -150,11 +150,12 @@ Log.levels = [ */ Log.parseLevels = function (input) { switch (typeof input) { - case 'string': - var i = _.indexOf(Log.levels, input); + case 'string': { + const i = _.indexOf(Log.levels, input); if (i >= 0) { return Log.levels.slice(0, i + 1); } + } /* fall through */ case 'object': if (_.isArray(input)) { diff --git a/src/lib/transport/sniff_on_connection_fault.js b/src/lib/transport/sniff_on_connection_fault.js index 06ce3acdd..c775ce4af 100644 --- a/src/lib/transport/sniff_on_connection_fault.js +++ b/src/lib/transport/sniff_on_connection_fault.js @@ -17,7 +17,7 @@ module.exports = function setupSniffOnConnectionFault(transport) { // do the actual sniff, if the sniff is unable to // connect to a node this function will be called again by the connectionPool - var work = function () { + const work = function () { work.timerId = transport._timeout(work.timerId); transport.sniff(); }; diff --git a/src/lib/utils.js b/src/lib/utils.js index e1303a5e4..02ab41293 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -343,8 +343,8 @@ _.funcEnum = function (config, name, opts, def) { return opts[val]; } /* falls through */ - default: - var err = 'Invalid ' + name + ' "' + val + '", expected a function'; + default: { + let err = 'Invalid ' + name + ' "' + val + '", expected a function'; switch (_.size(opts)) { case 0: break; @@ -356,6 +356,7 @@ _.funcEnum = function (config, name, opts, def) { break; } throw new TypeError(err); + } } }; diff --git a/test/integration/yaml_suite/yaml_doc.js b/test/integration/yaml_suite/yaml_doc.js index 237c08f51..2a4087966 100644 --- a/test/integration/yaml_suite/yaml_doc.js +++ b/test/integration/yaml_suite/yaml_doc.js @@ -403,11 +403,11 @@ YamlDoc.prototype = { } const client = clientManager.get(); - var clientActionName = _.map(action.split('.'), _.camelCase).join('.'); + const clientActionName = _.map(action.split('.'), _.camelCase).join('.'); const clientAction = this.get(clientActionName, client); _.assign(inputParams, args[action]); - var params = _.transform(inputParams, _.bind(function (params, val, name) { + const params = _.transform(inputParams, _.bind(function (params, val, name) { const camelName = _.camelCase(name); // search through the params and url peices to find this param name @@ -426,7 +426,7 @@ YamlDoc.prototype = { } // for ercursively traversing the params to replace '$stashed' vars - var transformObject = function (vals, val, i) { + const transformObject = function (vals, val, i) { if (_.isString(val)) { val = (val[0] === '$') ? this.get(val) : val; } else if (_.isPlainObject(val) || _.isArray(val)) { diff --git a/test/mocks/browser_server.js b/test/mocks/browser_server.js index 7e9e66ded..ba8828266 100644 --- a/test/mocks/browser_server.js +++ b/test/mocks/browser_server.js @@ -30,7 +30,7 @@ const server = new XhrServer(function (request) { server.start(); -var mockNock = module.exports = function (url) { +const mockNock = module.exports = function (url) { const parsedUrl = parseUrl(url); const req = { method: 'GET', @@ -38,7 +38,7 @@ var mockNock = module.exports = function (url) { times: 1 }; - var modifyReq = { + const modifyReq = { get: function (path) { req.path = path; req.method = 'GET'; diff --git a/test/unit/specs/http_connector.js b/test/unit/specs/http_connector.js index c9b66acc3..737ed9998 100644 --- a/test/unit/specs/http_connector.js +++ b/test/unit/specs/http_connector.js @@ -481,12 +481,13 @@ describe('Http Connector', function () { const fixture = _.partial(path.join, __dirname, '../../fixtures'); let timeout; // start the timeout once we hear back from the client + let client; // eslint-disable-line prefer-const const server = cp.fork(fixture('keepalive_server.js')) .on('message', function (port) { client.send(port); }); - var client = cp.fork(fixture('keepalive.js')) + client = cp.fork(fixture('keepalive.js')) .on('message', function (output) { expect(output).to.have.property('remaining', 0); expect(output).to.have.property('timeouts', 0); diff --git a/test/unit/specs/transport.js b/test/unit/specs/transport.js index 11351b522..e75d224e9 100644 --- a/test/unit/specs/transport.js +++ b/test/unit/specs/transport.js @@ -722,6 +722,7 @@ describe('Transport Class', function () { }); const con = getConnection(tran); + let ret; // eslint-disable-line prefer-const stub(con, 'request', function () { process.nextTick(function () { ret.abort(); @@ -731,7 +732,7 @@ describe('Transport Class', function () { }; }); - var ret = tran.request({}); + ret = tran.request({}); }); it('ignores the response from the connection when the connector does not support aborting', function (done) { const tran = new Transport({