Skip to content

Commit 4893f70

Browse files
committed
repl: remove magic mode
The magic mode is long deprecated and works the same as the sloppy mode. Since the sloppy mode is the default, removing the magic mode should be safe. PR-URL: #19187 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
1 parent 8181c60 commit 4893f70

File tree

4 files changed

+12
-24
lines changed

4 files changed

+12
-24
lines changed

doc/api/deprecations.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,16 +560,16 @@ The `tls.createSecurePair()` API was deprecated in documentation in Node.js
560560
<a id="DEP0065"></a>
561561
### DEP0065: repl.REPL_MODE_MAGIC and NODE_REPL_MODE=magic
562562

563-
Type: Documentation-only
563+
Type: End-of-Life
564564

565565
The `repl` module's `REPL_MODE_MAGIC` constant, used for `replMode` option, has
566-
been deprecated. Its behavior has been functionally identical to that of
566+
been removed. Its behavior has been functionally identical to that of
567567
`REPL_MODE_SLOPPY` since Node.js v6.0.0, when V8 5.0 was imported. Please use
568568
`REPL_MODE_SLOPPY` instead.
569569

570570
The `NODE_REPL_MODE` environment variable is used to set the underlying
571-
`replMode` of an interactive `node` session. Its default value, `magic`, is
572-
similarly deprecated in favor of `sloppy`.
571+
`replMode` of an interactive `node` session. Its value, `magic`, is also
572+
removed. Please use `sloppy` instead.
573573

574574
<a id="DEP0066"></a>
575575
### DEP0066: outgoingMessage.\_headers, outgoingMessage.\_headerNames

doc/api/repl.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,9 @@ Returns `true` if `keyword` is a valid keyword, otherwise `false`.
421421
<!-- YAML
422422
added: v0.1.91
423423
changes:
424+
- version: REPLACEME
425+
pr-url: https://github.com/nodejs/node/pull/REPLACEME
426+
description: The `REPL_MAGIC_MODE` replMode was removed.
424427
- version: v5.8.0
425428
pr-url: https://github.com/nodejs/node/pull/5388
426429
description: The `options` parameter is optional now.
@@ -462,9 +465,6 @@ changes:
462465
* `repl.REPL_MODE_SLOPPY` - evaluates expressions in sloppy mode.
463466
* `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is
464467
equivalent to prefacing every repl statement with `'use strict'`.
465-
* `repl.REPL_MODE_MAGIC` - This value is **deprecated**, since enhanced
466-
spec compliance in V8 has rendered magic mode unnecessary. It is now
467-
equivalent to `repl.REPL_MODE_SLOPPY` (documented above).
468468
* `breakEvalOnSigint` - Stop evaluating the current piece of code when
469469
`SIGINT` is received, i.e. `Ctrl+C` is pressed. This cannot be used together
470470
with a custom `eval` function. Defaults to `false`.
@@ -512,9 +512,8 @@ environment variables:
512512
REPL history. Whitespace will be trimmed from the value.
513513
- `NODE_REPL_HISTORY_SIZE` - Defaults to `1000`. Controls how many lines of
514514
history will be persisted if history is available. Must be a positive number.
515-
- `NODE_REPL_MODE` - May be any of `sloppy`, `strict`, or `magic`. Defaults
516-
to `sloppy`, which will allow non-strict mode code to be run. `magic` is
517-
**deprecated** and treated as an alias of `sloppy`.
515+
- `NODE_REPL_MODE` - May be either `sloppy` or `strict`. Defaults
516+
to `sloppy`, which will allow non-strict mode code to be run.
518517

519518
### Persistent History
520519

lib/repl.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,6 @@ exports.REPLServer = REPLServer;
716716

717717
exports.REPL_MODE_SLOPPY = Symbol('repl-sloppy');
718718
exports.REPL_MODE_STRICT = Symbol('repl-strict');
719-
exports.REPL_MODE_MAGIC = exports.REPL_MODE_SLOPPY;
720719

721720
// prompt is a string to print on each line for the prompt,
722721
// source is a stream to use for I/O, defaulting to stdin/stdout.

test/parallel/test-repl-options.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ const r2 = repl.start({
6767
ignoreUndefined: true,
6868
eval: evaler,
6969
writer: writer,
70-
replMode: repl.REPL_MODE_STRICT
70+
replMode: repl.REPL_MODE_STRICT,
71+
historySize: 50
7172
});
7273
assert.strictEqual(r2.input, stream);
7374
assert.strictEqual(r2.output, stream);
@@ -79,6 +80,7 @@ assert.strictEqual(r2.useGlobal, true);
7980
assert.strictEqual(r2.ignoreUndefined, true);
8081
assert.strictEqual(r2.writer, writer);
8182
assert.strictEqual(r2.replMode, repl.REPL_MODE_STRICT);
83+
assert.strictEqual(r2.historySize, 50);
8284

8385
// test r2 for backwards compact
8486
assert.strictEqual(r2.rli.input, stream);
@@ -87,18 +89,6 @@ assert.strictEqual(r2.rli.input, r2.inputStream);
8789
assert.strictEqual(r2.rli.output, r2.outputStream);
8890
assert.strictEqual(r2.rli.terminal, false);
8991

90-
// testing out "magic" replMode
91-
const r3 = repl.start({
92-
input: stream,
93-
output: stream,
94-
writer: writer,
95-
replMode: repl.REPL_MODE_MAGIC,
96-
historySize: 50
97-
});
98-
99-
assert.strictEqual(r3.replMode, repl.REPL_MODE_MAGIC);
100-
assert.strictEqual(r3.historySize, 50);
101-
10292
// Verify that defaults are used when no arguments are provided
10393
const r4 = repl.start();
10494

0 commit comments

Comments
 (0)