Skip to content

Commit

Permalink
lib: fix style issues after eslint update
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
targos authored and Myles Borins committed Jan 28, 2016
1 parent 8d3fe60 commit 0179241
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 172 deletions.
112 changes: 55 additions & 57 deletions lib/_debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ exports.start = function(argv, stdin, stdout) {
stdin = stdin || process.stdin;
stdout = stdout || process.stdout;

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

stdin.resume();

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


Client.prototype._onResponse = function(res) {
var cb,
index = -1;
var cb;
var index = -1;

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

Client.prototype.reqScopes = function(cb) {
var self = this,
req = {
command: 'scopes',
arguments: {}
};
const self = this;
const req = {
command: 'scopes',
arguments: {}
};

cb = cb || function() {};
this.req(req, function(err, res) {
Expand Down Expand Up @@ -525,8 +525,8 @@ Client.prototype.mirrorObject = function(handle, depth, cb) {
return;
}

var mirror,
waiting = 1;
var mirror;
var waiting = 1;

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

var head = sourceText.slice(0, position),
tail = sourceText.slice(position);
const head = sourceText.slice(0, position);
var tail = sourceText.slice(position);

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

if (body.script) {
if (body.script.name) {
var name = body.script.name,
dir = path.resolve() + '/';
var name = body.script.name;
const dir = path.resolve() + '/';

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

var self = this,
client = this.client;
const self = this;
const client = this.client;

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

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

delta || (delta = 5);

var self = this,
client = this.client,
from = client.currentSourceLine - delta + 1,
to = client.currentSourceLine + delta + 1;
const self = this;
const client = this.client;
const from = client.currentSourceLine - delta + 1;
const to = client.currentSourceLine + delta + 1;

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

var current = lineno == 1 + client.currentSourceLine,
breakpoint = client.breakpoints.some(function(bp) {
return (bp.scriptReq === client.currentScript ||
bp.script === client.currentScript) &&
bp.line == lineno;
});
const current = lineno == 1 + client.currentSourceLine;
const breakpoint = client.breakpoints.some(function(bp) {
return (bp.scriptReq === client.currentScript ||
bp.script === client.currentScript) &&
bp.line == lineno;
});

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

var self = this,
client = this.client;
const self = this;
const client = this.client;

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

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

var client = this.client,
displayNatives = arguments[0] || false,
scripts = [];
const client = this.client;
const displayNatives = arguments[0] || false;
const scripts = [];

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

var self = this,
scriptId,
ambiguous;
const self = this;
var scriptId;
var ambiguous;

// setBreakpoint() should insert breakpoint on current line
if (script === undefined) {
Expand Down Expand Up @@ -1429,10 +1429,10 @@ Interface.prototype.setBreakpoint = function(script, line,
Interface.prototype.clearBreakpoint = function(script, line) {
if (!this.requireConnection()) return;

var ambiguous,
breakpoint,
scriptId,
index;
var ambiguous;
var breakpoint;
var scriptId;
var index;

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

var self = this,
req = {
breakpoint: breakpoint
};
var self = this;
const req = {breakpoint};

self.pause();
self.client.clearBreakpoint(req, function(err, res) {
Expand Down Expand Up @@ -1513,8 +1511,8 @@ Interface.prototype.breakpoints = function() {
Interface.prototype.pause_ = function() {
if (!this.requireConnection()) return;

var self = this,
cmd = 'process._debugPause();';
const self = this;
const cmd = 'process._debugPause();';

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

// Spawns child process (and restores breakpoints)
Interface.prototype.trySpawn = function(cb) {
var self = this,
breakpoints = this.breakpoints || [],
port = exports.port,
host = '127.0.0.1',
childArgs = this.args;
const self = this;
const breakpoints = this.breakpoints || [];
var port = exports.port;
var host = '127.0.0.1';
var childArgs = this.args;

this.killChild();
assert(!this.child);
Expand Down Expand Up @@ -1676,8 +1674,8 @@ Interface.prototype.trySpawn = function(cb) {

this.pause();

var client = self.client = new Client(),
connectionAttempts = 0;
const client = self.client = new Client();
var connectionAttempts = 0;

client.once('ready', function() {
self.stdout.write(' ok\n');
Expand Down
2 changes: 1 addition & 1 deletion lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const STATUS_CODES = exports.STATUS_CODES = {
426 : 'Upgrade Required', // RFC 2817
428 : 'Precondition Required', // RFC 6585
429 : 'Too Many Requests', // RFC 6585
431 : 'Request Header Fields Too Large',// RFC 6585
431 : 'Request Header Fields Too Large', // RFC 6585
500 : 'Internal Server Error',
501 : 'Not Implemented',
502 : 'Bad Gateway',
Expand Down
16 changes: 8 additions & 8 deletions lib/_tls_legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ CryptoStream.prototype._write = function write(data, encoding, cb) {


CryptoStream.prototype._writePending = function writePending() {
var data = this._pending,
encoding = this._pendingEncoding,
cb = this._pendingCallback;
const data = this._pending;
const encoding = this._pendingEncoding;
const cb = this._pendingCallback;

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

var bytesRead = 0,
start = this._buffer.offset,
last = start;
var bytesRead = 0;
const start = this._buffer.offset;
var last = start;
do {
assert(last === this._buffer.offset);
var read = this._buffer.use(this.pair.ssl, out, size - bytesRead);
Expand Down Expand Up @@ -604,8 +604,8 @@ function onhandshakedone() {


function onclienthello(hello) {
var self = this,
once = false;
const self = this;
var once = false;

this._resumingSession = true;
function callback(err, session) {
Expand Down
14 changes: 7 additions & 7 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ TLSSocket.prototype._init = function(socket, wrap) {

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

this._requestCert = requestCert;
this._rejectUnauthorized = rejectUnauthorized;
Expand Down Expand Up @@ -494,8 +494,8 @@ TLSSocket.prototype._init = function(socket, wrap) {
};

TLSSocket.prototype.renegotiate = function(options, callback) {
var requestCert = this._requestCert,
rejectUnauthorized = this._rejectUnauthorized;
var requestCert = this._requestCert;
var rejectUnauthorized = this._rejectUnauthorized;

if (this.destroyed)
return;
Expand Down Expand Up @@ -966,9 +966,9 @@ exports.connect = function(/* [port, host], options, cb */) {
var hostname = options.servername ||
options.host ||
(options.socket && options.socket._host) ||
'localhost',
NPN = {},
context = tls.createSecureContext(options);
'localhost';
const NPN = {};
const context = tls.createSecureContext(options);
tls.convertNPNProtocols(options.NPNProtocols, NPN);

var socket = new TLSSocket(options.socket, {
Expand Down
10 changes: 5 additions & 5 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,18 @@ function objEquiv(a, b, strict) {
return a === b;
if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
return false;
var aIsArgs = isArguments(a),
bIsArgs = isArguments(b);
const aIsArgs = isArguments(a);
const bIsArgs = isArguments(b);
if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
return false;
if (aIsArgs) {
a = pSlice.call(a);
b = pSlice.call(b);
return _deepEqual(a, b, strict);
}
var ka = Object.keys(a),
kb = Object.keys(b),
key, i;
const ka = Object.keys(a);
const kb = Object.keys(b);
var key, i;
// having the same number of owned properties (keys incorporates
// hasOwnProperty)
if (ka.length !== kb.length)
Expand Down
22 changes: 11 additions & 11 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@ fs.openSync = function(path, flags, mode) {
fs.read = function(fd, buffer, offset, length, position, callback) {
if (!(buffer instanceof Buffer)) {
// legacy string interface (fd, length, position, encoding, callback)
var cb = arguments[4],
encoding = arguments[3];
const cb = arguments[4];
const encoding = arguments[3];

assertEncoding(encoding);

Expand Down Expand Up @@ -1388,9 +1388,9 @@ fs.realpathSync = function realpathSync(p, cache) {
return cache[p];
}

var original = p,
seenLinks = {},
knownHard = {};
const original = p;
const seenLinks = {};
const knownHard = {};

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

var original = p,
seenLinks = {},
knownHard = {};
const original = p;
const seenLinks = {};
const knownHard = {};

// current character position in p
var pos;
Expand Down Expand Up @@ -1941,9 +1941,9 @@ util.inherits(SyncWriteStream, Stream);

// Export
Object.defineProperty(fs, 'SyncWriteStream', {
configurable: true,
writable: true,
value: SyncWriteStream
configurable: true,
writable: true,
value: SyncWriteStream
});

SyncWriteStream.prototype.write = function(data, arg1, arg2) {
Expand Down
Loading

0 comments on commit 0179241

Please sign in to comment.