From c51a930a2ced45ff0eb6debf422210255ff5f3f5 Mon Sep 17 00:00:00 2001 From: Diga Widyaprana Date: Sat, 27 Feb 2016 21:07:26 +0800 Subject: [PATCH] ESlint manual fix --- gulpfile.js | 9 ++++----- lib/manager.js | 12 +++++++----- lib/url.js | 5 ++--- support/webpack.config.js | 6 +++--- test/connection.js | 5 ++++- test/url.js | 1 - 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index d43af2f0..3fbc9929 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,6 +1,5 @@ const gulp = require('gulp'); const mocha = require('gulp-mocha'); -const file = require('gulp-file'); const istanbul = require('gulp-istanbul'); const webpack = require('webpack-stream'); const child = require('child_process'); @@ -11,9 +10,9 @@ gulp.task('help', help); gulp.task('default', ['lint', 'build']); -//////////////////////////////////////// +// ////////////////////////////////////// // BUILDING -//////////////////////////////////////// +// ////////////////////////////////////// const BUILD_TARGET_DIR = './'; @@ -35,9 +34,9 @@ gulp.task('lint', function () { .pipe(eslint.failAfterError()); }); -//////////////////////////////////////// +// ////////////////////////////////////// // TESTING -//////////////////////////////////////// +// ////////////////////////////////////// const REPORTER = 'dot'; const TEST_FILE = './test/index.js'; diff --git a/lib/manager.js b/lib/manager.js index ae22ffc4..4efb31ea 100644 --- a/lib/manager.js +++ b/lib/manager.js @@ -196,7 +196,6 @@ Manager.prototype.maybeReconnectOnOpen = function () { } }; - /** * Sets the current transport `socket`. * @@ -299,7 +298,7 @@ Manager.prototype.onopen = function () { */ Manager.prototype.onping = function () { - this.lastPing = new Date; + this.lastPing = new Date(); this.emitAll('ping'); }; @@ -310,7 +309,7 @@ Manager.prototype.onping = function () { */ Manager.prototype.onpong = function () { - this.emitAll('pong', new Date - this.lastPing); + this.emitAll('pong', new Date() - this.lastPing); }; /** @@ -440,8 +439,11 @@ Manager.prototype.processPacketQueue = function () { Manager.prototype.cleanup = function () { debug('cleanup'); - var sub; - while (sub = this.subs.shift()) sub.destroy(); + var subsLength = this.subs.length; + for (var i = 0; i < subsLength; i++) { + var sub = this.subs.shift(); + sub.destroy(); + } this.packetBuffer = []; this.encoding = false; diff --git a/lib/url.js b/lib/url.js index f72da274..8bac5429 100644 --- a/lib/url.js +++ b/lib/url.js @@ -25,7 +25,7 @@ function url (uri, loc) { var obj = uri; // default to window.location - var loc = loc || global.location; + loc = loc || global.location; if (null == uri) uri = loc.protocol + '//' + loc.host; // relative path support @@ -56,8 +56,7 @@ function url (uri, loc) { if (!obj.port) { if (/^(http|ws)$/.test(obj.protocol)) { obj.port = '80'; - } - else if (/^(http|ws)s$/.test(obj.protocol)) { + } else if (/^(http|ws)s$/.test(obj.protocol)) { obj.port = '443'; } } diff --git a/support/webpack.config.js b/support/webpack.config.js index ddc7d78c..4cd2bfc2 100644 --- a/support/webpack.config.js +++ b/support/webpack.config.js @@ -28,7 +28,7 @@ module.exports = { */ function glob () { - return 'typeof self !== "undefined" ? self : ' - + 'typeof window !== "undefined" ? window : ' - + 'typeof global !== "undefined" ? global : {}'; + return 'typeof self !== "undefined" ? self : ' + + 'typeof window !== "undefined" ? window : ' + + 'typeof global !== "undefined" ? global : {}'; } diff --git a/test/connection.js b/test/connection.js index 29f6b4bf..be49f21b 100644 --- a/test/connection.js +++ b/test/connection.js @@ -186,7 +186,10 @@ describe('connection', function () { it('reconnect delay should increase every time', function (done) { var manager = io.Manager({ reconnection: true, timeout: 0, reconnectionAttempts: 3, reconnectionDelay: 100, randomizationFactor: 0.2 }); var socket = manager.socket('/timeout'); - var reconnects = 0, increasingDelay = true, startTime, prevDelay = 0; + var reconnects = 0; + var increasingDelay = true; + var startTime; + var prevDelay = 0; socket.on('connect_error', function () { startTime = new Date().getTime(); diff --git a/test/url.js b/test/url.js index 5b374f29..ce3dfc6d 100644 --- a/test/url.js +++ b/test/url.js @@ -4,7 +4,6 @@ var url = require('../lib/url'); var expect = require('expect.js'); describe('url', function () { - it('works with undefined', function () { loc.hostname = 'woot.com'; loc.protocol = 'https:';