Skip to content

Commit 2512a0f

Browse files
targosMichael Scovetta
authored and
Michael Scovetta
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: nodejs#2286 Reviewed-By: Roman Reiss <[email protected]>
1 parent bde43c8 commit 2512a0f

13 files changed

+171
-173
lines changed

lib/_debugger.js

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

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

3232
stdin.resume();
3333

@@ -198,8 +198,8 @@ Client.prototype._removeScript = function(desc) {
198198

199199

200200
Client.prototype._onResponse = function(res) {
201-
var cb,
202-
index = -1;
201+
var cb;
202+
var index = -1;
203203

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

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

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

529-
var mirror,
530-
waiting = 1;
529+
var mirror;
530+
var waiting = 1;
531531

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

681-
var head = sourceText.slice(0, position),
682-
tail = sourceText.slice(position);
681+
const head = sourceText.slice(0, position);
682+
var tail = sourceText.slice(position);
683683

684684
// Colourize char if stdout supports colours
685685
if (repl.useColors) {
@@ -699,8 +699,8 @@ function SourceInfo(body) {
699699

700700
if (body.script) {
701701
if (body.script.name) {
702-
var name = body.script.name,
703-
dir = path.resolve() + '/';
702+
var name = body.script.name;
703+
const dir = path.resolve() + '/';
704704

705705
// Change path to relative, if possible
706706
if (name.indexOf(dir) === 0) {
@@ -977,8 +977,8 @@ Interface.prototype.controlEval = function(code, context, filename, callback) {
977977
Interface.prototype.debugEval = function(code, context, filename, callback) {
978978
if (!this.requireConnection()) return;
979979

980-
var self = this,
981-
client = this.client;
980+
const self = this;
981+
const client = this.client;
982982

983983
// Repl asked for scope variables
984984
if (code === '.scope') {
@@ -1012,9 +1012,9 @@ Interface.prototype.debugEval = function(code, context, filename, callback) {
10121012
// Adds spaces and prefix to number
10131013
// maxN is a maximum number we should have space for
10141014
function leftPad(n, prefix, maxN) {
1015-
var s = n.toString(),
1016-
nchars = Math.max(2, String(maxN).length) + 1,
1017-
nspaces = nchars - s.length - 1;
1015+
const s = n.toString();
1016+
const nchars = Math.max(2, String(maxN).length) + 1;
1017+
const nspaces = nchars - s.length - 1;
10181018

10191019
for (var i = 0; i < nspaces; i++) {
10201020
prefix += ' ';
@@ -1086,10 +1086,10 @@ Interface.prototype.list = function(delta) {
10861086

10871087
delta || (delta = 5);
10881088

1089-
var self = this,
1090-
client = this.client,
1091-
from = client.currentSourceLine - delta + 1,
1092-
to = client.currentSourceLine + delta + 1;
1089+
const self = this;
1090+
const client = this.client;
1091+
const from = client.currentSourceLine - delta + 1;
1092+
const to = client.currentSourceLine + delta + 1;
10931093

10941094
self.pause();
10951095
client.reqSource(from, to, function(err, res) {
@@ -1104,12 +1104,12 @@ Interface.prototype.list = function(delta) {
11041104
var lineno = res.fromLine + i + 1;
11051105
if (lineno < from || lineno > to) continue;
11061106

1107-
var current = lineno == 1 + client.currentSourceLine,
1108-
breakpoint = client.breakpoints.some(function(bp) {
1109-
return (bp.scriptReq === client.currentScript ||
1110-
bp.script === client.currentScript) &&
1111-
bp.line == lineno;
1112-
});
1107+
const current = lineno == 1 + client.currentSourceLine;
1108+
const breakpoint = client.breakpoints.some(function(bp) {
1109+
return (bp.scriptReq === client.currentScript ||
1110+
bp.script === client.currentScript) &&
1111+
bp.line == lineno;
1112+
});
11131113

11141114
if (lineno == 1) {
11151115
// The first line needs to have the module wrapper filtered out of
@@ -1147,8 +1147,8 @@ Interface.prototype.list = function(delta) {
11471147
Interface.prototype.backtrace = function() {
11481148
if (!this.requireConnection()) return;
11491149

1150-
var self = this,
1151-
client = this.client;
1150+
const self = this;
1151+
const client = this.client;
11521152

11531153
self.pause();
11541154
client.fullTrace(function(err, bt) {
@@ -1161,8 +1161,8 @@ Interface.prototype.backtrace = function() {
11611161
if (bt.totalFrames == 0) {
11621162
self.print('(empty stack)');
11631163
} else {
1164-
var trace = [],
1165-
firstFrameNative = bt.frames[0].script.isNative;
1164+
const trace = [];
1165+
const firstFrameNative = bt.frames[0].script.isNative;
11661166

11671167
for (var i = 0; i < bt.frames.length; i++) {
11681168
var frame = bt.frames[i];
@@ -1191,9 +1191,9 @@ Interface.prototype.backtrace = function() {
11911191
Interface.prototype.scripts = function() {
11921192
if (!this.requireConnection()) return;
11931193

1194-
var client = this.client,
1195-
displayNatives = arguments[0] || false,
1196-
scripts = [];
1194+
const client = this.client;
1195+
const displayNatives = arguments[0] || false;
1196+
const scripts = [];
11971197

11981198
this.pause();
11991199
for (var id in client.scripts) {
@@ -1331,9 +1331,9 @@ Interface.prototype.setBreakpoint = function(script, line,
13311331
condition, silent) {
13321332
if (!this.requireConnection()) return;
13331333

1334-
var self = this,
1335-
scriptId,
1336-
ambiguous;
1334+
const self = this;
1335+
var scriptId;
1336+
var ambiguous;
13371337

13381338
// setBreakpoint() should insert breakpoint on current line
13391339
if (script === undefined) {
@@ -1437,10 +1437,10 @@ Interface.prototype.setBreakpoint = function(script, line,
14371437
Interface.prototype.clearBreakpoint = function(script, line) {
14381438
if (!this.requireConnection()) return;
14391439

1440-
var ambiguous,
1441-
breakpoint,
1442-
scriptId,
1443-
index;
1440+
var ambiguous;
1441+
var breakpoint;
1442+
var scriptId;
1443+
var index;
14441444

14451445
this.client.breakpoints.some(function(bp, i) {
14461446
if (bp.scriptId === script ||
@@ -1482,10 +1482,8 @@ Interface.prototype.clearBreakpoint = function(script, line) {
14821482
return this.error('Breakpoint not found on line ' + line);
14831483
}
14841484

1485-
var self = this,
1486-
req = {
1487-
breakpoint: breakpoint
1488-
};
1485+
var self = this;
1486+
const req = {breakpoint};
14891487

14901488
self.pause();
14911489
self.client.clearBreakpoint(req, function(err, res) {
@@ -1521,8 +1519,8 @@ Interface.prototype.breakpoints = function() {
15211519
Interface.prototype.pause_ = function() {
15221520
if (!this.requireConnection()) return;
15231521

1524-
var self = this,
1525-
cmd = 'process._debugPause();';
1522+
const self = this;
1523+
const cmd = 'process._debugPause();';
15261524

15271525
this.pause();
15281526
this.client.reqFrameEval(cmd, NO_FRAME, function(err, res) {
@@ -1643,11 +1641,11 @@ Interface.prototype.killChild = function() {
16431641

16441642
// Spawns child process (and restores breakpoints)
16451643
Interface.prototype.trySpawn = function(cb) {
1646-
var self = this,
1647-
breakpoints = this.breakpoints || [],
1648-
port = exports.port,
1649-
host = '127.0.0.1',
1650-
childArgs = this.args;
1644+
const self = this;
1645+
const breakpoints = this.breakpoints || [];
1646+
var port = exports.port;
1647+
var host = '127.0.0.1';
1648+
var childArgs = this.args;
16511649

16521650
this.killChild();
16531651
assert(!this.child);
@@ -1698,8 +1696,8 @@ Interface.prototype.trySpawn = function(cb) {
16981696

16991697
this.pause();
17001698

1701-
var client = self.client = new Client(),
1702-
connectionAttempts = 0;
1699+
const client = self.client = new Client();
1700+
var connectionAttempts = 0;
17031701

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

lib/_http_server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const STATUS_CODES = exports.STATUS_CODES = {
6363
426 : 'Upgrade Required', // RFC 2817
6464
428 : 'Precondition Required', // RFC 6585
6565
429 : 'Too Many Requests', // RFC 6585
66-
431 : 'Request Header Fields Too Large',// RFC 6585
66+
431 : 'Request Header Fields Too Large', // RFC 6585
6767
451 : 'Unavailable For Legal Reasons',
6868
500 : 'Internal Server Error',
6969
501 : 'Not Implemented',

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

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

384384
// For clients, we will always have either a given ca list or be using
385385
// default one
386-
var requestCert = !!options.requestCert || !options.isServer,
387-
rejectUnauthorized = !!options.rejectUnauthorized;
386+
const requestCert = !!options.requestCert || !options.isServer;
387+
const rejectUnauthorized = !!options.rejectUnauthorized;
388388

389389
this._requestCert = requestCert;
390390
this._rejectUnauthorized = rejectUnauthorized;
@@ -486,8 +486,8 @@ TLSSocket.prototype._init = function(socket, wrap) {
486486
};
487487

488488
TLSSocket.prototype.renegotiate = function(options, callback) {
489-
var requestCert = this._requestCert,
490-
rejectUnauthorized = this._rejectUnauthorized;
489+
var requestCert = this._requestCert;
490+
var rejectUnauthorized = this._rejectUnauthorized;
491491

492492
if (this.destroyed)
493493
return;
@@ -981,10 +981,10 @@ exports.connect = function(/* [port, host], options, cb */) {
981981
var hostname = options.servername ||
982982
options.host ||
983983
(options.socket && options.socket._host) ||
984-
'localhost',
985-
NPN = {},
986-
ALPN = {},
987-
context = options.secureContext || tls.createSecureContext(options);
984+
'localhost';
985+
const NPN = {};
986+
const ALPN = {};
987+
const context = options.secureContext || tls.createSecureContext(options);
988988
tls.convertNPNProtocols(options.NPNProtocols, NPN);
989989
tls.convertALPNProtocols(options.ALPNProtocols, ALPN);
990990

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)

0 commit comments

Comments
 (0)