Skip to content

Commit 70a0c17

Browse files
lholmquistBridgeAR
authored andcommitted
repl: add missing variable declaration
* Adds `let` to a variable declaration in a for loop that wasn't using anything. * Declare the for initial expression in the for loop. * Remove hoisted variables for loops. PR-URL: #29535 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 03a3468 commit 70a0c17

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/repl.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ function complete(line, callback) {
10891089
var completions;
10901090
// List of completion lists, one for each inheritance "level"
10911091
var completionGroups = [];
1092-
var completeOn, i, group, c;
1092+
var completeOn, group, c;
10931093

10941094
// REPL commands (e.g. ".break").
10951095
var filter;
@@ -1112,7 +1112,7 @@ function complete(line, callback) {
11121112
completeOn = match[1];
11131113
var subdir = match[2] || '';
11141114
filter = match[1];
1115-
var dir, files, f, name, base, ext, abs, subfiles, s, isDirectory;
1115+
var dir, files, name, base, ext, abs, subfiles, isDirectory;
11161116
group = [];
11171117
let paths = [];
11181118

@@ -1126,14 +1126,14 @@ function complete(line, callback) {
11261126
paths = module.paths.concat(CJSModule.globalPaths);
11271127
}
11281128

1129-
for (i = 0; i < paths.length; i++) {
1129+
for (let i = 0; i < paths.length; i++) {
11301130
dir = path.resolve(paths[i], subdir);
11311131
try {
11321132
files = fs.readdirSync(dir);
11331133
} catch {
11341134
continue;
11351135
}
1136-
for (f = 0; f < files.length; f++) {
1136+
for (let f = 0; f < files.length; f++) {
11371137
name = files[f];
11381138
ext = path.extname(name);
11391139
base = name.slice(0, -ext.length);
@@ -1154,7 +1154,7 @@ function complete(line, callback) {
11541154
} catch {
11551155
continue;
11561156
}
1157-
for (s = 0; s < subfiles.length; s++) {
1157+
for (let s = 0; s < subfiles.length; s++) {
11581158
if (indexRe.test(subfiles[s])) {
11591159
group.push(subdir + name);
11601160
}
@@ -1291,7 +1291,7 @@ function complete(line, callback) {
12911291
}
12921292

12931293
if (memberGroups.length) {
1294-
for (i = 0; i < memberGroups.length; i++) {
1294+
for (let i = 0; i < memberGroups.length; i++) {
12951295
completionGroups.push(
12961296
memberGroups[i].map((member) => `${expr}.${member}`));
12971297
}
@@ -1316,7 +1316,7 @@ function complete(line, callback) {
13161316
// Filter, sort (within each group), uniq and merge the completion groups.
13171317
if (completionGroups.length && filter) {
13181318
var newCompletionGroups = [];
1319-
for (i = 0; i < completionGroups.length; i++) {
1319+
for (let i = 0; i < completionGroups.length; i++) {
13201320
group = completionGroups[i]
13211321
.filter((elem) => elem.indexOf(filter) === 0);
13221322
if (group.length) {
@@ -1332,7 +1332,7 @@ function complete(line, callback) {
13321332
// Completion group 0 is the "closest"
13331333
// (least far up the inheritance chain)
13341334
// so we put its completions last: to be closest in the REPL.
1335-
for (i = 0; i < completionGroups.length; i++) {
1335+
for (let i = 0; i < completionGroups.length; i++) {
13361336
group = completionGroups[i];
13371337
group.sort();
13381338
for (var j = group.length - 1; j >= 0; j--) {

0 commit comments

Comments
 (0)