From 68a8f712c8b3d10bf8a12da90bdafd55dad1a6d9 Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 19 May 2016 07:52:01 -0700 Subject: [PATCH] fix eslint errors --- .eslintignore | 3 + package.json | 3 +- scripts/Version.js | 4 +- scripts/_spawn.js | 2 +- scripts/ci.js | 48 ++++++++------ scripts/generate/index.js | 4 +- scripts/generate/js_api.js | 2 +- scripts/generate/overrides.js | 2 + scripts/generate/templates/index.js | 22 +++---- scripts/generate/yaml_tests.js | 2 +- scripts/release/bower.js | 2 +- src/elasticsearch.jquery.js | 2 +- test/fixtures/keepalive_server.js | 2 +- test/integration/yaml_suite/client_manager.js | 3 +- test/integration/yaml_suite/run.js | 2 +- test/integration/yaml_suite/yaml_doc.js | 66 +++++++++---------- test/integration/yaml_suite/yaml_file.js | 2 +- test/mocks/browser_http.js | 2 +- test/mocks/browser_server.js | 20 +++--- test/mocks/incomming_message.js | 2 +- test/mocks/writable_stream.js | 2 +- test/unit/browser_builds/angular.js | 2 +- test/unit/browser_builds/generic.js | 2 +- test/unit/browser_builds/jquery.js | 2 +- test/unit/buffer_flush_tests.js | 2 +- test/unit/coverage.js | 4 +- test/unit/generic_logger_tests.js | 2 +- test/unit/index.js | 2 +- test/unit/specs/abstract_logger.js | 2 +- test/unit/specs/client.js | 2 +- test/unit/specs/client_action.js | 4 +- test/unit/specs/connection_abstract.js | 5 +- test/unit/specs/connection_pool.js | 10 +-- test/unit/specs/host.js | 8 +-- test/unit/specs/http_connector.js | 6 +- test/unit/specs/json_serializer.js | 2 +- test/unit/specs/log.js | 4 +- test/unit/specs/nodes_to_host_callback.js | 3 +- test/unit/specs/transport.js | 26 ++++---- test/unit/specs/utils.js | 11 ++-- test/unit/specs/yaml_test_reader.js | 2 +- test/utils/auto_release_stub.js | 2 +- test/utils/expect_sub_object.js | 2 +- test/utils/jenkins-reporter.js | 4 +- test/utils/make_j_unit_xml.js | 6 +- test/utils/server.js | 7 +- test/utils/slk.js | 2 +- 47 files changed, 165 insertions(+), 156 deletions(-) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..1fa83a552 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +src/_* +src/bower_es_js +src/lib/apis diff --git a/package.json b/package.json index e9a7f2c56..d671ab364 100644 --- a/package.json +++ b/package.json @@ -107,7 +107,8 @@ "scripts": { "test": "grunt test", "generate": "node scripts/generate", - "grunt": "grunt" + "grunt": "grunt", + "eslint": "eslint src scripts test" }, "engines": { "node": ">=0.8" diff --git a/scripts/Version.js b/scripts/Version.js index abaf6bed9..d7f08b029 100644 --- a/scripts/Version.js +++ b/scripts/Version.js @@ -1,6 +1,6 @@ var _ = require('lodash-migrate'); -var package = require('../package.json'); -var branches = package.config.supported_es_branches; +var pkg = require('../package.json'); +var branches = pkg.config.supported_es_branches; var semver = require('semver'); var maxMinorVersion = function (majorV) { diff --git a/scripts/_spawn.js b/scripts/_spawn.js index d5ed4e1e7..3efdd7d99 100644 --- a/scripts/_spawn.js +++ b/scripts/_spawn.js @@ -60,4 +60,4 @@ function _spawn(cmd, args, opts, cb) { _spawn.exec = function (cmd, opts, cb) { return _spawn('/bin/sh', ['-c', cmd], opts, cb); -}; \ No newline at end of file +}; diff --git a/scripts/ci.js b/scripts/ci.js index cf1fa7760..b1e35c405 100644 --- a/scripts/ci.js +++ b/scripts/ci.js @@ -23,7 +23,7 @@ var through2 = require('through2'); var map = require('through2-map'); var split = require('split'); var join = require('path').join; -var child_process = require('child_process'); +var cp = require('child_process'); var chalk = require('chalk'); var format = require('util').format; @@ -59,10 +59,10 @@ task('SAUCE_LABS', false, function () { return new Promise(function (resolve, reject) { // build the clients and start the server, once the server is ready call trySaucelabs() var serverTasks = ['browser_clients:build', 'run:browser_test_server:keepalive']; - spawn(GRUNT, serverTasks, function (cp) { + spawn(GRUNT, serverTasks, function (proc) { var toLines = split(); - cp.stdout + proc.stdout .pipe(toLines) .pipe(through2(function (line, enc, cb) { cb(); @@ -71,11 +71,11 @@ task('SAUCE_LABS', false, function () { trySaucelabs() - .finally(function () { cp && cp.kill(); }) + .finally(function () { if (proc) proc.kill(); }) .then(resolve, reject); - cp.on('exit', function () { cp = null; }); - cp.stdout.unpipe(toLines); + proc.on('exit', function () { proc = null; }); + proc.stdout.unpipe(toLines); toLines.end(); })); }) @@ -132,25 +132,30 @@ task('CHECK_COVERAGE', false, function () { execTask('SETUP', function () { return Promise.try(function readVersion() { if (!ENV.ES_V) { - if (ENV.ES_RELEASE) + if (ENV.ES_RELEASE) { return ['v' + ENV.ES_RELEASE, ENV.ES_RELEASE]; + } - if (ENV.ES_REF) + if (ENV.ES_REF) { return [ENV.ES_REF, null]; + } } var match; - if (match = ENV.ES_V.match(/^(.*)_nightly$/)) + if (match = ENV.ES_V.match(/^(.*)_nightly$/)) { return [match[1], null]; + } - if (/^(?:1\.\d+|0\.90)\..*$/.test(ENV.ES_V)) + if (/^(?:1\.\d+|0\.90)\..*$/.test(ENV.ES_V)) { return ['v' + ENV.ES_V, ENV.ES_V]; + } throw new Error('unable to parse ES_V ' + ENV.ES_V); }) .then(function readOtherConf(ver) { - if (!ver) + if (!ver) { throw new Error('Unable to run the ci script without at least an ES_REF or ES_RELEASE environment var.'); + } log('ES_PORT:', ENV.ES_PORT = parseInt(ENV.ES_PORT || 9400, 10)); log('ES_HOST:', ENV.ES_HOST = ENV.ES_HOST || 'localhost'); @@ -162,8 +167,9 @@ execTask('SETUP', function () { else delete ENV.ES_RELEASE; }) .then(function readTasks() { - if (!ENV.RUN) + if (!ENV.RUN) { return _.where(TASKS, { default: true }); + } return ENV.RUN .split(',') @@ -196,7 +202,7 @@ execTask('SETUP', function () { }); }); -/****** +/** **** * utils ******/ function log() { @@ -275,25 +281,25 @@ function execTask(name, task) { function spawn(file, args, block) { return new Promise(function (resolve, reject) { - var cp = child_process.spawn(file, args, { + var proc = cp.spawn(file, args, { cwd: ROOT, env: ENV, stdio: [0, 'pipe', 'pipe'] }); - cp.stdout.pipe(taskOut, { end: false }); - cp.stderr.pipe(taskOut, { end: false }); + proc.stdout.pipe(taskOut, { end: false }); + proc.stderr.pipe(taskOut, { end: false }); var stdout = ''; - cp.stdout + proc.stdout .pipe(through2(function (chunk, enc, cb) { stdout += chunk; cb(); })); - block && block(cp); + if (block) block(proc); - cp.on('exit', function (code) { + proc.on('exit', function (code) { if (code > 0) { reject(new Error('non-zero exit code: ' + code)); } else { @@ -301,13 +307,13 @@ function spawn(file, args, block) { } }); - cp.on('error', function (origErr) { + proc.on('error', function (origErr) { reject(new Error('Unable to execute "' + file + ' ' + args.join(' ') + '": ' + origErr.message)); }); }); } -function node(/*args... */) { +function node(/* args... */) { return spawn( process.execPath, _.toArray(arguments) diff --git a/scripts/generate/index.js b/scripts/generate/index.js index 937039fa2..742b947b8 100644 --- a/scripts/generate/index.js +++ b/scripts/generate/index.js @@ -1,4 +1,4 @@ -/*jshint curly: false */ +/* jshint curly: false */ var async = require('async'); var fs = require('fs'); var spawn = require('../_spawn'); @@ -206,7 +206,7 @@ function createArchive(branch) { spawnStep('mkdir', [dir], paths.root), spawnStep('git', ['archive', '--format', 'tar', '--output', tarball, branch, specPathInRepo], paths.esSrc), spawnStep('tar', ['-x', '-f', tarball, '-C', dir, '--strip-components', subDirCount]), - spawnStep('rm', [tarball]) + spawnStep('rm', [tarball]) ], done); }; } diff --git a/scripts/generate/js_api.js b/scripts/generate/js_api.js index b7fe299ff..f374b003f 100644 --- a/scripts/generate/js_api.js +++ b/scripts/generate/js_api.js @@ -171,7 +171,7 @@ module.exports = function (branch, done) { ); } - function __puke__transformSpec(spec) { + function __puke__transformSpec(spec) { // eslint-disable-line var actions = []; // itterate all of the specs within the file, should only be one diff --git a/scripts/generate/overrides.js b/scripts/generate/overrides.js index 9dabbd4c3..f3ee815eb 100644 --- a/scripts/generate/overrides.js +++ b/scripts/generate/overrides.js @@ -187,6 +187,7 @@ module.exports = [ version: '>=1.6.0', // strange indentation makes pretty api files +/* eslint-disable */ clientActionModifier: function (spec) { return require('../utils').merge(spec, { @@ -198,6 +199,7 @@ function (spec) { } }); } +/* eslint-enable */ }, { diff --git a/scripts/generate/templates/index.js b/scripts/generate/templates/index.js index 21e8c872a..0f74000af 100644 --- a/scripts/generate/templates/index.js +++ b/scripts/generate/templates/index.js @@ -15,7 +15,7 @@ var path = require('path'); */ function stringify(thing, pretty) { return (pretty ? JSON.stringify(thing, null, ' ') : JSON.stringify(thing)) - .replace(/\'/g, '\\\'') + .replace(/'/g, '\\\'') .replace(/\\?"/g, function (quote) { // replace external (unescaped) double quotes with single quotes return quote === '\\"' ? '"' : '\''; @@ -70,16 +70,16 @@ var templateGlobals = { paramType: function (type) { switch (type && type.toLowerCase ? type.toLowerCase() : 'any') { - case 'time': - return 'Date, Number'; - case 'any': - return 'Anything'; - case 'enum': - return 'String'; - case 'list': - return 'String, String[], Boolean'; - default: - return _.ucfirst(type); + case 'time': + return 'Date, Number'; + case 'any': + return 'Anything'; + case 'enum': + return 'String'; + case 'list': + return 'String, String[], Boolean'; + default: + return _.ucfirst(type); } }, diff --git a/scripts/generate/yaml_tests.js b/scripts/generate/yaml_tests.js index eed151ee1..a3cdcda17 100644 --- a/scripts/generate/yaml_tests.js +++ b/scripts/generate/yaml_tests.js @@ -55,4 +55,4 @@ module.exports = function (branch, done) { console.log(chalk.white.bold('wrote') + ' YAML index to', file); done(); } -}; \ No newline at end of file +}; diff --git a/scripts/release/bower.js b/scripts/release/bower.js index 3ada9c4e3..e05b6432a 100644 --- a/scripts/release/bower.js +++ b/scripts/release/bower.js @@ -42,4 +42,4 @@ async.series([ console.log('Error: ', err.message ? err.message : err); } } -}); \ No newline at end of file +}); diff --git a/src/elasticsearch.jquery.js b/src/elasticsearch.jquery.js index 6d6cce7f9..740a2ee1f 100644 --- a/src/elasticsearch.jquery.js +++ b/src/elasticsearch.jquery.js @@ -19,4 +19,4 @@ return new es.Client(config); }; -}(jQuery)); \ No newline at end of file +}(jQuery)); diff --git a/test/fixtures/keepalive_server.js b/test/fixtures/keepalive_server.js index 7f92981d1..e0d365878 100644 --- a/test/fixtures/keepalive_server.js +++ b/test/fixtures/keepalive_server.js @@ -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); -}); \ No newline at end of file +}); diff --git a/test/integration/yaml_suite/client_manager.js b/test/integration/yaml_suite/client_manager.js index 75437f360..4cc481a7b 100644 --- a/test/integration/yaml_suite/client_manager.js +++ b/test/integration/yaml_suite/client_manager.js @@ -55,7 +55,8 @@ module.exports = { function doCreateClient(options, cb) { if (typeof options === 'function') { - cb = options, options = {}; + cb = options; + options = {}; } var logConfig = {}; diff --git a/test/integration/yaml_suite/run.js b/test/integration/yaml_suite/run.js index 1ee63484c..9ec43a994 100644 --- a/test/integration/yaml_suite/run.js +++ b/test/integration/yaml_suite/run.js @@ -37,4 +37,4 @@ module.exports = function (branch) { }); }); -}; \ No newline at end of file +}; diff --git a/test/integration/yaml_suite/yaml_doc.js b/test/integration/yaml_suite/yaml_doc.js index 18fcc7b99..bb2299d08 100644 --- a/test/integration/yaml_suite/yaml_doc.js +++ b/test/integration/yaml_suite/yaml_doc.js @@ -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] === '/'; diff --git a/test/integration/yaml_suite/yaml_file.js b/test/integration/yaml_suite/yaml_file.js index 1035a37ec..b96529fc6 100644 --- a/test/integration/yaml_suite/yaml_file.js +++ b/test/integration/yaml_suite/yaml_file.js @@ -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); diff --git a/test/mocks/browser_http.js b/test/mocks/browser_http.js index 135d6ecc7..00d6cdb8b 100644 --- a/test/mocks/browser_http.js +++ b/test/mocks/browser_http.js @@ -1,4 +1,4 @@ - +/* eslint-disable */ ////////////// /// Extended version of: /// https://github.com/philikon/MockHttpRequest/ diff --git a/test/mocks/browser_server.js b/test/mocks/browser_server.js index 36babae1a..a10435cce 100644 --- a/test/mocks/browser_server.js +++ b/test/mocks/browser_server.js @@ -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)); } -}; \ No newline at end of file +}; diff --git a/test/mocks/incomming_message.js b/test/mocks/incomming_message.js index 2cca8809d..ce29326cd 100644 --- a/test/mocks/incomming_message.js +++ b/test/mocks/incomming_message.js @@ -32,4 +32,4 @@ util.inherits(MockIncommingMessage, Readable); * } * incom.push(null); * }); - */ \ No newline at end of file + */ diff --git a/test/mocks/writable_stream.js b/test/mocks/writable_stream.js index e20239af0..1907b233c 100644 --- a/test/mocks/writable_stream.js +++ b/test/mocks/writable_stream.js @@ -75,4 +75,4 @@ if (Writable) { // There is no shutdown() for files. MockWritableStream.prototype.destroySoon = MockWritableStream.prototype.end; -} \ No newline at end of file +} diff --git a/test/unit/browser_builds/angular.js b/test/unit/browser_builds/angular.js index ed6b2d974..13eafe14f 100644 --- a/test/unit/browser_builds/angular.js +++ b/test/unit/browser_builds/angular.js @@ -82,4 +82,4 @@ describe('Angular esFactory', function () { return prom; }); }); -}); \ No newline at end of file +}); diff --git a/test/unit/browser_builds/generic.js b/test/unit/browser_builds/generic.js index 4deec0163..e523fe7c9 100644 --- a/test/unit/browser_builds/generic.js +++ b/test/unit/browser_builds/generic.js @@ -17,4 +17,4 @@ describe('elasticsearch namespace', function () { expect(client.transport).to.be.a(es.Transport); client.close(); }); -}); \ No newline at end of file +}); diff --git a/test/unit/browser_builds/jquery.js b/test/unit/browser_builds/jquery.js index 0a0e3724e..42156c37b 100644 --- a/test/unit/browser_builds/jquery.js +++ b/test/unit/browser_builds/jquery.js @@ -16,4 +16,4 @@ describe('jQuery.es namespace', function () { expect(client.transport).to.be.a($.es.Transport); client.close(); }); -}); \ No newline at end of file +}); diff --git a/test/unit/buffer_flush_tests.js b/test/unit/buffer_flush_tests.js index d00f75b4d..2d2adf004 100644 --- a/test/unit/buffer_flush_tests.js +++ b/test/unit/buffer_flush_tests.js @@ -57,4 +57,4 @@ module.exports = function (makeLogger) { }); } }); -}; \ No newline at end of file +}; diff --git a/test/unit/coverage.js b/test/unit/coverage.js index 63b4fbd9b..a59557d9d 100644 --- a/test/unit/coverage.js +++ b/test/unit/coverage.js @@ -1,5 +1,5 @@ -var blanket = require("blanket")({ +var blanket = require('blanket')({ pattern: require('path').join(__dirname, '../../src') }); -require('./index'); \ No newline at end of file +require('./index'); diff --git a/test/unit/generic_logger_tests.js b/test/unit/generic_logger_tests.js index f9f3ed834..42f788ceb 100644 --- a/test/unit/generic_logger_tests.js +++ b/test/unit/generic_logger_tests.js @@ -234,4 +234,4 @@ module.exports = function (makeLogger) { expect(logger.write.callCount).to.eql(1); }); }); -}; \ No newline at end of file +}; diff --git a/test/unit/index.js b/test/unit/index.js index 8f437dc25..ed696a9c4 100644 --- a/test/unit/index.js +++ b/test/unit/index.js @@ -3,4 +3,4 @@ require('bluebird').longStackTraces(); var specDir = __dirname + '/specs'; require('fs').readdirSync(specDir).forEach(function (file) { require(specDir + '/' + file); -}); \ No newline at end of file +}); diff --git a/test/unit/specs/abstract_logger.js b/test/unit/specs/abstract_logger.js index 45158a9ba..577c0fc9f 100644 --- a/test/unit/specs/abstract_logger.js +++ b/test/unit/specs/abstract_logger.js @@ -32,4 +32,4 @@ describe('Logger Abstract', function () { require('../generic_logger_tests')(makeLogger); -}); \ No newline at end of file +}); diff --git a/test/unit/specs/client.js b/test/unit/specs/client.js index 4d7c59275..0be3338f5 100644 --- a/test/unit/specs/client.js +++ b/test/unit/specs/client.js @@ -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(); }; diff --git a/test/unit/specs/client_action.js b/test/unit/specs/client_action.js index 0b2bc76f2..82f4be8a0 100644 --- a/test/unit/specs/client_action.js +++ b/test/unit/specs/client_action.js @@ -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(); }); diff --git a/test/unit/specs/connection_abstract.js b/test/unit/specs/connection_abstract.js index 4f4a91cb6..e05bf1c0d 100644 --- a/test/unit/specs/connection_abstract.js +++ b/test/unit/specs/connection_abstract.js @@ -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); diff --git a/test/unit/specs/connection_pool.js b/test/unit/specs/connection_pool.js index b4f9d92ff..ccfd73261 100644 --- a/test/unit/specs/connection_pool.js +++ b/test/unit/specs/connection_pool.js @@ -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); }); }); diff --git a/test/unit/specs/host.js b/test/unit/specs/host.js index f0e4033c7..9bef6bde8 100644 --- a/test/unit/specs/host.js +++ b/test/unit/specs/host.js @@ -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'); }); diff --git a/test/unit/specs/http_connector.js b/test/unit/specs/http_connector.js index 47245e0f8..64825831a 100644 --- a/test/unit/specs/http_connector.js +++ b/test/unit/specs/http_connector.js @@ -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', diff --git a/test/unit/specs/json_serializer.js b/test/unit/specs/json_serializer.js index 0ec2f9e5c..9a876ba0f 100644 --- a/test/unit/specs/json_serializer.js +++ b/test/unit/specs/json_serializer.js @@ -97,4 +97,4 @@ describe('JSON serializer', function () { }).to.throwError(); }); }); -}); \ No newline at end of file +}); diff --git a/test/unit/specs/log.js b/test/unit/specs/log.js index 9cc6e38a1..aa5dab6e0 100644 --- a/test/unit/specs/log.js +++ b/test/unit/specs/log.js @@ -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); diff --git a/test/unit/specs/nodes_to_host_callback.js b/test/unit/specs/nodes_to_host_callback.js index 2f52b4bd3..c8830f9c4 100644 --- a/test/unit/specs/nodes_to_host_callback.js +++ b/test/unit/specs/nodes_to_host_callback.js @@ -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' } diff --git a/test/unit/specs/transport.js b/test/unit/specs/transport.js index c8aa567f2..4b99845ea 100644 --- a/test/unit/specs/transport.js +++ b/test/unit/specs/transport.js @@ -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); }); diff --git a/test/unit/specs/utils.js b/test/unit/specs/utils.js index fe1b73d9d..0c6f6fcfc 100644 --- a/test/unit/specs/utils.js +++ b/test/unit/specs/utils.js @@ -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(); }); diff --git a/test/unit/specs/yaml_test_reader.js b/test/unit/specs/yaml_test_reader.js index 0c241949a..4e101c1df 100644 --- a/test/unit/specs/yaml_test_reader.js +++ b/test/unit/specs/yaml_test_reader.js @@ -19,4 +19,4 @@ describe('Yaml Test Reader', function () { expect(compare('0.90 - 1.2', '1.4')).to.be(false); }); }); -}); \ No newline at end of file +}); diff --git a/test/utils/auto_release_stub.js b/test/utils/auto_release_stub.js index ce66cbf02..7ae531de7 100644 --- a/test/utils/auto_release_stub.js +++ b/test/utils/auto_release_stub.js @@ -18,4 +18,4 @@ exports.make = function () { }; return stubber; -}; \ No newline at end of file +}; diff --git a/test/utils/expect_sub_object.js b/test/utils/expect_sub_object.js index d4c61a0f1..f5c8f0e32 100644 --- a/test/utils/expect_sub_object.js +++ b/test/utils/expect_sub_object.js @@ -9,4 +9,4 @@ module.exports = function expectSubObject(obj, subObj) { expect(obj).property(prop, val); } }); -}; \ No newline at end of file +}; diff --git a/test/utils/jenkins-reporter.js b/test/utils/jenkins-reporter.js index 5d2208013..4516020d6 100644 --- a/test/utils/jenkins-reporter.js +++ b/test/utils/jenkins-reporter.js @@ -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); } diff --git a/test/utils/make_j_unit_xml.js b/test/utils/make_j_unit_xml.js index b87831667..f8a800e99 100644 --- a/test/utils/make_j_unit_xml.js +++ b/test/utils/make_j_unit_xml.js @@ -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)); } -} \ No newline at end of file +} diff --git a/test/utils/server.js b/test/utils/server.js index 88b7e07d8..1b23024b8 100644 --- a/test/utils/server.js +++ b/test/utils/server.js @@ -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'); -}); \ No newline at end of file +}); diff --git a/test/utils/slk.js b/test/utils/slk.js index e2764ba8b..0b95154c4 100644 --- a/test/utils/slk.js +++ b/test/utils/slk.js @@ -3,4 +3,4 @@ module.exports = JSON.parse(new Buffer( 'eyJ1c2VyIjoiZWxhc3RpY3NlYXJjaC1qcyIsImtleSI6IjI0ZjQ5ZTA3LWQ4MmYtNDA2Ny04NTRlLWQ4MTVlYmQxNWU0NiJ9', 'base64' -).toString('utf8')); \ No newline at end of file +).toString('utf8'));