Skip to content

Commit 4f2bf8c

Browse files
aduh95targos
authored andcommitted
repl: add trailing commas in source files
PR-URL: #46757 Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com> Reviewed-By: Qingyu Deng <i@ayase-lab.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 58b1f33 commit 4f2bf8c

File tree

5 files changed

+43
-41
lines changed

5 files changed

+43
-41
lines changed

lib/.eslintrc.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ overrides:
293293
- ./internal/process/*.js
294294
- ./internal/readline/*.js
295295
- ./internal/readme.md
296-
- ./internal/repl/history.js
296+
- ./internal/repl.js
297+
- ./internal/repl/*.js
297298
- ./internal/source_map/prepare_stack_trace.js
298299
- ./internal/streams/*.js
299300
- ./internal/structured_clone.js
@@ -310,6 +311,7 @@ overrides:
310311
- ./path/*.js
311312
- ./process.js
312313
- ./punycode.js
314+
- ./repl.js
313315
- ./stream/*.js
314316
- ./sys.js
315317
- ./test.js

lib/internal/repl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function createRepl(env, opts, cb) {
2222
ignoreUndefined: false,
2323
useGlobal: true,
2424
breakEvalOnSigint: true,
25-
...opts
25+
...opts,
2626
};
2727

2828
if (NumberParseInt(env.NODE_NO_READLINE)) {
@@ -32,7 +32,7 @@ function createRepl(env, opts, cb) {
3232
if (env.NODE_REPL_MODE) {
3333
opts.replMode = {
3434
'strict': REPL.REPL_MODE_STRICT,
35-
'sloppy': REPL.REPL_MODE_SLOPPY
35+
'sloppy': REPL.REPL_MODE_SLOPPY,
3636
}[env.NODE_REPL_MODE.toLowerCase().trim()];
3737
}
3838

lib/internal/repl/await.js

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

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

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ const {
9999
const { BuiltinModule } = require('internal/bootstrap/loaders');
100100
const {
101101
makeRequireFunction,
102-
addBuiltinLibsToObject
102+
addBuiltinLibsToObject,
103103
} = require('internal/modules/helpers');
104104
const {
105105
isIdentifierStart,
106-
isIdentifierChar
106+
isIdentifierChar,
107107
} = require('internal/deps/acorn/acorn/dist/acorn');
108108
const {
109109
decorateErrorStack,
@@ -118,7 +118,7 @@ const path = require('path');
118118
const fs = require('fs');
119119
const { Interface } = require('readline');
120120
const {
121-
commonPrefix
121+
commonPrefix,
122122
} = require('internal/readline/utils');
123123
const { Console } = require('console');
124124
const CJSModule = require('internal/modules/cjs/loader').Module;
@@ -173,7 +173,7 @@ const {
173173
} = internalBinding('util');
174174
const {
175175
startSigintWatchdog,
176-
stopSigintWatchdog
176+
stopSigintWatchdog,
177177
} = internalBinding('contextify');
178178

179179
const history = require('internal/repl/history');
@@ -296,7 +296,7 @@ function REPLServer(prompt,
296296
'DEP0141') :
297297
(val) => this.input = val,
298298
enumerable: false,
299-
configurable: true
299+
configurable: true,
300300
});
301301
ObjectDefineProperty(this, 'outputStream', {
302302
__proto__: null,
@@ -313,7 +313,7 @@ function REPLServer(prompt,
313313
'DEP0141') :
314314
(val) => this.output = val,
315315
enumerable: false,
316-
configurable: true
316+
configurable: true,
317317
});
318318

319319
this.allowBlockingCompletions = !!options.allowBlockingCompletions;
@@ -462,7 +462,7 @@ function REPLServer(prompt,
462462
importModuleDynamically: (specifier, _, importAssertions) => {
463463
return asyncESM.esmLoader.import(specifier, parentURL,
464464
importAssertions);
465-
}
465+
},
466466
});
467467
} catch (fallbackError) {
468468
if (isRecoverableError(fallbackError, fallbackCode)) {
@@ -506,7 +506,7 @@ function REPLServer(prompt,
506506
importModuleDynamically: (specifier, _, importAssertions) => {
507507
return asyncESM.esmLoader.import(specifier, parentURL,
508508
importAssertions);
509-
}
509+
},
510510
});
511511
} catch (e) {
512512
debug('parse error %j', code, e);
@@ -563,7 +563,7 @@ function REPLServer(prompt,
563563
try {
564564
const scriptOptions = {
565565
displayErrors: false,
566-
breakOnSigint: self.breakEvalOnSigint
566+
breakOnSigint: self.breakEvalOnSigint,
567567
};
568568

569569
if (self.useGlobal) {
@@ -767,7 +767,7 @@ function REPLServer(prompt,
767767
completer: options.completer || completer,
768768
terminal: options.terminal,
769769
historySize: options.historySize,
770-
prompt
770+
prompt,
771771
}]);
772772

773773
self.resetContext();
@@ -793,7 +793,7 @@ function REPLServer(prompt,
793793
return ObjectAssign(writer.options, options);
794794
},
795795
enumerable: true,
796-
configurable: true
796+
configurable: true,
797797
});
798798
}
799799
}
@@ -967,7 +967,7 @@ function REPLServer(prompt,
967967

968968
const {
969969
clearPreview,
970-
showPreview
970+
showPreview,
971971
} = setupPreview(
972972
this,
973973
kContextId,
@@ -1097,7 +1097,7 @@ REPLServer.prototype.createContext = function() {
10971097
__proto__: null,
10981098
configurable: true,
10991099
writable: true,
1100-
value: _console
1100+
value: _console,
11011101
});
11021102
}
11031103

@@ -1108,13 +1108,13 @@ REPLServer.prototype.createContext = function() {
11081108
__proto__: null,
11091109
configurable: true,
11101110
writable: true,
1111-
value: replModule
1111+
value: replModule,
11121112
});
11131113
ObjectDefineProperty(context, 'require', {
11141114
__proto__: null,
11151115
configurable: true,
11161116
writable: true,
1117-
value: makeRequireFunction(replModule)
1117+
value: makeRequireFunction(replModule),
11181118
});
11191119

11201120
addBuiltinLibsToObject(context, '<REPL>');
@@ -1140,7 +1140,7 @@ REPLServer.prototype.resetContext = function() {
11401140
this.underscoreAssigned = true;
11411141
this.output.write('Expression assignment to _ now disabled.\n');
11421142
}
1143-
}
1143+
},
11441144
});
11451145

11461146
ObjectDefineProperty(this.context, '_error', {
@@ -1154,7 +1154,7 @@ REPLServer.prototype.resetContext = function() {
11541154
this.output.write(
11551155
'Expression assignment to _error now disabled.\n');
11561156
}
1157-
}
1157+
},
11581158
});
11591159

11601160
// Allow REPL extensions to extend the new context
@@ -1240,7 +1240,7 @@ function getGlobalLexicalScopeNames(contextId) {
12401240
return sendInspectorCommand((session) => {
12411241
let names = [];
12421242
session.post('Runtime.globalLexicalScopeNames', {
1243-
executionContextId: contextId
1243+
executionContextId: contextId,
12441244
}, (error, result) => {
12451245
if (!error) names = result.names;
12461246
});
@@ -1661,7 +1661,7 @@ function _memory(cmd) {
16611661
// scope will not work for this function.
16621662
ArrayPrototypePush(self.lines.level, {
16631663
line: self.lines.length - 1,
1664-
depth: depth
1664+
depth: depth,
16651665
});
16661666
} else if (depth < 0) {
16671667
// Going... up.
@@ -1711,7 +1711,7 @@ function defineDefaultCommands(repl) {
17111711
action: function() {
17121712
this.clearBufferedCommand();
17131713
this.displayPrompt();
1714-
}
1714+
},
17151715
});
17161716

17171717
let clearMessage;
@@ -1729,14 +1729,14 @@ function defineDefaultCommands(repl) {
17291729
this.resetContext();
17301730
}
17311731
this.displayPrompt();
1732-
}
1732+
},
17331733
});
17341734

17351735
repl.defineCommand('exit', {
17361736
help: 'Exit the REPL',
17371737
action: function() {
17381738
this.close();
1739-
}
1739+
},
17401740
});
17411741

17421742
repl.defineCommand('help', {
@@ -1756,7 +1756,7 @@ function defineDefaultCommands(repl) {
17561756
this.output.write('\nPress Ctrl+C to abort current expression, ' +
17571757
'Ctrl+D to exit the REPL\n');
17581758
this.displayPrompt();
1759-
}
1759+
},
17601760
});
17611761

17621762
repl.defineCommand('save', {
@@ -1769,7 +1769,7 @@ function defineDefaultCommands(repl) {
17691769
this.output.write(`Failed to save: ${file}\n`);
17701770
}
17711771
this.displayPrompt();
1772-
}
1772+
},
17731773
});
17741774

17751775
repl.defineCommand('load', {
@@ -1792,7 +1792,7 @@ function defineDefaultCommands(repl) {
17921792
this.output.write(`Failed to load: ${file}\n`);
17931793
}
17941794
this.displayPrompt();
1795-
}
1795+
},
17961796
});
17971797
if (repl.terminal) {
17981798
repl.defineCommand('editor', {
@@ -1801,7 +1801,7 @@ function defineDefaultCommands(repl) {
18011801
_turnOnEditorMode(this);
18021802
this.output.write(
18031803
'// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)\n');
1804-
}
1804+
},
18051805
});
18061806
}
18071807
}
@@ -1818,15 +1818,15 @@ module.exports = {
18181818
REPLServer,
18191819
REPL_MODE_SLOPPY,
18201820
REPL_MODE_STRICT,
1821-
Recoverable
1821+
Recoverable,
18221822
};
18231823

18241824
ObjectDefineProperty(module.exports, 'builtinModules', {
18251825
__proto__: null,
18261826
get: () => _builtinLibs,
18271827
set: (val) => _builtinLibs = val,
18281828
enumerable: true,
1829-
configurable: true
1829+
configurable: true,
18301830
});
18311831

18321832
ObjectDefineProperty(module.exports, '_builtinLibs', {
@@ -1842,5 +1842,5 @@ ObjectDefineProperty(module.exports, '_builtinLibs', {
18421842
'DEP0142',
18431843
) : (val) => _builtinLibs = val,
18441844
enumerable: false,
1845-
configurable: true
1845+
configurable: true,
18461846
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy