Skip to content

Commit db61c95

Browse files
gibfahnMylesBorins
authored andcommitted
test: use eslint to fix var->const/let
Manually fix issues that eslint --fix couldn't do automatically. Backport-PR-URL: #11775 PR-URL: #10685 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
1 parent de63698 commit db61c95

File tree

806 files changed

+5037
-5001
lines changed

Some content is hidden

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

806 files changed

+5037
-5001
lines changed

test/addons/async-hello-world/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
const common = require('../../common');
3-
var assert = require('assert');
3+
const assert = require('assert');
44
const binding = require(`./build/${common.buildType}/binding`);
55

66
binding(5, common.mustCall(function(err, val) {

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

Lines changed: 2 additions & 2 deletions
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);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
const common = require('../../common');
3-
var assert = require('assert');
3+
const assert = require('assert');
44
const binding = require(`./build/${common.buildType}/binding`);
55
assert.strictEqual(binding(), 'world');
66
console.log('binding.hello() =', binding());

test/addons/hello-world/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
const common = require('../../common');
3-
var assert = require('assert');
3+
const assert = require('assert');
44
const binding = require(`./build/${common.buildType}/binding`);
55
assert.strictEqual(binding.hello(), 'world');
66
console.log('binding.hello() =', binding.hello());

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

Lines changed: 4 additions & 4 deletions
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,10 +28,10 @@ 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
35-
var addon = require(addonDestinationPath);
35+
const addon = require(addonDestinationPath);
3636
assert.notEqual(addon, null);
3737
assert.strictEqual(addon.hello(), 'world');

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
'use strict';
2-
var common = require('../../common');
3-
var assert = require('assert');
4-
var repl = require('repl');
5-
var stream = require('stream');
6-
var path = require('path');
7-
var buildType = process.config.target_defaults.default_configuration;
8-
var buildPath = path.join(__dirname, 'build', buildType, 'binding');
2+
const common = require('../../common');
3+
const assert = require('assert');
4+
const repl = require('repl');
5+
const stream = require('stream');
6+
const path = require('path');
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ exports.hasIPv6 = Object.keys(ifaces).some(function(name) {
208208
* the process aborts.
209209
*/
210210
exports.childShouldThrowAndAbort = function() {
211-
var testCmd = '';
211+
let testCmd = '';
212212
if (!exports.isWindows) {
213213
// Do not create core files, as it can take a lot of disk space on
214214
// continuous testing and developers' machines

test/debugger/helper-debugger-repl.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use strict';
22
const common = require('../common');
3-
var assert = require('assert');
4-
var spawn = require('child_process').spawn;
3+
const assert = require('assert');
4+
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);

0 commit comments

Comments
 (0)