Skip to content

Commit 15ed64e

Browse files
targosMyles Borins
authored and
Myles Borins
committed
lib: fix style issues after eslint update
With an indentation style of two spaces, it is not possible to indent multiline variable declarations by four spaces. Instead, the var keyword is used on every new line. Use const instead of var where applicable for changed lines. PR-URL: #2286 Reviewed-By: Roman Reiss <[email protected]>
1 parent b20ea69 commit 15ed64e

13 files changed

+170
-172
lines changed

lib/_debugger.js

+55-57
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ exports.start = function(argv, stdin, stdout) {
2525
stdin = stdin || process.stdin;
2626
stdout = stdout || process.stdout;
2727

28-
var args = ['--debug-brk'].concat(argv),
29-
interface_ = new Interface(stdin, stdout, args);
28+
const args = ['--debug-brk'].concat(argv);
29+
const interface_ = new Interface(stdin, stdout, args);
3030

3131
stdin.resume();
3232

@@ -197,8 +197,8 @@ Client.prototype._removeScript = function(desc) {
197197

198198

199199
Client.prototype._onResponse = function(res) {
200-
var cb,
201-
index = -1;
200+
var cb;
201+
var index = -1;
202202

203203
this._reqCallbacks.some(function(fn, i) {
204204
if (fn.request_seq == res.body.request_seq) {
@@ -295,11 +295,11 @@ Client.prototype.reqLookup = function(refs, cb) {
295295
};
296296

297297
Client.prototype.reqScopes = function(cb) {
298-
var self = this,
299-
req = {
300-
command: 'scopes',
301-
arguments: {}
302-
};
298+
const self = this;
299+
const req = {
300+
command: 'scopes',
301+
arguments: {}
302+
};
303303

304304
cb = cb || function() {};
305305
this.req(req, function(err, res) {
@@ -525,8 +525,8 @@ Client.prototype.mirrorObject = function(handle, depth, cb) {
525525
return;
526526
}
527527

528-
var mirror,
529-
waiting = 1;
528+
var mirror;
529+
var waiting = 1;
530530

531531
if (handle.className == 'Array') {
532532
mirror = [];
@@ -676,8 +676,8 @@ var helpMessage = 'Commands: ' + commands.map(function(group) {
676676
function SourceUnderline(sourceText, position, repl) {
677677
if (!sourceText) return '';
678678

679-
var head = sourceText.slice(0, position),
680-
tail = sourceText.slice(position);
679+
const head = sourceText.slice(0, position);
680+
var tail = sourceText.slice(position);
681681

682682
// Colourize char if stdout supports colours
683683
if (repl.useColors) {
@@ -697,8 +697,8 @@ function SourceInfo(body) {
697697

698698
if (body.script) {
699699
if (body.script.name) {
700-
var name = body.script.name,
701-
dir = path.resolve() + '/';
700+
var name = body.script.name;
701+
const dir = path.resolve() + '/';
702702

703703
// Change path to relative, if possible
704704
if (name.indexOf(dir) === 0) {
@@ -969,8 +969,8 @@ Interface.prototype.controlEval = function(code, context, filename, callback) {
969969
Interface.prototype.debugEval = function(code, context, filename, callback) {
970970
if (!this.requireConnection()) return;
971971

972-
var self = this,
973-
client = this.client;
972+
const self = this;
973+
const client = this.client;
974974

975975
// Repl asked for scope variables
976976
if (code === '.scope') {
@@ -1004,9 +1004,9 @@ Interface.prototype.debugEval = function(code, context, filename, callback) {
10041004
// Adds spaces and prefix to number
10051005
// maxN is a maximum number we should have space for
10061006
function leftPad(n, prefix, maxN) {
1007-
var s = n.toString(),
1008-
nchars = Math.max(2, String(maxN).length) + 1,
1009-
nspaces = nchars - s.length - 1;
1007+
const s = n.toString();
1008+
const nchars = Math.max(2, String(maxN).length) + 1;
1009+
const nspaces = nchars - s.length - 1;
10101010

10111011
for (var i = 0; i < nspaces; i++) {
10121012
prefix += ' ';
@@ -1078,10 +1078,10 @@ Interface.prototype.list = function(delta) {
10781078

10791079
delta || (delta = 5);
10801080

1081-
var self = this,
1082-
client = this.client,
1083-
from = client.currentSourceLine - delta + 1,
1084-
to = client.currentSourceLine + delta + 1;
1081+
const self = this;
1082+
const client = this.client;
1083+
const from = client.currentSourceLine - delta + 1;
1084+
const to = client.currentSourceLine + delta + 1;
10851085

10861086
self.pause();
10871087
client.reqSource(from, to, function(err, res) {
@@ -1096,12 +1096,12 @@ Interface.prototype.list = function(delta) {
10961096
var lineno = res.fromLine + i + 1;
10971097
if (lineno < from || lineno > to) continue;
10981098

1099-
var current = lineno == 1 + client.currentSourceLine,
1100-
breakpoint = client.breakpoints.some(function(bp) {
1101-
return (bp.scriptReq === client.currentScript ||
1102-
bp.script === client.currentScript) &&
1103-
bp.line == lineno;
1104-
});
1099+
const current = lineno == 1 + client.currentSourceLine;
1100+
const breakpoint = client.breakpoints.some(function(bp) {
1101+
return (bp.scriptReq === client.currentScript ||
1102+
bp.script === client.currentScript) &&
1103+
bp.line == lineno;
1104+
});
11051105

11061106
if (lineno == 1) {
11071107
// The first line needs to have the module wrapper filtered out of
@@ -1139,8 +1139,8 @@ Interface.prototype.list = function(delta) {
11391139
Interface.prototype.backtrace = function() {
11401140
if (!this.requireConnection()) return;
11411141

1142-
var self = this,
1143-
client = this.client;
1142+
const self = this;
1143+
const client = this.client;
11441144

11451145
self.pause();
11461146
client.fullTrace(function(err, bt) {
@@ -1153,8 +1153,8 @@ Interface.prototype.backtrace = function() {
11531153
if (bt.totalFrames == 0) {
11541154
self.print('(empty stack)');
11551155
} else {
1156-
var trace = [],
1157-
firstFrameNative = bt.frames[0].script.isNative;
1156+
const trace = [];
1157+
const firstFrameNative = bt.frames[0].script.isNative;
11581158

11591159
for (var i = 0; i < bt.frames.length; i++) {
11601160
var frame = bt.frames[i];
@@ -1183,9 +1183,9 @@ Interface.prototype.backtrace = function() {
11831183
Interface.prototype.scripts = function() {
11841184
if (!this.requireConnection()) return;
11851185

1186-
var client = this.client,
1187-
displayNatives = arguments[0] || false,
1188-
scripts = [];
1186+
const client = this.client;
1187+
const displayNatives = arguments[0] || false;
1188+
const scripts = [];
11891189

11901190
this.pause();
11911191
for (var id in client.scripts) {
@@ -1323,9 +1323,9 @@ Interface.prototype.setBreakpoint = function(script, line,
13231323
condition, silent) {
13241324
if (!this.requireConnection()) return;
13251325

1326-
var self = this,
1327-
scriptId,
1328-
ambiguous;
1326+
const self = this;
1327+
var scriptId;
1328+
var ambiguous;
13291329

13301330
// setBreakpoint() should insert breakpoint on current line
13311331
if (script === undefined) {
@@ -1429,10 +1429,10 @@ Interface.prototype.setBreakpoint = function(script, line,
14291429
Interface.prototype.clearBreakpoint = function(script, line) {
14301430
if (!this.requireConnection()) return;
14311431

1432-
var ambiguous,
1433-
breakpoint,
1434-
scriptId,
1435-
index;
1432+
var ambiguous;
1433+
var breakpoint;
1434+
var scriptId;
1435+
var index;
14361436

14371437
this.client.breakpoints.some(function(bp, i) {
14381438
if (bp.scriptId === script ||
@@ -1474,10 +1474,8 @@ Interface.prototype.clearBreakpoint = function(script, line) {
14741474
return this.error('Breakpoint not found on line ' + line);
14751475
}
14761476

1477-
var self = this,
1478-
req = {
1479-
breakpoint: breakpoint
1480-
};
1477+
var self = this;
1478+
const req = {breakpoint};
14811479

14821480
self.pause();
14831481
self.client.clearBreakpoint(req, function(err, res) {
@@ -1513,8 +1511,8 @@ Interface.prototype.breakpoints = function() {
15131511
Interface.prototype.pause_ = function() {
15141512
if (!this.requireConnection()) return;
15151513

1516-
var self = this,
1517-
cmd = 'process._debugPause();';
1514+
const self = this;
1515+
const cmd = 'process._debugPause();';
15181516

15191517
this.pause();
15201518
this.client.reqFrameEval(cmd, NO_FRAME, function(err, res) {
@@ -1621,11 +1619,11 @@ Interface.prototype.killChild = function() {
16211619

16221620
// Spawns child process (and restores breakpoints)
16231621
Interface.prototype.trySpawn = function(cb) {
1624-
var self = this,
1625-
breakpoints = this.breakpoints || [],
1626-
port = exports.port,
1627-
host = '127.0.0.1',
1628-
childArgs = this.args;
1622+
const self = this;
1623+
const breakpoints = this.breakpoints || [];
1624+
var port = exports.port;
1625+
var host = '127.0.0.1';
1626+
var childArgs = this.args;
16291627

16301628
this.killChild();
16311629
assert(!this.child);
@@ -1676,8 +1674,8 @@ Interface.prototype.trySpawn = function(cb) {
16761674

16771675
this.pause();
16781676

1679-
var client = self.client = new Client(),
1680-
connectionAttempts = 0;
1677+
const client = self.client = new Client();
1678+
var connectionAttempts = 0;
16811679

16821680
client.once('ready', function() {
16831681
self.stdout.write(' ok\n');

lib/_http_server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const STATUS_CODES = exports.STATUS_CODES = {
6464
426 : 'Upgrade Required', // RFC 2817
6565
428 : 'Precondition Required', // RFC 6585
6666
429 : 'Too Many Requests', // RFC 6585
67-
431 : 'Request Header Fields Too Large',// RFC 6585
67+
431 : 'Request Header Fields Too Large', // RFC 6585
6868
500 : 'Internal Server Error',
6969
501 : 'Not Implemented',
7070
502 : 'Bad Gateway',

lib/_tls_legacy.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ CryptoStream.prototype._write = function write(data, encoding, cb) {
224224

225225

226226
CryptoStream.prototype._writePending = function writePending() {
227-
var data = this._pending,
228-
encoding = this._pendingEncoding,
229-
cb = this._pendingCallback;
227+
const data = this._pending;
228+
const encoding = this._pendingEncoding;
229+
const cb = this._pendingCallback;
230230

231231
this._pending = null;
232232
this._pendingEncoding = '';
@@ -252,9 +252,9 @@ CryptoStream.prototype._read = function read(size) {
252252
out = this.pair.ssl.encOut;
253253
}
254254

255-
var bytesRead = 0,
256-
start = this._buffer.offset,
257-
last = start;
255+
var bytesRead = 0;
256+
const start = this._buffer.offset;
257+
var last = start;
258258
do {
259259
assert(last === this._buffer.offset);
260260
var read = this._buffer.use(this.pair.ssl, out, size - bytesRead);
@@ -604,8 +604,8 @@ function onhandshakedone() {
604604

605605

606606
function onclienthello(hello) {
607-
var self = this,
608-
once = false;
607+
const self = this;
608+
var once = false;
609609

610610
this._resumingSession = true;
611611
function callback(err, session) {

lib/_tls_wrap.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ TLSSocket.prototype._init = function(socket, wrap) {
397397

398398
// For clients, we will always have either a given ca list or be using
399399
// default one
400-
var requestCert = !!options.requestCert || !options.isServer,
401-
rejectUnauthorized = !!options.rejectUnauthorized;
400+
const requestCert = !!options.requestCert || !options.isServer;
401+
const rejectUnauthorized = !!options.rejectUnauthorized;
402402

403403
this._requestCert = requestCert;
404404
this._rejectUnauthorized = rejectUnauthorized;
@@ -494,8 +494,8 @@ TLSSocket.prototype._init = function(socket, wrap) {
494494
};
495495

496496
TLSSocket.prototype.renegotiate = function(options, callback) {
497-
var requestCert = this._requestCert,
498-
rejectUnauthorized = this._rejectUnauthorized;
497+
var requestCert = this._requestCert;
498+
var rejectUnauthorized = this._rejectUnauthorized;
499499

500500
if (this.destroyed)
501501
return;
@@ -966,9 +966,9 @@ exports.connect = function(/* [port, host], options, cb */) {
966966
var hostname = options.servername ||
967967
options.host ||
968968
(options.socket && options.socket._host) ||
969-
'localhost',
970-
NPN = {},
971-
context = tls.createSecureContext(options);
969+
'localhost';
970+
const NPN = {};
971+
const context = tls.createSecureContext(options);
972972
tls.convertNPNProtocols(options.NPNProtocols, NPN);
973973

974974
var socket = new TLSSocket(options.socket, {

lib/assert.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,18 @@ function objEquiv(a, b, strict) {
198198
return a === b;
199199
if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
200200
return false;
201-
var aIsArgs = isArguments(a),
202-
bIsArgs = isArguments(b);
201+
const aIsArgs = isArguments(a);
202+
const bIsArgs = isArguments(b);
203203
if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
204204
return false;
205205
if (aIsArgs) {
206206
a = pSlice.call(a);
207207
b = pSlice.call(b);
208208
return _deepEqual(a, b, strict);
209209
}
210-
var ka = Object.keys(a),
211-
kb = Object.keys(b),
212-
key, i;
210+
const ka = Object.keys(a);
211+
const kb = Object.keys(b);
212+
var key, i;
213213
// having the same number of owned properties (keys incorporates
214214
// hasOwnProperty)
215215
if (ka.length !== kb.length)

lib/fs.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ fs.openSync = function(path, flags, mode) {
552552
fs.read = function(fd, buffer, offset, length, position, callback) {
553553
if (!(buffer instanceof Buffer)) {
554554
// legacy string interface (fd, length, position, encoding, callback)
555-
var cb = arguments[4],
556-
encoding = arguments[3];
555+
const cb = arguments[4];
556+
const encoding = arguments[3];
557557

558558
assertEncoding(encoding);
559559

@@ -1388,9 +1388,9 @@ fs.realpathSync = function realpathSync(p, cache) {
13881388
return cache[p];
13891389
}
13901390

1391-
var original = p,
1392-
seenLinks = {},
1393-
knownHard = {};
1391+
const original = p;
1392+
const seenLinks = {};
1393+
const knownHard = {};
13941394

13951395
// current character position in p
13961396
var pos;
@@ -1490,9 +1490,9 @@ fs.realpath = function realpath(p, cache, cb) {
14901490
return process.nextTick(cb.bind(null, null, cache[p]));
14911491
}
14921492

1493-
var original = p,
1494-
seenLinks = {},
1495-
knownHard = {};
1493+
const original = p;
1494+
const seenLinks = {};
1495+
const knownHard = {};
14961496

14971497
// current character position in p
14981498
var pos;
@@ -1941,9 +1941,9 @@ util.inherits(SyncWriteStream, Stream);
19411941

19421942
// Export
19431943
Object.defineProperty(fs, 'SyncWriteStream', {
1944-
configurable: true,
1945-
writable: true,
1946-
value: SyncWriteStream
1944+
configurable: true,
1945+
writable: true,
1946+
value: SyncWriteStream
19471947
});
19481948

19491949
SyncWriteStream.prototype.write = function(data, arg1, arg2) {

0 commit comments

Comments
 (0)