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,8 +1,8 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
var assert = require('assert');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
console.error('load test-module-loading.js');
|
||||
|
||||
@@ -15,21 +15,21 @@ assert.strictEqual(process.mainModule, module,
|
||||
require('../fixtures/not-main-module.js');
|
||||
|
||||
// require a file with a request that includes the extension
|
||||
var a_js = require('../fixtures/a.js');
|
||||
const a_js = require('../fixtures/a.js');
|
||||
assert.strictEqual(42, a_js.number);
|
||||
|
||||
// require a file without any extensions
|
||||
var foo_no_ext = require('../fixtures/foo');
|
||||
const foo_no_ext = require('../fixtures/foo');
|
||||
assert.strictEqual('ok', foo_no_ext.foo);
|
||||
|
||||
var a = require('../fixtures/a');
|
||||
var c = require('../fixtures/b/c');
|
||||
var d = require('../fixtures/b/d');
|
||||
var d2 = require('../fixtures/b/d');
|
||||
const a = require('../fixtures/a');
|
||||
const c = require('../fixtures/b/c');
|
||||
const d = require('../fixtures/b/d');
|
||||
const d2 = require('../fixtures/b/d');
|
||||
// Absolute
|
||||
var d3 = require(path.join(__dirname, '../fixtures/b/d'));
|
||||
const d3 = require(path.join(__dirname, '../fixtures/b/d'));
|
||||
// Relative
|
||||
var d4 = require('../fixtures/b/d');
|
||||
const d4 = require('../fixtures/b/d');
|
||||
|
||||
assert.strictEqual(false, false, 'testing the test program.');
|
||||
|
||||
@@ -94,13 +94,13 @@ require('../fixtures/node_modules/foo');
|
||||
|
||||
console.error('test name clashes');
|
||||
// this one exists and should import the local module
|
||||
var my_path = require('../fixtures/path');
|
||||
const my_path = require('../fixtures/path');
|
||||
assert.ok(my_path.path_func instanceof Function);
|
||||
// this one does not exist and should throw
|
||||
assert.throws(function() { require('./utils'); },
|
||||
/^Error: Cannot find module '.\/utils'$/);
|
||||
|
||||
var errorThrown = false;
|
||||
let errorThrown = false;
|
||||
try {
|
||||
require('../fixtures/throws_error');
|
||||
} catch (e) {
|
||||
@@ -112,7 +112,7 @@ assert.strictEqual(require('path').dirname(__filename), __dirname);
|
||||
|
||||
console.error('load custom file types with extensions');
|
||||
require.extensions['.test'] = function(module, filename) {
|
||||
var content = fs.readFileSync(filename).toString();
|
||||
let content = fs.readFileSync(filename).toString();
|
||||
assert.strictEqual('this is custom source\n', content);
|
||||
content = content.replace('this is custom source',
|
||||
'exports.test = \'passed\'');
|
||||
@@ -174,13 +174,13 @@ assert.strictEqual(require(loadOrder + 'file9').file9, 'file9/index.reg2', msg);
|
||||
|
||||
// make sure that module.require() is the same as
|
||||
// doing require() inside of that module.
|
||||
var parent = require('../fixtures/module-require/parent/');
|
||||
var child = require('../fixtures/module-require/child/');
|
||||
const parent = require('../fixtures/module-require/parent/');
|
||||
const child = require('../fixtures/module-require/child/');
|
||||
assert.strictEqual(child.loaded, parent.loaded);
|
||||
|
||||
|
||||
// #1357 Loading JSON files with require()
|
||||
var json = require('../fixtures/packages/main/package.json');
|
||||
const json = require('../fixtures/packages/main/package.json');
|
||||
assert.deepStrictEqual(json, {
|
||||
name: 'package-name',
|
||||
version: '1.2.3',
|
||||
@@ -192,8 +192,8 @@ assert.deepStrictEqual(json, {
|
||||
// modules that we've required, and that all of them contain
|
||||
// the appropriate children, and so on.
|
||||
|
||||
var children = module.children.reduce(function red(set, child) {
|
||||
var id = path.relative(path.dirname(__dirname), child.id);
|
||||
const children = module.children.reduce(function red(set, child) {
|
||||
let id = path.relative(path.dirname(__dirname), child.id);
|
||||
id = id.replace(/\\/g, '/');
|
||||
set[id] = child.children.reduce(red, {});
|
||||
return set;
|
||||
|
||||
Reference in new issue
Block a user