[eslint] remove exception for no-var, fix violations
This commit is contained in:
@ -2,7 +2,6 @@
|
||||
extends: "@elastic/eslint-config-kibana"
|
||||
|
||||
rules:
|
||||
no-var: warn
|
||||
no-unused-vars: warn
|
||||
semi: warn
|
||||
one-var: warn
|
||||
|
||||
@ -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);
|
||||
},
|
||||
|
||||
@ -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])) {
|
||||
|
||||
2
src/lib/connectors/jquery.js
vendored
2
src/lib/connectors/jquery.js
vendored
@ -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')
|
||||
|
||||
@ -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)) {
|
||||
|
||||
@ -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();
|
||||
};
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -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)) {
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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({
|
||||
|
||||
Reference in New Issue
Block a user