Skip to content

Commit 91fbad6

Browse files
aduh95danielleadams
authored andcommitted
repl: add trailing commas in source files
PR-URL: #46757 Reviewed-By: Deokjin Kim <[email protected]> Reviewed-By: Qingyu Deng <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 331073a commit 91fbad6

File tree

5 files changed

+43
-41
lines changed

5 files changed

+43
-41
lines changed

lib/.eslintrc.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ overrides:
281281
- ./internal/process/*.js
282282
- ./internal/readline/*.js
283283
- ./internal/readme.md
284-
- ./internal/repl/history.js
284+
- ./internal/repl.js
285+
- ./internal/repl/*.js
285286
- ./internal/source_map/prepare_stack_trace.js
286287
- ./internal/streams/*.js
287288
- ./internal/structured_clone.js
@@ -298,6 +299,7 @@ overrides:
298299
- ./path/*.js
299300
- ./process.js
300301
- ./punycode.js
302+
- ./repl.js
301303
- ./stream/*.js
302304
- ./sys.js
303305
- ./test.js

lib/internal/repl.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function createRepl(env, opts, cb) {
2323
ignoreUndefined: false,
2424
useGlobal: true,
2525
breakEvalOnSigint: true,
26-
...opts
26+
...opts,
2727
};
2828

2929
if (NumberParseInt(env.NODE_NO_READLINE)) {
@@ -33,7 +33,7 @@ function createRepl(env, opts, cb) {
3333
if (env.NODE_REPL_MODE) {
3434
opts.replMode = {
3535
'strict': REPL.REPL_MODE_STRICT,
36-
'sloppy': REPL.REPL_MODE_SLOPPY
36+
'sloppy': REPL.REPL_MODE_SLOPPY,
3737
}[env.NODE_REPL_MODE.toLowerCase().trim()];
3838
}
3939

lib/internal/repl/await.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ const visitorsWithoutAncestors = {
133133
}
134134

135135
walk.base.VariableDeclaration(node, state, c);
136-
}
136+
},
137137
};
138138

139139
const visitors = {};
@@ -209,7 +209,7 @@ function processTopLevelAwait(src) {
209209
wrappedArray[node.end - 1] += str;
210210
},
211211
containsAwait: false,
212-
containsReturn: false
212+
containsReturn: false,
213213
};
214214

215215
walk.recursive(body, state, visitors);
@@ -258,5 +258,5 @@ function processTopLevelAwait(src) {
258258
}
259259

260260
module.exports = {
261-
processTopLevelAwait
261+
processTopLevelAwait,
262262
};

lib/internal/repl/utils.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const { tokTypes: tt, Parser: AcornParser } =
2727
const { sendInspectorCommand } = require('internal/util/inspector');
2828

2929
const {
30-
ERR_INSPECTOR_NOT_AVAILABLE
30+
ERR_INSPECTOR_NOT_AVAILABLE,
3131
} = require('internal/errors').codes;
3232

3333
const {
@@ -54,7 +54,7 @@ let debug = require('internal/util/debuglog').debuglog('repl', (fn) => {
5454
const previewOptions = {
5555
colors: false,
5656
depth: 1,
57-
showHidden: false
57+
showHidden: false,
5858
};
5959

6060
const REPL_MODE_STRICT = Symbol('repl-strict');
@@ -340,7 +340,7 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) {
340340
colors: false,
341341
depth: 1,
342342
compact: true,
343-
breakLength: Infinity
343+
breakLength: Infinity,
344344
}, previewOptions);
345345
session.post('Runtime.callFunctionOn', {
346346
functionDeclaration:
@@ -349,7 +349,7 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) {
349349
.getOwnPropertyDescriptor(globalThis, 'util')
350350
.get().inspect(v, ${inspectOptions})`,
351351
objectId: result.objectId,
352-
arguments: [result]
352+
arguments: [result],
353353
}, (error, preview) => {
354354
if (error) {
355355
callback(error);
@@ -520,7 +520,7 @@ function setupReverseSearch(repl) {
520520
const alreadyMatched = new SafeSet();
521521
const labels = {
522522
r: 'bck-i-search: ',
523-
s: 'fwd-i-search: '
523+
s: 'fwd-i-search: ',
524524
};
525525
let isInReverseSearch = false;
526526
let historyIndex = -1;
@@ -749,5 +749,5 @@ module.exports = {
749749
isRecoverableError,
750750
kStandaloneREPL: Symbol('kStandaloneREPL'),
751751
setupPreview,
752-
setupReverseSearch
752+
setupReverseSearch,
753753
};

lib/repl.js

+29-29
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ const {
100100
const { BuiltinModule } = require('internal/bootstrap/loaders');
101101
const {
102102
makeRequireFunction,
103-
addBuiltinLibsToObject
103+
addBuiltinLibsToObject,
104104
} = require('internal/modules/cjs/helpers');
105105
const {
106106
isIdentifierStart,
107-
isIdentifierChar
107+
isIdentifierChar,
108108
} = require('internal/deps/acorn/acorn/dist/acorn');
109109
const {
110110
decorateErrorStack,
@@ -119,7 +119,7 @@ const path = require('path');
119119
const fs = require('fs');
120120
const { Interface } = require('readline');
121121
const {
122-
commonPrefix
122+
commonPrefix,
123123
} = require('internal/readline/utils');
124124
const { Console } = require('console');
125125
const CJSModule = require('internal/modules/cjs/loader').Module;
@@ -174,7 +174,7 @@ const {
174174
} = internalBinding('util');
175175
const {
176176
startSigintWatchdog,
177-
stopSigintWatchdog
177+
stopSigintWatchdog,
178178
} = internalBinding('contextify');
179179

180180
const history = require('internal/repl/history');
@@ -298,7 +298,7 @@ function REPLServer(prompt,
298298
'DEP0141') :
299299
(val) => this.input = val,
300300
enumerable: false,
301-
configurable: true
301+
configurable: true,
302302
});
303303
ObjectDefineProperty(this, 'outputStream', {
304304
__proto__: null,
@@ -315,7 +315,7 @@ function REPLServer(prompt,
315315
'DEP0141') :
316316
(val) => this.output = val,
317317
enumerable: false,
318-
configurable: true
318+
configurable: true,
319319
});
320320

321321
this.allowBlockingCompletions = !!options.allowBlockingCompletions;
@@ -464,7 +464,7 @@ function REPLServer(prompt,
464464
importModuleDynamically: (specifier, _, importAssertions) => {
465465
return asyncESM.esmLoader.import(specifier, parentURL,
466466
importAssertions);
467-
}
467+
},
468468
});
469469
} catch (fallbackError) {
470470
if (isRecoverableError(fallbackError, fallbackCode)) {
@@ -508,7 +508,7 @@ function REPLServer(prompt,
508508
importModuleDynamically: (specifier, _, importAssertions) => {
509509
return asyncESM.esmLoader.import(specifier, parentURL,
510510
importAssertions);
511-
}
511+
},
512512
});
513513
} catch (e) {
514514
debug('parse error %j', code, e);
@@ -565,7 +565,7 @@ function REPLServer(prompt,
565565
try {
566566
const scriptOptions = {
567567
displayErrors: false,
568-
breakOnSigint: self.breakEvalOnSigint
568+
breakOnSigint: self.breakEvalOnSigint,
569569
};
570570

571571
if (self.useGlobal) {
@@ -769,7 +769,7 @@ function REPLServer(prompt,
769769
completer: options.completer || completer,
770770
terminal: options.terminal,
771771
historySize: options.historySize,
772-
prompt
772+
prompt,
773773
}]);
774774

775775
self.resetContext();
@@ -795,7 +795,7 @@ function REPLServer(prompt,
795795
return ObjectAssign(writer.options, options);
796796
},
797797
enumerable: true,
798-
configurable: true
798+
configurable: true,
799799
});
800800
}
801801
}
@@ -969,7 +969,7 @@ function REPLServer(prompt,
969969

970970
const {
971971
clearPreview,
972-
showPreview
972+
showPreview,
973973
} = setupPreview(
974974
this,
975975
kContextId,
@@ -1099,7 +1099,7 @@ REPLServer.prototype.createContext = function() {
10991099
__proto__: null,
11001100
configurable: true,
11011101
writable: true,
1102-
value: _console
1102+
value: _console,
11031103
});
11041104
}
11051105

@@ -1110,13 +1110,13 @@ REPLServer.prototype.createContext = function() {
11101110
__proto__: null,
11111111
configurable: true,
11121112
writable: true,
1113-
value: replModule
1113+
value: replModule,
11141114
});
11151115
ObjectDefineProperty(context, 'require', {
11161116
__proto__: null,
11171117
configurable: true,
11181118
writable: true,
1119-
value: makeRequireFunction(replModule)
1119+
value: makeRequireFunction(replModule),
11201120
});
11211121

11221122
addBuiltinLibsToObject(context, '<REPL>');
@@ -1142,7 +1142,7 @@ REPLServer.prototype.resetContext = function() {
11421142
this.underscoreAssigned = true;
11431143
this.output.write('Expression assignment to _ now disabled.\n');
11441144
}
1145-
}
1145+
},
11461146
});
11471147

11481148
ObjectDefineProperty(this.context, '_error', {
@@ -1156,7 +1156,7 @@ REPLServer.prototype.resetContext = function() {
11561156
this.output.write(
11571157
'Expression assignment to _error now disabled.\n');
11581158
}
1159-
}
1159+
},
11601160
});
11611161

11621162
// Allow REPL extensions to extend the new context
@@ -1242,7 +1242,7 @@ function getGlobalLexicalScopeNames(contextId) {
12421242
return sendInspectorCommand((session) => {
12431243
let names = [];
12441244
session.post('Runtime.globalLexicalScopeNames', {
1245-
executionContextId: contextId
1245+
executionContextId: contextId,
12461246
}, (error, result) => {
12471247
if (!error) names = result.names;
12481248
});
@@ -1666,7 +1666,7 @@ function _memory(cmd) {
16661666
// scope will not work for this function.
16671667
ArrayPrototypePush(self.lines.level, {
16681668
line: self.lines.length - 1,
1669-
depth: depth
1669+
depth: depth,
16701670
});
16711671
} else if (depth < 0) {
16721672
// Going... up.
@@ -1716,7 +1716,7 @@ function defineDefaultCommands(repl) {
17161716
action: function() {
17171717
this.clearBufferedCommand();
17181718
this.displayPrompt();
1719-
}
1719+
},
17201720
});
17211721

17221722
let clearMessage;
@@ -1734,14 +1734,14 @@ function defineDefaultCommands(repl) {
17341734
this.resetContext();
17351735
}
17361736
this.displayPrompt();
1737-
}
1737+
},
17381738
});
17391739

17401740
repl.defineCommand('exit', {
17411741
help: 'Exit the REPL',
17421742
action: function() {
17431743
this.close();
1744-
}
1744+
},
17451745
});
17461746

17471747
repl.defineCommand('help', {
@@ -1761,7 +1761,7 @@ function defineDefaultCommands(repl) {
17611761
this.output.write('\nPress Ctrl+C to abort current expression, ' +
17621762
'Ctrl+D to exit the REPL\n');
17631763
this.displayPrompt();
1764-
}
1764+
},
17651765
});
17661766

17671767
repl.defineCommand('save', {
@@ -1774,7 +1774,7 @@ function defineDefaultCommands(repl) {
17741774
this.output.write(`Failed to save: ${file}\n`);
17751775
}
17761776
this.displayPrompt();
1777-
}
1777+
},
17781778
});
17791779

17801780
repl.defineCommand('load', {
@@ -1797,7 +1797,7 @@ function defineDefaultCommands(repl) {
17971797
this.output.write(`Failed to load: ${file}\n`);
17981798
}
17991799
this.displayPrompt();
1800-
}
1800+
},
18011801
});
18021802
if (repl.terminal) {
18031803
repl.defineCommand('editor', {
@@ -1806,7 +1806,7 @@ function defineDefaultCommands(repl) {
18061806
_turnOnEditorMode(this);
18071807
this.output.write(
18081808
'// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)\n');
1809-
}
1809+
},
18101810
});
18111811
}
18121812
}
@@ -1823,15 +1823,15 @@ module.exports = {
18231823
REPLServer,
18241824
REPL_MODE_SLOPPY,
18251825
REPL_MODE_STRICT,
1826-
Recoverable
1826+
Recoverable,
18271827
};
18281828

18291829
ObjectDefineProperty(module.exports, 'builtinModules', {
18301830
__proto__: null,
18311831
get: () => _builtinLibs,
18321832
set: (val) => _builtinLibs = val,
18331833
enumerable: true,
1834-
configurable: true
1834+
configurable: true,
18351835
});
18361836

18371837
ObjectDefineProperty(module.exports, '_builtinLibs', {
@@ -1847,5 +1847,5 @@ ObjectDefineProperty(module.exports, '_builtinLibs', {
18471847
'DEP0142',
18481848
) : (val) => _builtinLibs = val,
18491849
enumerable: false,
1850-
configurable: true
1850+
configurable: true,
18511851
});

0 commit comments

Comments
 (0)