diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index da38169aac2b4d..ce0306ddbe10df 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -293,7 +293,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 @@ -310,6 +311,7 @@ overrides: - ./path/*.js - ./process.js - ./punycode.js + - ./repl.js - ./stream/*.js - ./sys.js - ./test.js diff --git a/lib/internal/repl.js b/lib/internal/repl.js index 491049ebfeb1e5..2dc79b2784e189 100644 --- a/lib/internal/repl.js +++ b/lib/internal/repl.js @@ -22,7 +22,7 @@ function createRepl(env, opts, cb) { ignoreUndefined: false, useGlobal: true, breakEvalOnSigint: true, - ...opts + ...opts, }; if (NumberParseInt(env.NODE_NO_READLINE)) { @@ -32,7 +32,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()]; } diff --git a/lib/internal/repl/await.js b/lib/internal/repl/await.js index ed24de2d48eb46..e4a0d9719d9c42 100644 --- a/lib/internal/repl/await.js +++ b/lib/internal/repl/await.js @@ -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, }; diff --git a/lib/internal/repl/utils.js b/lib/internal/repl/utils.js index 8405e6758fc7b7..618b5775414c58 100644 --- a/lib/internal/repl/utils.js +++ b/lib/internal/repl/utils.js @@ -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, }; diff --git a/lib/repl.js b/lib/repl.js index 3875858871ebfb..241e25f0f2095a 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -99,11 +99,11 @@ const { const { BuiltinModule } = require('internal/bootstrap/loaders'); const { makeRequireFunction, - addBuiltinLibsToObject + addBuiltinLibsToObject, } = require('internal/modules/helpers'); const { isIdentifierStart, - isIdentifierChar + isIdentifierChar, } = require('internal/deps/acorn/acorn/dist/acorn'); const { decorateErrorStack, @@ -118,7 +118,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; @@ -173,7 +173,7 @@ const { } = internalBinding('util'); const { startSigintWatchdog, - stopSigintWatchdog + stopSigintWatchdog, } = internalBinding('contextify'); const history = require('internal/repl/history'); @@ -296,7 +296,7 @@ function REPLServer(prompt, 'DEP0141') : (val) => this.input = val, enumerable: false, - configurable: true + configurable: true, }); ObjectDefineProperty(this, 'outputStream', { __proto__: null, @@ -313,7 +313,7 @@ function REPLServer(prompt, 'DEP0141') : (val) => this.output = val, enumerable: false, - configurable: true + configurable: true, }); this.allowBlockingCompletions = !!options.allowBlockingCompletions; @@ -462,7 +462,7 @@ function REPLServer(prompt, importModuleDynamically: (specifier, _, importAssertions) => { return asyncESM.esmLoader.import(specifier, parentURL, importAssertions); - } + }, }); } catch (fallbackError) { if (isRecoverableError(fallbackError, fallbackCode)) { @@ -506,7 +506,7 @@ function REPLServer(prompt, importModuleDynamically: (specifier, _, importAssertions) => { return asyncESM.esmLoader.import(specifier, parentURL, importAssertions); - } + }, }); } catch (e) { debug('parse error %j', code, e); @@ -563,7 +563,7 @@ function REPLServer(prompt, try { const scriptOptions = { displayErrors: false, - breakOnSigint: self.breakEvalOnSigint + breakOnSigint: self.breakEvalOnSigint, }; if (self.useGlobal) { @@ -767,7 +767,7 @@ function REPLServer(prompt, completer: options.completer || completer, terminal: options.terminal, historySize: options.historySize, - prompt + prompt, }]); self.resetContext(); @@ -793,7 +793,7 @@ function REPLServer(prompt, return ObjectAssign(writer.options, options); }, enumerable: true, - configurable: true + configurable: true, }); } } @@ -967,7 +967,7 @@ function REPLServer(prompt, const { clearPreview, - showPreview + showPreview, } = setupPreview( this, kContextId, @@ -1097,7 +1097,7 @@ REPLServer.prototype.createContext = function() { __proto__: null, configurable: true, writable: true, - value: _console + value: _console, }); } @@ -1108,13 +1108,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, ''); @@ -1140,7 +1140,7 @@ REPLServer.prototype.resetContext = function() { this.underscoreAssigned = true; this.output.write('Expression assignment to _ now disabled.\n'); } - } + }, }); ObjectDefineProperty(this.context, '_error', { @@ -1154,7 +1154,7 @@ REPLServer.prototype.resetContext = function() { this.output.write( 'Expression assignment to _error now disabled.\n'); } - } + }, }); // Allow REPL extensions to extend the new context @@ -1240,7 +1240,7 @@ function getGlobalLexicalScopeNames(contextId) { return sendInspectorCommand((session) => { let names = []; session.post('Runtime.globalLexicalScopeNames', { - executionContextId: contextId + executionContextId: contextId, }, (error, result) => { if (!error) names = result.names; }); @@ -1661,7 +1661,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. @@ -1711,7 +1711,7 @@ function defineDefaultCommands(repl) { action: function() { this.clearBufferedCommand(); this.displayPrompt(); - } + }, }); let clearMessage; @@ -1729,14 +1729,14 @@ function defineDefaultCommands(repl) { this.resetContext(); } this.displayPrompt(); - } + }, }); repl.defineCommand('exit', { help: 'Exit the REPL', action: function() { this.close(); - } + }, }); repl.defineCommand('help', { @@ -1756,7 +1756,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', { @@ -1769,7 +1769,7 @@ function defineDefaultCommands(repl) { this.output.write(`Failed to save: ${file}\n`); } this.displayPrompt(); - } + }, }); repl.defineCommand('load', { @@ -1792,7 +1792,7 @@ function defineDefaultCommands(repl) { this.output.write(`Failed to load: ${file}\n`); } this.displayPrompt(); - } + }, }); if (repl.terminal) { repl.defineCommand('editor', { @@ -1801,7 +1801,7 @@ function defineDefaultCommands(repl) { _turnOnEditorMode(this); this.output.write( '// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)\n'); - } + }, }); } } @@ -1818,7 +1818,7 @@ module.exports = { REPLServer, REPL_MODE_SLOPPY, REPL_MODE_STRICT, - Recoverable + Recoverable, }; ObjectDefineProperty(module.exports, 'builtinModules', { @@ -1826,7 +1826,7 @@ ObjectDefineProperty(module.exports, 'builtinModules', { get: () => _builtinLibs, set: (val) => _builtinLibs = val, enumerable: true, - configurable: true + configurable: true, }); ObjectDefineProperty(module.exports, '_builtinLibs', { @@ -1842,5 +1842,5 @@ ObjectDefineProperty(module.exports, '_builtinLibs', { 'DEP0142', ) : (val) => _builtinLibs = val, enumerable: false, - configurable: true + configurable: true, });