fix eslint errors

This commit is contained in:
spalger
2016-05-19 07:52:01 -07:00
parent 939cca84c6
commit 68a8f712c8
47 changed files with 165 additions and 156 deletions

View File

@ -13,4 +13,4 @@ var server = require('http').createServer(app);
server.listen(function () {
var port = server.address().port;
process.connected ? process.send(port) : console.log(port);
});
});

View File

@ -55,7 +55,8 @@ module.exports = {
function doCreateClient(options, cb) {
if (typeof options === 'function') {
cb = options, options = {};
cb = options;
options = {};
}
var logConfig = {};

View File

@ -37,4 +37,4 @@ module.exports = function (branch) {
});
});
};
};

View File

@ -26,10 +26,10 @@ var ES_VERSION = null;
var versionExp = '((?:\\d+\\.){0,2}\\d+)(?:[\\.\\-]\\w+)?|';
// match all whitespace within a "regexp" match arg
var reWhitespace_RE = /\s+/g;
var reWhitespaceRE = /\s+/g;
// match all comments within a "regexp" match arg
var reComments_RE = /([\S\s]?)#[^\n]*\n/g;
var reCommentsRE = /([\S\s]?)#[^\n]*\n/g;
/**
* Regular Expression to extract a version number from a string
@ -356,34 +356,34 @@ YamlDoc.prototype = {
// resolve the catch arg to a value used for matching once the request is complete
switch (args.catch) {
case void 0:
catcher = null;
break;
case 'missing':
catcher = 404;
break;
case 'conflict':
catcher = 409;
break;
case 'forbidden':
catcher = 403;
break;
case 'request_timeout':
catcher = 408;
break;
case 'request':
catcher = /.*/;
break;
case 'param':
catcher = TypeError;
break;
default:
catcher = args.catch.match(/^\/(.*)\/$/);
if (catcher) {
catcher = new RegExp(catcher[1]);
} else {
return done(new TypeError('unsupported catch type ' + args.catch));
}
case void 0:
catcher = null;
break;
case 'missing':
catcher = 404;
break;
case 'conflict':
catcher = 409;
break;
case 'forbidden':
catcher = 403;
break;
case 'request_timeout':
catcher = 408;
break;
case 'request':
catcher = /.*/;
break;
case 'param':
catcher = TypeError;
break;
default:
catcher = args.catch.match(/^\/(.*)\/$/);
if (catcher) {
catcher = new RegExp(catcher[1]);
} else {
return done(new TypeError('unsupported catch type ' + args.catch));
}
}
delete args.catch;
@ -448,7 +448,7 @@ YamlDoc.prototype = {
}
var timeoutId;
var cb = _.bind(function (error, body) {
var cb = _.bind(function (error, body) {
this._last_requests_response = body;
clearTimeout(timeoutId);
@ -588,7 +588,7 @@ YamlDoc.prototype = {
// convert the matcher into a compatible string for building a regexp
maybeRE = match
// replace comments, but allow the # to be escaped like \#
.replace(reComments_RE, function (match, prevChar) {
.replace(reCommentsRE, function (match, prevChar) {
if (prevChar === '\\') {
return match;
} else {
@ -597,7 +597,7 @@ YamlDoc.prototype = {
})
// remove all whitespace from the expression, all meaningful
// whitespace is represented with \s
.replace(reWhitespace_RE, '');
.replace(reWhitespaceRE, '');
var startsWithSlash = maybeRE[0] === '/';
var endsWithSlash = maybeRE[maybeRE.length - 1] === '/';

View File

@ -19,7 +19,7 @@ function YamlFile(filename, docs) {
describe(filename, function () {
file.docs = _.map(docs, function (doc) {
doc = new YamlDoc(doc, file);
doc = new YamlDoc(doc, file);
if (doc.description === 'setup') {
beforeEach(/* doc */function (done) {
async.series(doc.getActionsRunners(), done);

View File

@ -1,4 +1,4 @@
/* eslint-disable */
//////////////
/// Extended version of:
/// https://github.com/philikon/MockHttpRequest/

View File

@ -57,15 +57,15 @@ var mockNock = module.exports = function (url) {
req.status = status;
req.body = body;
switch (typeof req.body) {
case 'string':
case 'number':
break;
default:
try {
req.body = req.body && JSON.stringify(req.body);
} catch (e) {
req.body = req.body;
}
case 'string':
case 'number':
break;
default:
try {
req.body = req.body && JSON.stringify(req.body);
} catch (e) {
req.body = req.body;
}
}
interceptors.push(req);
return mockNock(url);
@ -80,4 +80,4 @@ mockNock.done = function () {
if (interceptors.length) {
throw new Error('Some interceptors were not called: ' + JSON.stringify(interceptors));
}
};
};

View File

@ -32,4 +32,4 @@ util.inherits(MockIncommingMessage, Readable);
* }
* incom.push(null);
* });
*/
*/

View File

@ -75,4 +75,4 @@ if (Writable) {
// There is no shutdown() for files.
MockWritableStream.prototype.destroySoon = MockWritableStream.prototype.end;
}
}

View File

@ -82,4 +82,4 @@ describe('Angular esFactory', function () {
return prom;
});
});
});
});

View File

@ -17,4 +17,4 @@ describe('elasticsearch namespace', function () {
expect(client.transport).to.be.a(es.Transport);
client.close();
});
});
});

View File

@ -16,4 +16,4 @@ describe('jQuery.es namespace', function () {
expect(client.transport).to.be.a($.es.Transport);
client.close();
});
});
});

