[eslint] remove exception for no-var, fix violations

This commit is contained in:
spalger
2017-06-14 18:56:26 -07:00
parent 3d75c6ff0f
commit 058569d4f8
11 changed files with 21 additions and 17 deletions

View File

@ -2,7 +2,6 @@
extends: "@elastic/eslint-config-kibana"
rules:
no-var: warn
no-unused-vars: warn
semi: warn
one-var: warn

View File

@ -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);
},

View File

@ -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;
@ -349,6 +349,7 @@ function exec(transport, spec, params, cb) {
}
}
}
}
for (i = 0; i < spec.requireParamKeys.length; i++) {
if (!query.hasOwnProperty(spec.requireParamKeys[i])) {

View File

@ -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')

View File

@ -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)) {

View File

@ -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();
};

View File

@ -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;
@ -357,6 +357,7 @@ _.funcEnum = function (config, name, opts, def) {
}
throw new TypeError(err);
}
}
};
/**

View File

@ -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)) {

View File

@ -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';

View File

@ -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);

View File

@ -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({