Skip to content

Commit 7a0e462

Browse files
committed
test: use eslint to fix var->const/let
Manually fix issues that eslint --fix couldn't do automatically. PR-URL: #10685 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
1 parent 1ef401c commit 7a0e462

File tree

730 files changed

+3390
-3371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

730 files changed

+3390
-3371
lines changed

test/addons/buffer-free-callback/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const common = require('../../common');
55
const binding = require(`./build/${common.buildType}/binding`);
66

77
function check(size, alignment, offset) {
8-
var buf = binding.alloc(size, alignment, offset);
9-
var slice = buf.slice(size >>> 1);
8+
let buf = binding.alloc(size, alignment, offset);
9+
let slice = buf.slice(size >>> 1);
1010

1111
buf = null;
1212
binding.check(slice);

test/addons/load-long-path/test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ common.refreshTmpDir();
1414
// make a path that is more than 260 chars long.
1515
// Any given folder cannot have a name longer than 260 characters,
1616
// so create 10 nested folders each with 30 character long names.
17-
var addonDestinationDir = path.resolve(common.tmpDir);
17+
let addonDestinationDir = path.resolve(common.tmpDir);
1818

19-
for (var i = 0; i < 10; i++) {
19+
for (let i = 0; i < 10; i++) {
2020
addonDestinationDir = path.join(addonDestinationDir, 'x'.repeat(30));
2121
fs.mkdirSync(addonDestinationDir);
2222
}
@@ -28,7 +28,7 @@ const addonPath = path.join(__dirname,
2828
const addonDestinationPath = path.join(addonDestinationDir, 'binding.node');
2929

3030
// Copy binary to long path destination
31-
var contents = fs.readFileSync(addonPath);
31+
const contents = fs.readFileSync(addonPath);
3232
fs.writeFileSync(addonDestinationPath, contents);
3333

3434
// Attempt to load at long path destination

test/addons/make-callback-recurse/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ assert.throws(function() {
6565
results.push(2);
6666

6767
setImmediate(common.mustCall(function() {
68-
for (var i = 0; i < results.length; i++) {
68+
for (let i = 0; i < results.length; i++) {
6969
assert.strictEqual(results[i], i,
7070
`verifyExecutionOrder(${arg}) results: ${results}`);
7171
}

test/addons/repl-domain-abort/test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ const assert = require('assert');
44
const repl = require('repl');
55
const stream = require('stream');
66
const path = require('path');
7-
var buildType = process.config.target_defaults.default_configuration;
8-
var buildPath = path.join(__dirname, 'build', buildType, 'binding');
7+
const buildType = process.config.target_defaults.default_configuration;
8+
let buildPath = path.join(__dirname, 'build', buildType, 'binding');
99
// On Windows, escape backslashes in the path before passing it to REPL.
1010
if (common.isWindows)
1111
buildPath = buildPath.replace(/\\/g, '/');
12-
var cb_ran = false;
12+
let cb_ran = false;
1313

1414
process.on('exit', function() {
1515
assert(cb_ran);
1616
console.log('ok');
1717
});
1818

19-
var lines = [
19+
const lines = [
2020
// This line shouldn't cause an assertion error.
2121
'require(\'' + buildPath + '\')' +
2222
// Log output to double check callback ran.
2323
'.method(function() { console.log(\'cb_ran\'); });',
2424
];
2525

26-
var dInput = new stream.Readable();
27-
var dOutput = new stream.Writable();
26+
const dInput = new stream.Readable();
27+
const dOutput = new stream.Writable();
2828

2929
dInput._read = function _read(size) {
3030
while (lines.length > 0 && this.push(lines.shift()));
@@ -38,7 +38,7 @@ dOutput._write = function _write(chunk, encoding, cb) {
3838
cb();
3939
};
4040

41-
var options = {
41+
const options = {
4242
input: dInput,
4343
output: dOutput,
4444
terminal: false,

test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
1414
return;
1515
}
1616

17+
let buf;
1718
try {
18-
var buf = Buffer.allocUnsafe(kStringMaxLength);
19+
buf = Buffer.allocUnsafe(kStringMaxLength);
1920
} catch (e) {
2021
// If the exception is not due to memory confinement then rethrow it.
2122
if (e.message !== 'Array buffer allocation failed') throw (e);

test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
1414
// v8::String::kMaxLength defined in v8.h
1515
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
1616

17+
let buf;
1718
try {
18-
var buf = Buffer.allocUnsafe(kStringMaxLength + 1);
19+
buf = Buffer.allocUnsafe(kStringMaxLength + 1);
1920
} catch (e) {
2021
// If the exception is not due to memory confinement then rethrow it.
2122
if (e.message !== 'Array buffer allocation failed') throw (e);

test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
1414
// v8::String::kMaxLength defined in v8.h
1515
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
1616

17+
let buf;
1718
try {
18-
var buf = Buffer.allocUnsafe(kStringMaxLength + 1);
19+
buf = Buffer.allocUnsafe(kStringMaxLength + 1);
1920
} catch (e) {
2021
// If the exception is not due to memory confinement then rethrow it.
2122
if (e.message !== 'Array buffer allocation failed') throw (e);

test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
1414
// v8::String::kMaxLength defined in v8.h
1515
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
1616

17+
let buf;
1718
try {
18-
var buf = Buffer.allocUnsafe(kStringMaxLength + 1);
19+
buf = Buffer.allocUnsafe(kStringMaxLength + 1);
1920
} catch (e) {
2021
// If the exception is not due to memory confinement then rethrow it.
2122
if (e.message !== 'Array buffer allocation failed') throw (e);
@@ -33,7 +34,7 @@ assert.throws(function() {
3334
buf.toString('latin1');
3435
}, /"toString\(\)" failed/);
3536

36-
var maxString = buf.toString('latin1', 1);
37+
let maxString = buf.toString('latin1', 1);
3738
assert.strictEqual(maxString.length, kStringMaxLength);
3839
// Free the memory early instead of at the end of the next assignment
3940
maxString = undefined;

test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
1414
// v8::String::kMaxLength defined in v8.h
1515
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
1616

17+
let buf;
1718
try {
18-
var buf = Buffer.allocUnsafe(kStringMaxLength + 1);
19+
buf = Buffer.allocUnsafe(kStringMaxLength + 1);
1920
} catch (e) {
2021
// If the exception is not due to memory confinement then rethrow it.
2122
if (e.message !== 'Array buffer allocation failed') throw (e);

test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
1414
// v8::String::kMaxLength defined in v8.h
1515
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
1616

17+
let buf;
1718
try {
18-
var buf = Buffer.allocUnsafe(kStringMaxLength + 1);
19+
buf = Buffer.allocUnsafe(kStringMaxLength + 1);
1920
} catch (e) {
2021
// If the exception is not due to memory confinement then rethrow it.
2122
if (e.message !== 'Array buffer allocation failed') throw (e);

test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
1414
// v8::String::kMaxLength defined in v8.h
1515
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
1616

17+
let buf;
1718
try {
18-
var buf = Buffer.allocUnsafe(kStringMaxLength + 2);
19+
buf = Buffer.allocUnsafe(kStringMaxLength + 2);
1920
} catch (e) {
2021
// If the exception is not due to memory confinement then rethrow it.
2122
if (e.message !== 'Array buffer allocation failed') throw (e);

test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
1414
// v8::String::kMaxLength defined in v8.h
1515
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
1616

17+
let buf;
1718
try {
18-
var buf = Buffer.allocUnsafe(kStringMaxLength * 2 + 2);
19+
buf = Buffer.allocUnsafe(kStringMaxLength * 2 + 2);
1920
} catch (e) {
2021
// If the exception is not due to memory confinement then rethrow it.
2122
if (e.message !== 'Array buffer allocation failed') throw (e);

test/common.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ exports.hasIPv6 = Object.keys(ifaces).some(function(name) {
212212
* the process aborts.
213213
*/
214214
exports.childShouldThrowAndAbort = function() {
215-
var testCmd = '';
215+
let testCmd = '';
216216
if (!exports.isWindows) {
217217
// Do not create core files, as it can take a lot of disk space on
218218
// continuous testing and developers' machines

test/debugger/helper-debugger-repl.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ const assert = require('assert');
44
const spawn = require('child_process').spawn;
55

66
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
7-
var port = common.PORT;
7+
const port = common.PORT;
88

9-
var child;
10-
var buffer = '';
11-
var expected = [];
12-
var quit;
9+
let child;
10+
let buffer = '';
11+
const expected = [];
12+
let quit;
1313

1414
function startDebugger(scriptToDebug) {
1515
scriptToDebug = process.env.NODE_DEBUGGER_TEST_SCRIPT ||
@@ -34,23 +34,23 @@ function startDebugger(scriptToDebug) {
3434
console.log(line);
3535
assert.ok(expected.length > 0, 'Got unexpected line: ' + line);
3636

37-
var expectedLine = expected[0].lines.shift();
37+
const expectedLine = expected[0].lines.shift();
3838
assert.ok(line.match(expectedLine) !== null, line + ' != ' + expectedLine);
3939

4040
if (expected[0].lines.length === 0) {
41-
var callback = expected[0].callback;
41+
const callback = expected[0].callback;
4242
expected.shift();
4343
callback && callback();
4444
}
4545
});
4646

47-
var childClosed = false;
47+
let childClosed = false;
4848
child.on('close', function(code) {
4949
assert(!code);
5050
childClosed = true;
5151
});
5252

53-
var quitCalled = false;
53+
let quitCalled = false;
5454
quit = function() {
5555
if (quitCalled || childClosed) return;
5656
quitCalled = true;
@@ -60,7 +60,7 @@ function startDebugger(scriptToDebug) {
6060

6161
setTimeout(function() {
6262
console.error('dying badly buffer=%j', buffer);
63-
var err = 'Timeout';
63+
let err = 'Timeout';
6464
if (expected.length > 0 && expected[0].lines) {
6565
err = err + '. Expected: ' + expected[0].lines.shift();
6666
}
@@ -95,7 +95,7 @@ function addTest(input, output) {
9595
child.stdin.write(expected[0].input + '\n');
9696

9797
if (!expected[0].lines) {
98-
var callback = expected[0].callback;
98+
const callback = expected[0].callback;
9999
expected.shift();
100100

101101
callback && callback();
@@ -107,17 +107,17 @@ function addTest(input, output) {
107107
expected.push({input: input, lines: output, callback: next});
108108
}
109109

110-
var handshakeLines = [
110+
const handshakeLines = [
111111
/listening on /,
112112
/connecting.* ok/
113113
];
114114

115-
var initialBreakLines = [
115+
const initialBreakLines = [
116116
/break in .*:1/,
117117
/1/, /2/, /3/
118118
];
119119

120-
var initialLines = handshakeLines.concat(initialBreakLines);
120+
const initialLines = handshakeLines.concat(initialBreakLines);
121121

122122
// Process initial lines
123123
addTest(null, initialLines);

test/debugger/test-debugger-repl-restart.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ require('../common');
33
const repl = require('./helper-debugger-repl.js');
44

55
repl.startDebugger('breakpoints.js');
6-
var linesWithBreakpoint = [
6+
const linesWithBreakpoint = [
77
/1/, /2/, /3/, /4/, /5/, /\* 6/
88
];
99
// We slice here, because addTest will change the given array.
1010
repl.addTest('sb(6)', linesWithBreakpoint.slice());
1111

12-
var initialLines = repl.initialLines.slice();
12+
const initialLines = repl.initialLines.slice();
1313
initialLines.splice(2, 0, /Restoring/, /Warning/);
1414

1515
// Restart the debugged script

test/debugger/test-debugger-repl-term.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const repl = require('./helper-debugger-repl.js');
66

77
repl.startDebugger('breakpoints.js');
88

9-
var addTest = repl.addTest;
9+
const addTest = repl.addTest;
1010

1111
// next
1212
addTest('n', [
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
const common = require('../common');
3-
var script = common.fixturesDir + '/breakpoints_utf8.js';
3+
const script = common.fixturesDir + '/breakpoints_utf8.js';
44
process.env.NODE_DEBUGGER_TEST_SCRIPT = script;
55

66
require('./test-debugger-repl.js');

test/debugger/test-debugger-repl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const repl = require('./helper-debugger-repl.js');
44

55
repl.startDebugger('breakpoints.js');
66

7-
var addTest = repl.addTest;
7+
const addTest = repl.addTest;
88

99
// Next
1010
addTest('n', [

test/gc/test-http-client-connaborted.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let countGC = 0;
1818

1919
console.log('We should do ' + todo + ' requests');
2020

21-
var server = http.createServer(serverHandler);
21+
const server = http.createServer(serverHandler);
2222
server.listen(0, getall);
2323

2424
function getall() {
@@ -31,7 +31,7 @@ function getall() {
3131
statusLater();
3232
}
3333

34-
var req = http.get({
34+
const req = http.get({
3535
hostname: 'localhost',
3636
pathname: '/',
3737
port: server.address().port
@@ -44,14 +44,14 @@ function getall() {
4444
setImmediate(getall);
4545
}
4646

47-
for (var i = 0; i < 10; i++)
47+
for (let i = 0; i < 10; i++)
4848
getall();
4949

5050
function afterGC() {
5151
countGC++;
5252
}
5353

54-
var timer;
54+
let timer;
5555
function statusLater() {
5656
global.gc();
5757
if (timer) clearTimeout(timer);

test/gc/test-http-client-onerror.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let countGC = 0;
2020

2121
console.log('We should do ' + todo + ' requests');
2222

23-
var server = http.createServer(serverHandler);
23+
const server = http.createServer(serverHandler);
2424
server.listen(0, runTest);
2525

2626
function getall() {
@@ -37,7 +37,7 @@ function getall() {
3737
throw er;
3838
}
3939

40-
var req = http.get({
40+
const req = http.get({
4141
hostname: 'localhost',
4242
pathname: '/',
4343
port: server.address().port
@@ -51,15 +51,15 @@ function getall() {
5151
}
5252

5353
function runTest() {
54-
for (var i = 0; i < 10; i++)
54+
for (let i = 0; i < 10; i++)
5555
getall();
5656
}
5757

5858
function afterGC() {
5959
countGC++;
6060
}
6161

62-
var timer;
62+
let timer;
6363
function statusLater() {
6464
global.gc();
6565
if (timer) clearTimeout(timer);

0 commit comments

Comments
 (0)