Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: update eslint to v1.x #2286

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 1 addition & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ rules:
no-duplicate-case: 2
## disallow assignment of exceptional params
no-ex-assign: 2
## disallow use of reserved words as keys like enum, class
no-reserved-keys: 2
## disallow unreachable code
no-unreachable: 2
## require valid typeof compared string like typeof foo === 'strnig'
Expand All @@ -44,7 +42,7 @@ rules:
## use single quote, we can use double quote when escape chars
quotes: [2, "single", "avoid-escape"]
## 2 space indentation
indent: [2, 2]
indent: [2, 2, {SwitchCase: 1}]
## add space after comma
comma-spacing: 2
## put semi-colon
Expand Down Expand Up @@ -112,5 +110,3 @@ globals:
DTRACE_NET_SERVER_CONNECTION : false
LTTNG_NET_SERVER_CONNECTION : false
COUNTER_NET_SERVER_CONNECTION : false
escape : false
unescape : false
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ icu_config.gypi

# various stuff that VC++ produces/uses
Debug/
!deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug
!**/node_modules/debug/
!deps/v8/src/debug/
Release/
!doc/blog/**
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ bench-idle:

jslint:
$(NODE) tools/eslint/bin/eslint.js src lib test tools/eslint-rules \
--rulesdir tools/eslint-rules --reset --quiet
--rulesdir tools/eslint-rules --quiet

CPPLINT_EXCLUDE ?=
CPPLINT_EXCLUDE += src/node_lttng.cc
Expand Down
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