View File

@ -57,4 +57,4 @@ module.exports = function (makeLogger) {
});
}
});
};
};

View File

@ -1,5 +1,5 @@
var blanket = require("blanket")({
var blanket = require('blanket')({
pattern: require('path').join(__dirname, '../../src')
});
require('./index');
require('./index');

View File

@ -234,4 +234,4 @@ module.exports = function (makeLogger) {
expect(logger.write.callCount).to.eql(1);
});
});
};
};

View File

@ -3,4 +3,4 @@ require('bluebird').longStackTraces();
var specDir = __dirname + '/specs';
require('fs').readdirSync(specDir).forEach(function (file) {
require(specDir + '/' + file);
});
});

View File

@ -32,4 +32,4 @@ describe('Logger Abstract', function () {
require('../generic_logger_tests')(makeLogger);
});
});

View File

@ -68,7 +68,7 @@ describe('Client instances creation', function () {
}
util.inherits(NullStream, stream.Writable);
NullStream.prototype._write = function(/* chunk, encoding, next */) {
NullStream.prototype._write = function (/* chunk, encoding, next */) {
done();
};

View File

@ -195,7 +195,7 @@ describe('Client Action runner', function () {
it('rejects array', function (done) {
action({
one: ['one'],
two: [ 1304 ]
two: [1304]
}, function (err, params) {
expect(err).to.be.a(TypeError);
done();
@ -629,7 +629,7 @@ describe('Client Action runner', function () {
method: 'POST'
});
action({method: 'get'}, function (err, params) {
action({ method: 'get' }, function (err, params) {
expect(params.method).to.be('GET');
done();
});

View File

@ -17,11 +17,11 @@ describe('Connection Abstract', function () {
it('requires a valid host', function () {
expect(function () {
new ConnectionAbstract();
var conn = new ConnectionAbstract();
}).to.throwError(TypeError);
expect(function () {
new ConnectionAbstract({});
var conn = new ConnectionAbstract({});
}).to.throwError(TypeError);
});
@ -81,7 +81,6 @@ describe('Connection Abstract', function () {
it('calls it\'s own request method', function () {
var conn = new ConnectionAbstract(host);
var football = {};
stub(conn, 'request');
conn.ping();
expect(conn.request.callCount).to.eql(1);

View File

@ -1,6 +1,5 @@
var ConnectionPool = require('../../../src/lib/connection_pool');
var Host = require('../../../src/lib/host');
var errors = require('../../../src/lib/errors');
var ConnectionAbstract = require('../../../src/lib/connection');
var _ = require('lodash-migrate');
var EventEmitter = require('events').EventEmitter;
@ -121,7 +120,7 @@ describe('Connection Pool', function () {
});
it('detects if the selector is not async', function (done) {
pool.selector = function (list) {
pool.selector = function () {
expect(arguments.length).to.be(1);
};
@ -149,11 +148,11 @@ describe('Connection Pool', function () {
});
it('should catch errors in sync selectors', function (done) {
pool.selector = function (list) {
pool.selector = function () {
return JSON.notAMethod();
};
pool.select(function (err, selection) {
pool.select(function (err) {
expect(err).be.an(Error);
done();
});
@ -297,7 +296,8 @@ describe('Connection Pool', function () {
var result = pool.getConnections();
expect(result.length).to.be(1000);
expect(_.reduce(result, function (sum, num) {
return sum += num;
sum += num
return sum;
}, 0)).to.eql(499500);
});
});

View File

@ -32,7 +32,7 @@ describe('Host class', function () {
});
it('accepts a string for query', function () {
var host = new Host({ query: 'beep=boop'});
var host = new Host({ query: 'beep=boop' });
expect(host.query).to.eql({
beep: 'boop'
@ -157,14 +157,14 @@ describe('Host class', function () {
var host = new Host();
host.path = 'prefix';
expect(host.makeUrl({ path: '/this and that'}))
expect(host.makeUrl({ path: '/this and that' }))
.to.be('http://localhost:9200/prefix/this and that');
});
it('does not try to prevent double forward-slashes', function () {
var host = new Host({ path: 'prefix/' });
expect(host.makeUrl({ path: '/this and that'}))
expect(host.makeUrl({ path: '/this and that' }))
.to.be('http://localhost:9200/prefix//this and that');
});
@ -175,7 +175,7 @@ describe('Host class', function () {
host = new Host({ host: 'john', port: 80 });
expect(host.makeUrl()).to.be('http://john/');
host = new Host({ host: 'italy', path: '/pie', auth: 'user:pass'});
host = new Host({ host: 'italy', path: '/pie', auth: 'user:pass' });
expect(host.makeUrl()).to.be('http://italy:9200/pie');
});

View File

@ -324,7 +324,7 @@ describe('Http Connector', function () {
zlib.gzip(body, function (err, compressedBody) {
server
.get('/users/1')
.reply(200, compressedBody, {'Content-Encoding': 'gzip'});
.reply(200, compressedBody, { 'Content-Encoding': 'gzip' });
con.request({
method: 'GET',
@ -350,7 +350,7 @@ describe('Http Connector', function () {
zlib.deflate(body, function (err, compressedBody) {
server
.get('/users/1')
.reply(200, compressedBody, {'Content-Encoding': 'deflate'});
.reply(200, compressedBody, { 'Content-Encoding': 'deflate' });
con.request({
method: 'GET',
@ -371,7 +371,7 @@ describe('Http Connector', function () {
var body = 'blah';
server
.get('/users/1')
.reply(200, body, {'Content-Encoding': 'gzip'});
.reply(200, body, { 'Content-Encoding': 'gzip' });
con.request({
method: 'GET',

View File

@ -97,4 +97,4 @@ describe('JSON serializer', function () {
}).to.throwError();
});
});
});
});

View File

@ -141,7 +141,7 @@ describe('Log class', function () {
log.emit = function (eventName) {
call = {
event : eventName,
event: eventName,
args: Array.prototype.slice.call(arguments, 1)
};
};
@ -221,7 +221,7 @@ describe('Log class', function () {
});
it('accepts an array of output config objects', function () {
var log = new Log({ log: [{ level: 'error' }, { level: 'trace'}] });
var log = new Log({ log: [{ level: 'error' }, { level: 'trace' }] });
expect(log.listenerCount('error')).to.eql(2);
expect(log.listenerCount('warning')).to.eql(1);
expect(log.listenerCount('info')).to.eql(1);

View File

@ -61,7 +61,6 @@ describe('Nodes to host callback', function () {
});
it('ignores hosts that don\'t have an http_host property', function () {
var hosts = callback({
node_id: {
@ -74,7 +73,7 @@ describe('Nodes to host callback', function () {
it('throws an error when the host property is not formatted properly', function () {
expect(function () {
var hosts = callback({
callback({
node_id: {
http_address: 'not actually an http host'
}

View File

@ -1,7 +1,6 @@
var Transport = require('../../../src/lib/transport');
var Host = require('../../../src/lib/host');
var errors = require('../../../src/lib/errors');
var Promise = require('bluebird');
var sinon = require('sinon');
var expect = require('expect.js');
@ -354,10 +353,10 @@ describe('Transport Class', function () {
});
it('logs an error if nodes to host throws one', function (done) {
trans.nodesToHostCallback = function (nodes) {
trans.nodesToHostCallback = function () {
throw new Error('I failed');
};
trans.log.error = function (err) {
trans.log.error = function () {
done();
};
trans.sniff();
@ -408,7 +407,7 @@ describe('Transport Class', function () {
});
});
it('passed back the full server response', function (done) {
trans.sniff(function (err, resp, status) {
trans.sniff(function (err, resp) {
expect(resp.ok).to.eql(true);
expect(resp.cluster_name).to.eql('clustername');
done();
@ -501,7 +500,7 @@ describe('Transport Class', function () {
});
var conn = getConnection(trans);
var body = [
{ _id: 'simple body'},
{ _id: 'simple body' },
{ name: 'ഢധയമബ' }
];
@ -526,7 +525,7 @@ describe('Transport Class', function () {
var trans = new Transport({
hosts: 'localhost'
});
var conn = getConnection(trans);
getConnection(trans);
var body = {
_id: 'circular body'
};
@ -560,7 +559,7 @@ describe('Transport Class', function () {
}
});
trans.request({}, function (err, body, status) {
trans.request({}, function (err) {
expect(err.message).to.eql('I am broken');
});
});
@ -574,7 +573,7 @@ describe('Transport Class', function () {
}
});
trans.request({}, function (err, body, status) {
trans.request({}, function (err) {
expect(err.message).to.eql('I am broken');
});
});
@ -638,7 +637,6 @@ describe('Transport Class', function () {
});
describe('return value', function () {
it('returns an object with an abort() method when a callback is sent', function () {
var tran = new Transport();
@ -681,7 +679,7 @@ describe('Transport Class', function () {
expect(process.domain).to.be(null);
var tran = new Transport();
shortCircuitRequest(tran);
tran.request({}, function(err, result, status) {
tran.request({}, function () {
expect(process.domain).to.be(null);
});
});
@ -689,12 +687,12 @@ describe('Transport Class', function () {
it('binds the callback to the correct domain', function () {
expect(process.domain).to.be(null);
var domain = require('domain').create();
domain.run(function() {
domain.run(function () {
var tran = new Transport();
shortCircuitRequest(tran);
expect(process.domain).not.to.be(null);
var startingDomain = process.domain
tran.request({}, function(err, result, status) {
tran.request({}, function () {
expect(process.domain).not.to.be(null);
expect(process.domain).to.be(startingDomain);
process.domain.exit();
@ -758,7 +756,6 @@ describe('Transport Class', function () {
var clock = sinon.useFakeTimers('setTimeout', 'clearTimeout');
stub.autoRelease(clock);
var tran = new Transport({});
var err;
var prom = tran.request({});
// disregard promise, prevent bluebird's warnings
@ -776,7 +773,6 @@ describe('Transport Class', function () {
var tran = new Transport({
requestTimeout: 5000
});
var err;
var prom = tran.request({});
// disregard promise, prevent bluebird's warnings
@ -799,7 +795,7 @@ describe('Transport Class', function () {
tran.request({
requestTimeout: falsy
}, function (_err) {});
}, function () {});
expect(_.size(clock.timers)).to.eql(0);
});

View File

@ -32,7 +32,7 @@ describe('Utils', function () {
}
},
function (thing, name) {
describe('#isArrayOf' + name, function (test) {
describe('#isArrayOf' + name, function () {
it('likes arrays of ' + name, function () {
expect(_['isArrayOf' + name + 's'](thing.is)).to.be(true);
});
@ -54,7 +54,6 @@ describe('Utils', function () {
expect(_.isNumeric(0)).to.be(true);
expect(_.isNumeric(32)).to.be(true);
expect(_.isNumeric('040')).to.be(true);
expect(_.isNumeric(0144)).to.be(true);
expect(_.isNumeric('0xFF')).to.be(true);
expect(_.isNumeric(0xFFF)).to.be(true);
});
@ -196,7 +195,7 @@ describe('Utils', function () {
});
it('sorta kinda works on objects', function () {
expect(_.toLowerString({a: 'thing'})).to.eql('[object object]');
expect(_.toLowerString({ a: 'thing' })).to.eql('[object object]');
});
});
@ -216,7 +215,7 @@ describe('Utils', function () {
});
it('sorta kinda works on objects', function () {
expect(_.toUpperString({a: 'thing'})).to.eql('[OBJECT OBJECT]');
expect(_.toUpperString({ a: 'thing' })).to.eql('[OBJECT OBJECT]');
});
});
@ -268,7 +267,7 @@ describe('Utils', function () {
foo: ['bax', 'boz']
}
};
_.deepMerge(obj, { bax: { foo: ['poo'] }});
_.deepMerge(obj, { bax: { foo: ['poo'] } });
expect(obj.bax.foo).to.have.length(3);
});
@ -282,7 +281,7 @@ describe('Utils', function () {
expect(out).to.not.be(inp);
});
it('accepts a primitive value and calls the the transform function', function (done) {
var out = _.createArray('str', function (val) {
_.createArray('str', function (val) {
expect(val).to.be('str');
done();
});

View File

@ -19,4 +19,4 @@ describe('Yaml Test Reader', function () {
expect(compare('0.90 - 1.2', '1.4')).to.be(false);
});
});
});
});

View File

@ -18,4 +18,4 @@ exports.make = function () {
};
return stubber;
};
};

View File

@ -9,4 +9,4 @@ module.exports = function expectSubObject(obj, subObj) {
expect(obj).property(prop, val);
}
});
};
};

View File

@ -22,7 +22,7 @@ var log = (function () {
}
locked(str);
};
})();
}());
var integration = _.find(process.argv, function (arg) { return arg.indexOf('test/integration') > -1; });
var unit = _.find(process.argv, function (arg) { return arg.indexOf('test/unit') > -1; });
@ -86,7 +86,7 @@ function JenkinsReporter(runner) {
stack.shift();
});
runner.on('fail', function (test, err) {
runner.on('fail', function (test) {
if ('hook' === test.type) {
runner.emit('test end', test);
}

View File

@ -41,7 +41,7 @@ function makeJUnitXml(runnerName, testDetails) {
timestamp: moment(suiteInfo.start).toJSON(),
hostname: 'localhost',
tests: (suiteInfo.results && suiteInfo.results.length) || 0,
failures: _.where(suiteInfo.results, {pass: false}).length,
failures: _.where(suiteInfo.results, { pass: false }).length,
errors: 0,
time: suiteInfo.time / 1000
});
@ -89,7 +89,7 @@ function makeJUnitXml(runnerName, testDetails) {
giveOutput(suite, suiteInfo);
});
return suites.toString({ pretty: true});
return suites.toString({ pretty: true });
}
function giveOutput(el, info) {
@ -103,4 +103,4 @@ function giveOutput(el, info) {
if (err) {
el.ele('system-err', {}).cdata(chalk.stripColor(err));
}
}
}

View File

@ -1,3 +1,4 @@
/* eslint-disable import/no-unresolved */
var express = require('express');
var http = require('http');
var fs = require('fs');
@ -31,6 +32,8 @@ testFiles.build = fs.readdirSync(browserBuildsDir)
if (file.substr(-3) === '.js') {
return browserBuildsDir + '/' + file;
}
return null
})
.filter(Boolean);
@ -73,7 +76,7 @@ function bundleTests(name) {
// create a route that just rends a specific file (like a symlink or something)
function sendFile(file) {
return function (req, res, next) {
return function (req, res) {
res.sendfile(file);
};
}
@ -111,4 +114,4 @@ app
http.createServer(app).listen(8000, function () {
console.log('listening on port 8000');
});
});

View File

@ -3,4 +3,4 @@
module.exports = JSON.parse(new Buffer(
'eyJ1c2VyIjoiZWxhc3RpY3NlYXJjaC1qcyIsImtleSI6IjI0ZjQ5ZTA3LWQ4MmYtNDA2Ny04NTRlLWQ4MTVlYmQxNWU0NiJ9',
'base64'
).toString('utf8'));
).toString('utf8'));