Skip to content

Commit 19ffb5c

Browse files
lib: fix eslint styles
PR-URL: #1539 Fixes: #1253 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
1 parent f9dd34d commit 19ffb5c

22 files changed

+45
-39
lines changed

lib/_debugger.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Protocol.prototype.execute = function(d) {
101101
if (len - this.bodyStartByteIndex < this.contentLength) {
102102
break;
103103
}
104-
// pass thru
104+
// falls through
105105
case 'body':
106106
var resRawByteLength = Buffer.byteLength(res.raw, 'utf8');
107107

@@ -125,7 +125,6 @@ Protocol.prototype.execute = function(d) {
125125

126126
default:
127127
throw new Error('Unknown state');
128-
break;
129128
}
130129
};
131130

@@ -262,7 +261,7 @@ Client.prototype.req = function(req, cb) {
262261

263262
Client.prototype.reqVersion = function(cb) {
264263
cb = cb || function() {};
265-
this.req({ command: 'version' } , function(err, body, res) {
264+
this.req({ command: 'version' }, function(err, body, res) {
266265
if (err) return cb(err);
267266
cb(null, res.body.body.V8Version, res.body.running);
268267
});
@@ -398,7 +397,7 @@ Client.prototype.reqFrameEval = function(expression, frame, cb) {
398397
// reqBacktrace(cb)
399398
// TODO: from, to, bottom
400399
Client.prototype.reqBacktrace = function(cb) {
401-
this.req({ command: 'backtrace', arguments: { inlineRefs: true } } , cb);
400+
this.req({ command: 'backtrace', arguments: { inlineRefs: true } }, cb);
402401
};
403402

404403

@@ -432,7 +431,7 @@ Client.prototype.reqScripts = function(cb) {
432431
var self = this;
433432
cb = cb || function() {};
434433

435-
this.req({ command: 'scripts' } , function(err, res) {
434+
this.req({ command: 'scripts' }, function(err, res) {
436435
if (err) return cb(err);
437436

438437
for (var i = 0; i < res.length; i++) {

lib/_http_incoming.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ IncomingMessage.prototype._addHeaderLine = function(field, value, dest) {
137137
}
138138
break;
139139

140+
/* eslint-disable max-len */
140141
// list is taken from:
141142
// https://mxr.mozilla.org/mozilla/source/netwerk/protocol/http/src/nsHttpHeaderArray.cpp
143+
/* eslint-enable max-len */
142144
case 'content-type':
143145
case 'content-length':
144146
case 'user-agent':
@@ -158,9 +160,9 @@ IncomingMessage.prototype._addHeaderLine = function(field, value, dest) {
158160

159161
default:
160162
// make comma-separated list
161-
if (dest[field] !== undefined)
163+
if (dest[field] !== undefined) {
162164
dest[field] += ', ' + value;
163-
else {
165+
} else {
164166
dest[field] = value;
165167
}
166168
}

lib/_http_outgoing.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ OutgoingMessage.prototype.setTimeout = function(msecs, callback) {
8585
this.once('socket', function(socket) {
8686
socket.setTimeout(msecs);
8787
});
88-
} else
88+
} else {
8989
this.socket.setTimeout(msecs);
90+
}
9091
};
9192

9293

lib/_http_server.js

+2
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,11 @@ function Server(requestListener) {
221221
this.addListener('request', requestListener);
222222
}
223223

224+
/* eslint-disable max-len */
224225
// Similar option to this. Too lazy to write my own docs.
225226
// http://www.squid-cache.org/Doc/config/half_closed_clients/
226227
// http://wiki.squid-cache.org/SquidFaq/InnerWorkings#What_is_a_half-closed_filedescriptor.3F
228+
/* eslint-enable max-len */
227229
this.httpAllowHalfOpen = false;
228230

229231
this.addListener('connection', connectionListener);

lib/_stream_readable.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,9 @@ function howMuchToRead(n, state) {
234234
if (!state.ended) {
235235
state.needReadable = true;
236236
return 0;
237-
} else
237+
} else {
238238
return state.length;
239+
}
239240
}
240241

241242
return n;
@@ -774,7 +775,7 @@ Readable.prototype.wrap = function(stream) {
774775
if (this[i] === undefined && typeof stream[i] === 'function') {
775776
this[i] = function(method) { return function() {
776777
return stream[method].apply(stream, arguments);
777-
}}(i);
778+
}; }(i);
778779
}
779780
}
780781

lib/_stream_writable.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Writable.WritableState = WritableState;
99

1010
const util = require('util');
1111
const Stream = require('stream');
12-
const debug = util.debuglog('stream');
1312

1413
util.inherits(Writable, Stream);
1514

@@ -273,9 +272,9 @@ function writeOrBuffer(stream, state, chunk, encoding, cb) {
273272
} else {
274273
state.bufferedRequest = state.lastBufferedRequest;
275274
}
276-
}
277-
else
275+
} else {
278276
doWrite(stream, state, false, len, chunk, encoding, cb);
277+
}
279278

280279
return ret;
281280
}
@@ -471,8 +470,9 @@ function finishMaybe(stream, state) {
471470
prefinish(stream, state);
472471
state.finished = true;
473472
stream.emit('finish');
474-
} else
473+
} else {
475474
prefinish(stream, state);
475+
}
476476
}
477477
return need;
478478
}

lib/_tls_legacy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ function onnewsession(key, session) {
646646

647647
if (self.ssl)
648648
self.ssl.newSessionDone();
649-
};
649+
}
650650
}
651651

