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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
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);

0 commit comments

Comments
 (0)