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 <me@silverwind.io>
  • Loading branch information
targos authored and silverwind committed Jan 13, 2016
1 parent 4d5ee7a commit 7ce0e04
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 173 deletions.
112 changes: 55 additions & 57 deletions lib/_debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,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 @@ -198,8 +198,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 @@ -296,11 +296,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 @@ -526,8 +526,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 @@ -678,8 +678,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 @@ -699,8 +699,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 @@ -977,8 +977,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 @@ -1012,9 +1012,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 @@ -1086,10 +1086,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 @@ -1104,12 +1104,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 @@ -1147,8 +1147,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 @@ -1161,8 +1161,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 @@ -1191,9 +1191,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 @@ -1331,9 +1331,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 @@ -1437,10 +1437,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 @@ -1482,10 +1482,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 @@ -1521,8 +1519,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 @@ -1643,11 +1641,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 @@ -1698,8 +1696,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 @@ -63,7 +63,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
451 : 'Unavailable For Legal Reasons',
500 : 'Internal Server Error',
501 : 'Not Implemented',
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
16 changes: 8 additions & 8 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,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 @@ -486,8 +486,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 @@ -981,10 +981,10 @@ exports.connect = function(/* [port, host], options, cb */) {
var hostname = options.servername ||
options.host ||
(options.socket && options.socket._host) ||
'localhost',
NPN = {},
ALPN = {},
context = options.secureContext || tls.createSecureContext(options);
'localhost';
const NPN = {};
const ALPN = {};
const context = options.secureContext || tls.createSecureContext(options);
tls.convertNPNProtocols(options.NPNProtocols, NPN);
tls.convertALPNProtocols(options.ALPNProtocols, ALPN);

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
Loading

0 comments on commit 7ce0e04

Please sign in to comment.