lib: force using primordials for JSON, Math and Reflect · nodejs/node@0817840 (original) (raw)
43 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
1 | 1 | rules: |
2 | 2 | prefer-object-spread: error |
3 | 3 | no-buffer-constructor: error |
4 | +no-restricted-globals: ["error", "JSON", "Math", "Reflect"] | |
4 | 5 | no-restricted-syntax: |
5 | 6 | # Config copied from .eslintrc.js |
6 | 7 | - error |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -21,6 +21,8 @@ | ||
21 | 21 | |
22 | 22 | 'use strict'; |
23 | 23 | |
24 | +const { Math } = primordials; | |
25 | + | |
24 | 26 | const { getOptionValue } = require('internal/options'); |
25 | 27 | |
26 | 28 | const { methods, HTTPParser } = |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Reflect } = primordials; | |
4 | + | |
3 | 5 | const { |
4 | 6 | ERR_ASYNC_CALLBACK, |
5 | 7 | ERR_INVALID_ASYNC_ID |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -21,6 +21,8 @@ | ||
21 | 21 | |
22 | 22 | 'use strict'; |
23 | 23 | |
24 | +const { Math } = primordials; | |
25 | + | |
24 | 26 | const { |
25 | 27 | byteLengthUtf8, |
26 | 28 | copy: _copy, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -26,6 +26,8 @@ | ||
26 | 26 | // No new pull requests targeting this module will be accepted |
27 | 27 | // unless they address existing, critical bugs. |
28 | 28 | |
29 | +const { Reflect } = primordials; | |
30 | + | |
29 | 31 | const util = require('util'); |
30 | 32 | const EventEmitter = require('events'); |
31 | 33 | const { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -21,6 +21,8 @@ | ||
21 | 21 | |
22 | 22 | 'use strict'; |
23 | 23 | |
24 | +const { Math, Reflect } = primordials; | |
25 | + | |
24 | 26 | var spliceOne; |
25 | 27 | |
26 | 28 | const { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -24,6 +24,8 @@ | ||
24 | 24 | |
25 | 25 | 'use strict'; |
26 | 26 | |
27 | +const { Math, Reflect } = primordials; | |
28 | + | |
27 | 29 | const { fs: constants } = internalBinding('constants'); |
28 | 30 | const { |
29 | 31 | S_IFIFO, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { JSON } = primordials; | |
4 | + | |
3 | 5 | const { |
4 | 6 | ERR_INSPECTOR_ALREADY_CONNECTED, |
5 | 7 | ERR_INSPECTOR_CLOSED, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Math } = primordials; | |
4 | + | |
3 | 5 | const { inspect } = require('internal/util/inspect'); |
4 | 6 | const { codes: { |
5 | 7 | ERR_INVALID_ARG_TYPE |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Reflect } = primordials; | |
4 | + | |
3 | 5 | const { |
4 | 6 | ERR_ASYNC_TYPE, |
5 | 7 | ERR_INVALID_ASYNC_ID |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -34,9 +34,8 @@ | ||
34 | 34 | // This file is compiled as if it's wrapped in a function with arguments |
35 | 35 | // passed by node::RunBootstrapping() |
36 | 36 | /* global process, require, internalBinding, isMainThread, ownsProcessState */ |
37 | -/* global primordials */ | |
38 | 37 | |
39 | -const { Object, Symbol } = primordials; | |
38 | +const { JSON, Object, Symbol } = primordials; | |
40 | 39 | const config = internalBinding('config'); |
41 | 40 | const { deprecate } = require('internal/util'); |
42 | 41 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | -/* global primordials */ | |
3 | +/* eslint-disable no-restricted-globals */ | |
4 | 4 | |
5 | 5 | // This file subclasses and stores the JS builtins that come from the VM |
6 | 6 | // so that Node.js's builtin modules do not need to later look these up from |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Math } = primordials; | |
4 | + | |
3 | 5 | const { |
4 | 6 | ERR_BUFFER_OUT_OF_BOUNDS, |
5 | 7 | ERR_INVALID_ARG_TYPE, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { JSON } = primordials; | |
4 | + | |
3 | 5 | const { |
4 | 6 | errnoException, |
5 | 7 | codes: { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Math } = primordials; | |
4 | + | |
3 | 5 | const { Buffer } = require('buffer'); |
4 | 6 | const { removeColors } = require('internal/util'); |
5 | 7 | const HasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -3,6 +3,8 @@ | ||
3 | 3 | // The Console constructor is not actually used to construct the global |
4 | 4 | // console. It's exported for backwards compatibility. |
5 | 5 | |
6 | +const { Reflect } = primordials; | |
7 | + | |
6 | 8 | const { trace } = internalBinding('trace_events'); |
7 | 9 | const { |
8 | 10 | isStackOverflowError, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -12,6 +12,8 @@ | ||
12 | 12 | // Therefore, the console.Console.prototype is not |
13 | 13 | // in the global console prototype chain anymore. |
14 | 14 | |
15 | +const { Reflect } = primordials; | |
16 | + | |
15 | 17 | const { |
16 | 18 | Console, |
17 | 19 | kBindStreamsLazy, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Math } = primordials; | |
4 | + | |
3 | 5 | const { AsyncWrap, Providers } = internalBinding('async_wrap'); |
4 | 6 | const { Buffer, kMaxLength } = require('buffer'); |
5 | 7 | const { randomBytes: _randomBytes } = internalBinding('crypto'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -20,7 +20,9 @@ | ||
20 | 20 | // https://github.com/tc39/proposal-frozen-realms/blob/91ac390e3451da92b5c27e354b39e52b7636a437/shim/src/deep-freeze.js |
21 | 21 | |
22 | 22 | /* global WebAssembly, SharedArrayBuffer, console */ |
23 | +/* eslint-disable no-restricted-globals */ | |
23 | 24 | 'use strict'; |
25 | + | |
24 | 26 | module.exports = function() { |
25 | 27 | |
26 | 28 | const intrinsics = [ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Math } = primordials; | |
4 | + | |
3 | 5 | const { |
4 | 6 | F_OK, |
5 | 7 | O_SYMLINK, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Math } = primordials; | |
4 | + | |
3 | 5 | const { Buffer } = require('buffer'); |
4 | 6 | |
5 | 7 | const { FSReqCallback, close, read } = internalBinding('fs'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Math } = primordials; | |
4 | + | |
3 | 5 | const { |
4 | 6 | FSReqCallback, |
5 | 7 | writeBuffers |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Reflect } = primordials; | |
4 | + | |
3 | 5 | const { Buffer, kMaxLength } = require('buffer'); |
4 | 6 | const { |
5 | 7 | codes: { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Reflect } = primordials; | |
4 | + | |
3 | 5 | const assert = require('internal/assert'); |
4 | 6 | const Stream = require('stream'); |
5 | 7 | const Readable = Stream.Readable; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2,6 +2,8 @@ | ||
2 | 2 | |
3 | 3 | /* eslint-disable no-use-before-define */ |
4 | 4 | |
5 | +const { Math, Reflect } = primordials; | |
6 | + | |
5 | 7 | const { |
6 | 8 | assertCrypto, |
7 | 9 | customInspectSymbol: kInspect, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Math } = primordials; | |
4 | + | |
3 | 5 | const binding = internalBinding('http2'); |
4 | 6 | const { |
5 | 7 | codes: { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +/* eslint-disable no-restricted-globals */ | |
4 | + | |
3 | 5 | const { types } = internalBinding('options'); |
4 | 6 | const hasCrypto = Boolean(process.versions.openssl); |
5 | 7 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -21,6 +21,8 @@ | ||
21 | 21 | |
22 | 22 | 'use strict'; |
23 | 23 | |
24 | +const { JSON, Reflect } = primordials; | |
25 | + | |
24 | 26 | const { NativeModule } = require('internal/bootstrap/loaders'); |
25 | 27 | const { pathToFileURL } = require('internal/url'); |
26 | 28 | const { deprecate } = require('internal/util'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { JSON } = primordials; | |
4 | + | |
3 | 5 | const path = require('path'); |
4 | 6 | |
5 | 7 | const { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { JSON, Reflect } = primordials; | |
4 | + | |
3 | 5 | const { |
4 | 6 | ERR_MANIFEST_TDZ, |
5 | 7 | } = require('internal/errors').codes; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Reflect } = primordials; | |
4 | + | |
3 | 5 | const { |
4 | 6 | // For easy access to the nextTick state in the C++ land, |
5 | 7 | // and to avoid unnecessary calls into JS land. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -3,6 +3,8 @@ | ||
3 | 3 | // Implements coverage collection exposed by the `NODE_V8_COVERAGE` |
4 | 4 | // environment variable which can also be used in the user land. |
5 | 5 | |
6 | +const { JSON } = primordials; | |
7 | + | |
6 | 8 | let coverageDirectory; |
7 | 9 | |
8 | 10 | function writeCoverage() { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Math } = primordials; | |
4 | + | |
3 | 5 | const { ERR_INVALID_OPT_VALUE } = require('internal/errors').codes; |
4 | 6 | |
5 | 7 | function highWaterMarkFrom(options, isDuplex, duplexKey) { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -72,6 +72,8 @@ | ||
72 | 72 | // timers within (or creation of a new list). However, these operations combined |
73 | 73 | // have shown to be trivial in comparison to other timers architectures. |
74 | 74 | |
75 | +const { Math, Reflect } = primordials; | |
76 | + | |
75 | 77 | const { |
76 | 78 | scheduleTimer, |
77 | 79 | toggleTimerRef, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Reflect } = primordials; | |
4 | + | |
3 | 5 | const { inspect } = require('internal/util/inspect'); |
4 | 6 | const { |
5 | 7 | encodeStr, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { Reflect } = primordials; | |
4 | + | |
3 | 5 | const { |
4 | 6 | ERR_INVALID_ARG_TYPE, |
5 | 7 | ERR_NO_CRYPTO, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { JSON, Math } = primordials; | |
4 | + | |
3 | 5 | const { |
4 | 6 | getOwnNonIndexProperties, |
5 | 7 | getPromiseDetails, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +const { JSON } = primordials; | |
4 | + | |
3 | 5 | const vm = require('vm'); |
4 | 6 | |
5 | 7 | const scriptFiles = [ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -27,6 +27,8 @@ | ||
27 | 27 | |
28 | 28 | 'use strict'; |
29 | 29 | |
30 | +const { Math } = primordials; | |
31 | + | |
30 | 32 | const { |
31 | 33 | ERR_INVALID_CURSOR_POS, |
32 | 34 | ERR_INVALID_OPT_VALUE |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -42,6 +42,8 @@ | ||
42 | 42 | |
43 | 43 | 'use strict'; |
44 | 44 | |
45 | +const { Math } = primordials; | |
46 | + | |
45 | 47 | const { |
46 | 48 | builtinLibs, |
47 | 49 | makeRequireFunction, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -21,6 +21,8 @@ | ||
21 | 21 | |
22 | 22 | 'use strict'; |
23 | 23 | |
24 | +const { Math } = primordials; | |
25 | + | |
24 | 26 | const { |
25 | 27 | immediateInfo, |
26 | 28 | toggleImmediateRef |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -21,6 +21,8 @@ | ||
21 | 21 | |
22 | 22 | 'use strict'; |
23 | 23 | |
24 | +const { Reflect } = primordials; | |
25 | + | |
24 | 26 | const { |
25 | 27 | codes: { |
26 | 28 | ERR_FALSY_VALUE_REJECTION, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -21,6 +21,8 @@ | ||
21 | 21 | |
22 | 22 | 'use strict'; |
23 | 23 | |
24 | +const { Math } = primordials; | |
25 | + | |
24 | 26 | const { |
25 | 27 | codes: { |
26 | 28 | ERR_BROTLI_INVALID_PARAM, |