repl: add trailing commas in source files

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Antoine du Hamel authored and Danielle Adams committed 2023-04-05 12:52:25 -04:00
1 parent 331073a7aa
commit 91fbad617d
5 files changed
+43 -41

No files matched your search

+3 -1
View File
@@ -281,7 +281,8 @@ overrides:
- ./internal/process/*.js
- ./internal/readline/*.js
- ./internal/readme.md
- ./internal/repl/history.js
- ./internal/repl.js
- ./internal/repl/*.js
- ./internal/source_map/prepare_stack_trace.js
- ./internal/streams/*.js
- ./internal/structured_clone.js
@@ -298,6 +299,7 @@ overrides:
- ./path/*.js
- ./process.js
- ./punycode.js
- ./repl.js
- ./stream/*.js
- ./sys.js
- ./test.js
+2 -2
View File
@@ -23,7 +23,7 @@ function createRepl(env, opts, cb) {
ignoreUndefined: false,
useGlobal: true,
breakEvalOnSigint: true,
...opts
...opts,
};
if (NumberParseInt(env.NODE_NO_READLINE)) {
@@ -33,7 +33,7 @@ function createRepl(env, opts, cb) {
if (env.NODE_REPL_MODE) {
opts.replMode = {
'strict': REPL.REPL_MODE_STRICT,
'sloppy': REPL.REPL_MODE_SLOPPY
'sloppy': REPL.REPL_MODE_SLOPPY,
}[env.NODE_REPL_MODE.toLowerCase().trim()];
}
+3 -3
View File
@@ -133,7 +133,7 @@ const visitorsWithoutAncestors = {
}
walk.base.VariableDeclaration(node, state, c);
}
},
};
const visitors = {};
@@ -209,7 +209,7 @@ function processTopLevelAwait(src) {
wrappedArray[node.end - 1] += str;
},
containsAwait: false,
containsReturn: false
containsReturn: false,
};
walk.recursive(body, state, visitors);
@@ -258,5 +258,5 @@ function processTopLevelAwait(src) {
}
module.exports = {
processTopLevelAwait
processTopLevelAwait,
};
+6 -6
View File
@@ -27,7 +27,7 @@ const { tokTypes: tt, Parser: AcornParser } =
const { sendInspectorCommand } = require('internal/util/inspector');
const {
ERR_INSPECTOR_NOT_AVAILABLE
ERR_INSPECTOR_NOT_AVAILABLE,
} = require('internal/errors').codes;
const {
@@ -54,7 +54,7 @@ let debug = require('internal/util/debuglog').debuglog('repl', (fn) => {
const previewOptions = {
colors: false,
depth: 1,
showHidden: false
showHidden: false,
};
const REPL_MODE_STRICT = Symbol('repl-strict');
@@ -340,7 +340,7 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) {
colors: false,
depth: 1,
compact: true,
breakLength: Infinity
breakLength: Infinity,
}, previewOptions);
session.post('Runtime.callFunctionOn', {
functionDeclaration:
@@ -349,7 +349,7 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) {
.getOwnPropertyDescriptor(globalThis, 'util')
.get().inspect(v, ${inspectOptions})`,
objectId: result.objectId,
arguments: [result]
arguments: [result],
}, (error, preview) => {
if (error) {
callback(error);
@@ -520,7 +520,7 @@ function setupReverseSearch(repl) {
const alreadyMatched = new SafeSet();
const labels = {
r: 'bck-i-search: ',
s: 'fwd-i-search: '
s: 'fwd-i-search: ',
};
let isInReverseSearch = false;
let historyIndex = -1;
@@ -749,5 +749,5 @@ module.exports = {
isRecoverableError,
kStandaloneREPL: Symbol('kStandaloneREPL'),
setupPreview,
setupReverseSearch
setupReverseSearch,
};
+29 -29
View File
@@ -100,11 +100,11 @@ const {
const { BuiltinModule } = require('internal/bootstrap/loaders');
const {
makeRequireFunction,
addBuiltinLibsToObject
addBuiltinLibsToObject,
} = require('internal/modules/cjs/helpers');
const {
isIdentifierStart,
isIdentifierChar
isIdentifierChar,
} = require('internal/deps/acorn/acorn/dist/acorn');
const {
decorateErrorStack,
@@ -119,7 +119,7 @@ const path = require('path');
const fs = require('fs');
const { Interface } = require('readline');
const {
commonPrefix
commonPrefix,
} = require('internal/readline/utils');
const { Console } = require('console');
const CJSModule = require('internal/modules/cjs/loader').Module;
@@ -174,7 +174,7 @@ const {
} = internalBinding('util');
const {
startSigintWatchdog,
stopSigintWatchdog
stopSigintWatchdog,
} = internalBinding('contextify');
const history = require('internal/repl/history');
@@ -298,7 +298,7 @@ function REPLServer(prompt,
'DEP0141') :
(val) => this.input = val,
enumerable: false,
configurable: true
configurable: true,
});
ObjectDefineProperty(this, 'outputStream', {
__proto__: null,
@@ -315,7 +315,7 @@ function REPLServer(prompt,
'DEP0141') :
(val) => this.output = val,
enumerable: false,
configurable: true
configurable: true,
});
this.allowBlockingCompletions = !!options.allowBlockingCompletions;
@@ -464,7 +464,7 @@ function REPLServer(prompt,
importModuleDynamically: (specifier, _, importAssertions) => {
return asyncESM.esmLoader.import(specifier, parentURL,
importAssertions);
}
},
});
} catch (fallbackError) {
if (isRecoverableError(fallbackError, fallbackCode)) {
@@ -508,7 +508,7 @@ function REPLServer(prompt,
importModuleDynamically: (specifier, _, importAssertions) => {
return asyncESM.esmLoader.import(specifier, parentURL,
importAssertions);
}
},
});
} catch (e) {
debug('parse error %j', code, e);
@@ -565,7 +565,7 @@ function REPLServer(prompt,
try {
const scriptOptions = {
displayErrors: false,
breakOnSigint: self.breakEvalOnSigint
breakOnSigint: self.breakEvalOnSigint,
};
if (self.useGlobal) {
@@ -769,7 +769,7 @@ function REPLServer(prompt,
completer: options.completer || completer,
terminal: options.terminal,
historySize: options.historySize,
prompt
prompt,
}]);
self.resetContext();
@@ -795,7 +795,7 @@ function REPLServer(prompt,
return ObjectAssign(writer.options, options);
},
enumerable: true,
configurable: true
configurable: true,
});
}
}
@@ -969,7 +969,7 @@ function REPLServer(prompt,
const {
clearPreview,
showPreview
showPreview,
} = setupPreview(
this,
kContextId,
@@ -1099,7 +1099,7 @@ REPLServer.prototype.createContext = function() {
__proto__: null,
configurable: true,
writable: true,
value: _console
value: _console,
});
}
@@ -1110,13 +1110,13 @@ REPLServer.prototype.createContext = function() {
__proto__: null,
configurable: true,
writable: true,
value: replModule
value: replModule,
});
ObjectDefineProperty(context, 'require', {
__proto__: null,
configurable: true,
writable: true,
value: makeRequireFunction(replModule)
value: makeRequireFunction(replModule),
});
addBuiltinLibsToObject(context, '<REPL>');
@@ -1142,7 +1142,7 @@ REPLServer.prototype.resetContext = function() {
this.underscoreAssigned = true;
this.output.write('Expression assignment to _ now disabled.\n');
}
}
},
});
ObjectDefineProperty(this.context, '_error', {
@@ -1156,7 +1156,7 @@ REPLServer.prototype.resetContext = function() {
this.output.write(
'Expression assignment to _error now disabled.\n');
}
}
},
});
// Allow REPL extensions to extend the new context
@@ -1242,7 +1242,7 @@ function getGlobalLexicalScopeNames(contextId) {
return sendInspectorCommand((session) => {
let names = [];
session.post('Runtime.globalLexicalScopeNames', {
executionContextId: contextId
executionContextId: contextId,
}, (error, result) => {
if (!error) names = result.names;
});
@@ -1666,7 +1666,7 @@ function _memory(cmd) {
// scope will not work for this function.
ArrayPrototypePush(self.lines.level, {
line: self.lines.length - 1,
depth: depth
depth: depth,
});
} else if (depth < 0) {
// Going... up.
@@ -1716,7 +1716,7 @@ function defineDefaultCommands(repl) {
action: function() {
this.clearBufferedCommand();
this.displayPrompt();
}
},
});
let clearMessage;
@@ -1734,14 +1734,14 @@ function defineDefaultCommands(repl) {
this.resetContext();
}
this.displayPrompt();
}
},
});
repl.defineCommand('exit', {
help: 'Exit the REPL',
action: function() {
this.close();
}
},
});
repl.defineCommand('help', {
@@ -1761,7 +1761,7 @@ function defineDefaultCommands(repl) {
this.output.write('\nPress Ctrl+C to abort current expression, ' +
'Ctrl+D to exit the REPL\n');
this.displayPrompt();
}
},
});
repl.defineCommand('save', {
@@ -1774,7 +1774,7 @@ function defineDefaultCommands(repl) {
this.output.write(`Failed to save: ${file}\n`);
}
this.displayPrompt();
}
},
});
repl.defineCommand('load', {
@@ -1797,7 +1797,7 @@ function defineDefaultCommands(repl) {
this.output.write(`Failed to load: ${file}\n`);
}
this.displayPrompt();
}
},
});
if (repl.terminal) {
repl.defineCommand('editor', {
@@ -1806,7 +1806,7 @@ function defineDefaultCommands(repl) {
_turnOnEditorMode(this);
this.output.write(
'// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)\n');
}
},
});
}
}
@@ -1823,7 +1823,7 @@ module.exports = {
REPLServer,
REPL_MODE_SLOPPY,
REPL_MODE_STRICT,
Recoverable
Recoverable,
};
ObjectDefineProperty(module.exports, 'builtinModules', {
@@ -1831,7 +1831,7 @@ ObjectDefineProperty(module.exports, 'builtinModules', {
get: () => _builtinLibs,
set: (val) => _builtinLibs = val,
enumerable: true,
configurable: true
configurable: true,
});
ObjectDefineProperty(module.exports, '_builtinLibs', {
@@ -1847,5 +1847,5 @@ ObjectDefineProperty(module.exports, '_builtinLibs', {
'DEP0142',
) : (val) => _builtinLibs = val,
enumerable: false,
configurable: true
configurable: true,
});