652652

lib/assert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,4 @@ assert.doesNotThrow = function(block, /*optional*/message) {
323323
_throws.apply(this, [false].concat(pSlice.call(arguments)));
324324
};
325325

326-
assert.ifError = function(err) { if (err) {throw err;}};
326+
assert.ifError = function(err) { if (err) throw err; };

lib/child_process.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,15 @@ SocketListSend.prototype._request = function(msg, cmd, callback) {
169169
function onclose() {
170170
self.slave.removeListener('internalMessage', onreply);
171171
callback(new Error('Slave closed before reply'));
172-
};
172+
}
173173

174174
function onreply(msg) {
175175
if (!(msg.cmd === cmd && msg.key === self.key)) return;
176176
self.slave.removeListener('disconnect', onclose);
177177
self.slave.removeListener('internalMessage', onreply);
178178

179179
callback(null, msg);
180-
};
180+
}
181181

182182
this.slave.once('disconnect', onclose);
183183
this.slave.on('internalMessage', onreply);

lib/cluster.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const SCHED_RR = 2;
1111

1212
const uv = process.binding('uv');
1313

14-
const cluster = new EventEmitter;
14+
const cluster = new EventEmitter();
1515
module.exports = cluster;
1616
cluster.Worker = Worker;
1717
cluster.isWorker = ('NODE_UNIQUE_ID' in process.env);
@@ -127,11 +127,10 @@ RoundRobinHandle.prototype.add = function(worker, send) {
127127
function done() {
128128
if (self.handle.getsockname) {
129129
var out = {};
130-
var err = self.handle.getsockname(out);
130+
self.handle.getsockname(out);
131131
// TODO(bnoordhuis) Check err.
132132
send(null, { sockname: out }, null);
133-
}
134-
else {
133+
} else {
135134
send(null, null, null); // UNIX socket.
136135
}
137136
self.handoff(worker); // In case there are connections pending.
@@ -196,7 +195,7 @@ else
196195
function masterInit() {
197196
cluster.workers = {};
198197

199-
var intercom = new EventEmitter;
198+
var intercom = new EventEmitter();
200199
cluster.settings = {};
201200

202201
// XXX(bnoordhuis) Fold cluster.schedulingPolicy into cluster.settings?

lib/console.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Console.prototype.timeEnd = function(label) {
7373
Console.prototype.trace = function trace() {
7474
// TODO probably can to do this better with V8's debug object once that is
7575
// exposed.
76-
var err = new Error;
76+
var err = new Error();
7777
err.name = 'Trace';
7878
err.message = util.format.apply(this, arguments);
7979
Error.captureStackTrace(err, trace);

lib/crypto.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ function Verify(algorithm, options) {
320320
if (!(this instanceof Verify))
321321
return new Verify(algorithm, options);
322322

323-
this._handle = new binding.Verify;
323+
this._handle = new binding.Verify();
324324
this._handle.init(algorithm);
325325

326326
stream.Writable.call(this, options);

lib/dgram.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ function lookup6(address, callback) {
3939

4040
function newHandle(type) {
4141
if (type == 'udp4') {
42-
var handle = new UDP;
42+
var handle = new UDP();
4343
handle.lookup = lookup4;
4444
return handle;
4545
}
4646

4747
if (type == 'udp6') {
48-
var handle = new UDP;
48+
var handle = new UDP();
4949
handle.lookup = lookup6;
5050
handle.bind = handle.bind6;
5151
handle.send = handle.send6;
@@ -301,8 +301,7 @@ Socket.prototype.send = function(buffer,
301301
if (ex) {
302302
if (callback) callback(ex);
303303
self.emit('error', ex);
304-
}
305-
else if (self._handle) {
304+
} else if (self._handle) {
306305
var req = new SendWrap();
307306
req.buffer = buffer; // Keep reference alive.
308307
req.length = length;

lib/dns.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ function resolver(bindingName) {
239239
if (err) throw errnoException(err, bindingName);
240240
callback.immediately = true;
241241
return req;
242-
}
242+
};
243243
}
244244

245245

lib/events.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,9 @@ EventEmitter.prototype.removeListener =
307307
if (--this._eventsCount === 0) {
308308
this._events = {};
309309
return this;
310-
} else
310+
} else {
311311
delete events[type];
312+
}
312313
} else {
313314
spliceOne(list, position);
314315
}

lib/fs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function rethrow() {
4040
// Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
4141
// is fairly slow to generate.
4242
if (DEBUG) {
43-
var backtrace = new Error;
43+
var backtrace = new Error();
4444
return function(err) {
4545
if (err) {
4646
backtrace.stack = err.name + ': ' + err.message +

lib/net.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ Socket.prototype._destroy = function(exception, cb) {
431431
});
432432
self._writableState.errorEmitted = true;
433433
}
434-
};
434+
}
435435

436436
if (this.destroyed) {
437437
debug('already destroyed, fire error callbacks');
@@ -1338,7 +1338,7 @@ Server.prototype.listen = function() {
13381338
Server.prototype.address = function() {
13391339
if (this._handle && this._handle.getsockname) {
13401340
var out = {};
1341-
var err = this._handle.getsockname(out);
1341+
this._handle.getsockname(out);
13421342
// TODO(bnoordhuis) Check err and throw?
13431343
return out;
13441344
} else if (this._pipeName) {

lib/querystring.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ QueryString.unescapeBuffer = function(s, decodeSpaces) {
2828
break;
2929
case charCode('+'):
3030
if (decodeSpaces) c = charCode(' ');
31-
// pass thru
31+
// falls through
3232
default:
3333
out[outIndex++] = c;
3434
break;

lib/repl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ function REPLServer(prompt,
350350

351351
// Display prompt again
352352
self.displayPrompt();
353-
};
353+
}
354354
});
355355

356356
self.on('SIGCONT', function() {

lib/url.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const querystring = require('querystring');
8080
function urlParse(url, parseQueryString, slashesDenoteHost) {
8181
if (url instanceof Url) return url;
8282

83-
var u = new Url;
83+
var u = new Url();
8484
u.parse(url, parseQueryString, slashesDenoteHost);
8585
return u;
8686
}

lib/util.js

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ exports.format = function(f) {
2828
} catch (_) {
2929
return '[Circular]';
3030
}
31+
// falls through
3132
default:
3233
return x;
3334
}

src/node.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@
475475
if (process._exiting)
476476
return;
477477

478-
var args = undefined;
478+
var args;
479479
if (arguments.length > 1) {
480480
args = [];
481481
for (var i = 1; i < arguments.length; i++)
@@ -496,8 +496,9 @@
496496
if (!process.emit('unhandledRejection', reason, promise)) {
497497
// Nobody is listening.
498498
// TODO(petkaantonov) Take some default action, see #830
499-
} else
499+
} else {
500500
hadListeners = true;
501+
}
501502
}
502503
}
503504
return hadListeners;

0 commit comments

Comments
 (0)