mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
test: use eslint to fix var->const/let
Manually fix issues that eslint --fix couldn't do automatically. Backport-PR-URL: https://github.com/nodejs/node/pull/11775 PR-URL: https://github.com/nodejs/node/pull/10685 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
This commit is contained in:
1 parent
de63698066
commit
db61c952de
806 files changed
+5031
-4995
No files matched your search
@@ -1,15 +1,15 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
var assert = require('assert');
|
||||
var spawn = require('child_process').spawn;
|
||||
const assert = require('assert');
|
||||
const spawn = require('child_process').spawn;
|
||||
|
||||
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
|
||||
var port = common.PORT;
|
||||
const port = common.PORT;
|
||||
|
||||
var child;
|
||||
var buffer = '';
|
||||
var expected = [];
|
||||
var quit;
|
||||
let child;
|
||||
let buffer = '';
|
||||
const expected = [];
|
||||
let quit;
|
||||
|
||||
function startDebugger(scriptToDebug) {
|
||||
scriptToDebug = process.env.NODE_DEBUGGER_TEST_SCRIPT ||
|
||||
@@ -34,23 +34,23 @@ function startDebugger(scriptToDebug) {
|
||||
console.log(line);
|
||||
assert.ok(expected.length > 0, 'Got unexpected line: ' + line);
|
||||
|
||||
var expectedLine = expected[0].lines.shift();
|
||||
const expectedLine = expected[0].lines.shift();
|
||||
assert.ok(line.match(expectedLine) !== null, line + ' != ' + expectedLine);
|
||||
|
||||
if (expected[0].lines.length === 0) {
|
||||
var callback = expected[0].callback;
|
||||
const callback = expected[0].callback;
|
||||
expected.shift();
|
||||
callback && callback();
|
||||
}
|
||||
});
|
||||
|
||||
var childClosed = false;
|
||||
let childClosed = false;
|
||||
child.on('close', function(code) {
|
||||
assert(!code);
|
||||
childClosed = true;
|
||||
});
|
||||
|
||||
var quitCalled = false;
|
||||
let quitCalled = false;
|
||||
quit = function() {
|
||||
if (quitCalled || childClosed) return;
|
||||
quitCalled = true;
|
||||
@@ -60,7 +60,7 @@ function startDebugger(scriptToDebug) {
|
||||
|
||||
setTimeout(function() {
|
||||
console.error('dying badly buffer=%j', buffer);
|
||||
var err = 'Timeout';
|
||||
let err = 'Timeout';
|
||||
if (expected.length > 0 && expected[0].lines) {
|
||||
err = err + '. Expected: ' + expected[0].lines.shift();
|
||||
}
|
||||
@@ -95,7 +95,7 @@ function addTest(input, output) {
|
||||
child.stdin.write(expected[0].input + '\n');
|
||||
|
||||
if (!expected[0].lines) {
|
||||
var callback = expected[0].callback;
|
||||
const callback = expected[0].callback;
|
||||
expected.shift();
|
||||
|
||||
callback && callback();
|
||||
@@ -107,17 +107,17 @@ function addTest(input, output) {
|
||||
expected.push({input: input, lines: output, callback: next});
|
||||
}
|
||||
|
||||
var handshakeLines = [
|
||||
const handshakeLines = [
|
||||
/listening on /,
|
||||
/connecting.* ok/
|
||||
];
|
||||
|
||||
var initialBreakLines = [
|
||||
const initialBreakLines = [
|
||||
/break in .*:1/,
|
||||
/1/, /2/, /3/
|
||||
];
|
||||
|
||||
var initialLines = handshakeLines.concat(initialBreakLines);
|
||||
const initialLines = handshakeLines.concat(initialBreakLines);
|
||||
|
||||
// Process initial lines
|
||||
addTest(null, initialLines);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
var assert = require('assert');
|
||||
var debug = require('_debugger');
|
||||
const assert = require('assert');
|
||||
const debug = require('_debugger');
|
||||
|
||||
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
|
||||
var debugPort = common.PORT;
|
||||
const debugPort = common.PORT;
|
||||
debug.port = debugPort;
|
||||
var spawn = require('child_process').spawn;
|
||||
const spawn = require('child_process').spawn;
|
||||
|
||||
setTimeout(function() {
|
||||
if (nodeProcess) nodeProcess.kill('SIGTERM');
|
||||
@@ -14,8 +14,8 @@ setTimeout(function() {
|
||||
}, 10000).unref();
|
||||
|
||||
|
||||
var resCount = 0;
|
||||
var p = new debug.Protocol();
|
||||
let resCount = 0;
|
||||
const p = new debug.Protocol();
|
||||
p.onResponse = function() {
|
||||
resCount++;
|
||||
};
|
||||
@@ -29,12 +29,12 @@ assert.strictEqual(resCount, 1);
|
||||
|
||||
// Make sure split messages go in.
|
||||
|
||||
var parts = [];
|
||||
const parts = [];
|
||||
parts.push('Content-Length: 336\r\n');
|
||||
assert.strictEqual(parts[0].length, 21);
|
||||
parts.push('\r\n');
|
||||
assert.strictEqual(parts[1].length, 2);
|
||||
var bodyLength = 0;
|
||||
let bodyLength = 0;
|
||||
|
||||
parts.push('{"seq":12,"type":"event","event":"break","body":' +
|
||||
'{"invocationText":"#<a Server>');
|
||||
@@ -55,7 +55,7 @@ bodyLength += parts[4].length;
|
||||
|
||||
assert.strictEqual(bodyLength, 336);
|
||||
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
p.execute(parts[i]);
|
||||
}
|
||||
assert.strictEqual(resCount, 2);
|
||||
@@ -63,24 +63,24 @@ assert.strictEqual(resCount, 2);
|
||||
|
||||
// Make sure that if we get backed up, we still manage to get all the
|
||||
// messages
|
||||
var d = 'Content-Length: 466\r\n\r\n' +
|
||||
'{"seq":10,"type":"event","event":"afterCompile","success":true,' +
|
||||
'"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
|
||||
'"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,' +
|
||||
'"sourceStart":"(function(module, exports, require) {' +
|
||||
'var dns = process.binding(\'cares\')' +
|
||||
';\\nvar ne","sourceLength":6137,"scriptType":2,"compilationType":0,' +
|
||||
'"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' +
|
||||
'[{"handle":0' +
|
||||
',"type":"context","text":"#<a ContextMirror>"}],"running":true}' +
|
||||
'\r\n\r\nContent-Length: 119\r\n\r\n' +
|
||||
'{"seq":11,"type":"event","event":"scriptCollected","success":true,' +
|
||||
'"body":{"script":{"id":26}},"refs":[],"running":true}';
|
||||
const d = 'Content-Length: 466\r\n\r\n' +
|
||||
'{"seq":10,"type":"event","event":"afterCompile","success":true,' +
|
||||
'"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
|
||||
'"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,' +
|
||||
'"sourceStart":"(function(module, exports, require) {' +
|
||||
'let dns = process.binding(\'cares\')' +
|
||||
';\\nlet ne","sourceLength":6137,"scriptType":2,"compilationType":0' +
|
||||
',"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' +
|
||||
'[{"handle":0' +
|
||||
',"type":"context","text":"#<a ContextMirror>"}],"running":true}' +
|
||||
'\r\n\r\nContent-Length: 119\r\n\r\n' +
|
||||
'{"seq":11,"type":"event","event":"scriptCollected","success":true,' +
|
||||
'"body":{"script":{"id":26}},"refs":[],"running":true}';
|
||||
p.execute(d);
|
||||
assert.strictEqual(resCount, 4);
|
||||
|
||||
var expectedConnections = 0;
|
||||
var tests = [];
|
||||
let expectedConnections = 0;
|
||||
const tests = [];
|
||||
function addTest(cb) {
|
||||
expectedConnections++;
|
||||
tests.push(cb);
|
||||
@@ -102,9 +102,9 @@ addTest(function(client, done) {
|
||||
assert.ifError(err);
|
||||
console.error('got %d scripts', Object.keys(client.scripts).length);
|
||||
|
||||
var foundMainScript = false;
|
||||
for (var k in client.scripts) {
|
||||
var script = client.scripts[k];
|
||||
let foundMainScript = false;
|
||||
for (const k in client.scripts) {
|
||||
const script = client.scripts[k];
|
||||
if (script && script.name === 'bootstrap_node.js') {
|
||||
foundMainScript = true;
|
||||
break;
|
||||
@@ -127,19 +127,19 @@ addTest(function(client, done) {
|
||||
});
|
||||
|
||||
|
||||
var connectCount = 0;
|
||||
var script = 'setTimeout(function() { console.log("blah"); });' +
|
||||
'setInterval(function() {}, 1000000);';
|
||||
let connectCount = 0;
|
||||
const script = 'setTimeout(function() { console.log("blah"); });' +
|
||||
'setInterval(function() {}, 1000000);';
|
||||
|
||||
var nodeProcess;
|
||||
let nodeProcess;
|
||||
|
||||
function doTest(cb, done) {
|
||||
var args = ['--debug=' + debugPort, '-e', script];
|
||||
const args = ['--debug=' + debugPort, '-e', script];
|
||||
nodeProcess = spawn(process.execPath, args);
|
||||
|
||||
nodeProcess.stdout.once('data', function() {
|
||||
console.log('>>> new node process: %d', nodeProcess.pid);
|
||||
var failed = true;
|
||||
let failed = true;
|
||||
try {
|
||||
process._debugProcess(nodeProcess.pid);
|
||||
failed = false;
|
||||
@@ -151,9 +151,9 @@ function doTest(cb, done) {
|
||||
console.log('>>> starting debugger session');
|
||||
});
|
||||
|
||||
var didTryConnect = false;
|
||||
let didTryConnect = false;
|
||||
nodeProcess.stderr.setEncoding('utf8');
|
||||
var b = '';
|
||||
let b = '';
|
||||
nodeProcess.stderr.on('data', function(data) {
|
||||
console.error('got stderr data %j', data);
|
||||
nodeProcess.stderr.resume();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
var repl = require('./helper-debugger-repl.js');
|
||||
const repl = require('./helper-debugger-repl.js');
|
||||
|
||||
repl.startDebugger('break-in-module/main.js');
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
var repl = require('./helper-debugger-repl.js');
|
||||
const repl = require('./helper-debugger-repl.js');
|
||||
|
||||
repl.startDebugger('breakpoints.js');
|
||||
var linesWithBreakpoint = [
|
||||
const linesWithBreakpoint = [
|
||||
/1/, /2/, /3/, /4/, /5/, /\* 6/
|
||||
];
|
||||
// We slice here, because addTest will change the given array.
|
||||
repl.addTest('sb(6)', linesWithBreakpoint.slice());
|
||||
|
||||
var initialLines = repl.initialLines.slice();
|
||||
const initialLines = repl.initialLines.slice();
|
||||
initialLines.splice(2, 0, /Restoring/, /Warning/);
|
||||
|
||||
// Restart the debugged script
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
require('../common');
|
||||
process.env.NODE_FORCE_READLINE = 1;
|
||||
|
||||
var repl = require('./helper-debugger-repl.js');
|
||||
const repl = require('./helper-debugger-repl.js');
|
||||
|
||||
repl.startDebugger('breakpoints.js');
|
||||
|
||||
var addTest = repl.addTest;
|
||||
const addTest = repl.addTest;
|
||||
|
||||
// next
|
||||
addTest('n', [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
var common = require('../common');
|
||||
var script = common.fixturesDir + '/breakpoints_utf8.js';
|
||||
const common = require('../common');
|
||||
const script = common.fixturesDir + '/breakpoints_utf8.js';
|
||||
process.env.NODE_DEBUGGER_TEST_SCRIPT = script;
|
||||
|
||||
require('./test-debugger-repl.js');
|
||||
@@ -1,10 +1,10 @@
|
||||
'use strict';
|
||||
var common = require('../common');
|
||||
var repl = require('./helper-debugger-repl.js');
|
||||
const common = require('../common');
|
||||
const repl = require('./helper-debugger-repl.js');
|
||||
|
||||
repl.startDebugger('breakpoints.js');
|
||||
|
||||
var addTest = repl.addTest;
|
||||
const addTest = repl.addTest;
|
||||
|
||||
// Next
|
||||
addTest('n', [
|
||||
|
||||
Reference in new issue
Block a user