lib: force using primordials for JSON, Math and Reflect
Use the "no-restricted-globals" ESLint rule to lint for it. PR-URL: https://github.com/nodejs/node/pull/27027 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
8a6dcd040f
commit
0817840f77
@ -1,6 +1,7 @@
|
||||
rules:
|
||||
prefer-object-spread: error
|
||||
no-buffer-constructor: error
|
||||
no-restricted-globals: ["error", "JSON", "Math", "Reflect"]
|
||||
no-restricted-syntax:
|
||||
# Config copied from .eslintrc.js
|
||||
- error
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const { getOptionValue } = require('internal/options');
|
||||
|
||||
const { methods, HTTPParser } =
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Reflect } = primordials;
|
||||
|
||||
const {
|
||||
ERR_ASYNC_CALLBACK,
|
||||
ERR_INVALID_ASYNC_ID
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const {
|
||||
byteLengthUtf8,
|
||||
copy: _copy,
|
||||
|
@ -26,6 +26,8 @@
|
||||
// No new pull requests targeting this module will be accepted
|
||||
// unless they address existing, critical bugs.
|
||||
|
||||
const { Reflect } = primordials;
|
||||
|
||||
const util = require('util');
|
||||
const EventEmitter = require('events');
|
||||
const {
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const { Math, Reflect } = primordials;
|
||||
|
||||
var spliceOne;
|
||||
|
||||
const {
|
||||
|
@ -24,6 +24,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const { Math, Reflect } = primordials;
|
||||
|
||||
const { fs: constants } = internalBinding('constants');
|
||||
const {
|
||||
S_IFIFO,
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { JSON } = primordials;
|
||||
|
||||
const {
|
||||
ERR_INSPECTOR_ALREADY_CONNECTED,
|
||||
ERR_INSPECTOR_CLOSED,
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const { inspect } = require('internal/util/inspect');
|
||||
const { codes: {
|
||||
ERR_INVALID_ARG_TYPE
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Reflect } = primordials;
|
||||
|
||||
const {
|
||||
ERR_ASYNC_TYPE,
|
||||
ERR_INVALID_ASYNC_ID
|
||||
|
@ -34,9 +34,8 @@
|
||||
// This file is compiled as if it's wrapped in a function with arguments
|
||||
// passed by node::RunBootstrapping()
|
||||
/* global process, require, internalBinding, isMainThread, ownsProcessState */
|
||||
/* global primordials */
|
||||
|
||||
const { Object, Symbol } = primordials;
|
||||
const { JSON, Object, Symbol } = primordials;
|
||||
const config = internalBinding('config');
|
||||
const { deprecate } = require('internal/util');
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
/* global primordials */
|
||||
/* eslint-disable no-restricted-globals */
|
||||
|
||||
// This file subclasses and stores the JS builtins that come from the VM
|
||||
// so that Node.js's builtin modules do not need to later look these up from
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const {
|
||||
ERR_BUFFER_OUT_OF_BOUNDS,
|
||||
ERR_INVALID_ARG_TYPE,
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { JSON } = primordials;
|
||||
|
||||
const {
|
||||
errnoException,
|
||||
codes: {
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const { Buffer } = require('buffer');
|
||||
const { removeColors } = require('internal/util');
|
||||
const HasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty);
|
||||
|
@ -3,6 +3,8 @@
|
||||
// The Console constructor is not actually used to construct the global
|
||||
// console. It's exported for backwards compatibility.
|
||||
|
||||
const { Reflect } = primordials;
|
||||
|
||||
const { trace } = internalBinding('trace_events');
|
||||
const {
|
||||
isStackOverflowError,
|
||||
|
@ -12,6 +12,8 @@
|
||||
// Therefore, the console.Console.prototype is not
|
||||
// in the global console prototype chain anymore.
|
||||
|
||||
const { Reflect } = primordials;
|
||||
|
||||
const {
|
||||
Console,
|
||||
kBindStreamsLazy,
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const { AsyncWrap, Providers } = internalBinding('async_wrap');
|
||||
const { Buffer, kMaxLength } = require('buffer');
|
||||
const { randomBytes: _randomBytes } = internalBinding('crypto');
|
||||
|
@ -20,7 +20,9 @@
|
||||
// https://github.com/tc39/proposal-frozen-realms/blob/91ac390e3451da92b5c27e354b39e52b7636a437/shim/src/deep-freeze.js
|
||||
|
||||
/* global WebAssembly, SharedArrayBuffer, console */
|
||||
/* eslint-disable no-restricted-globals */
|
||||
'use strict';
|
||||
|
||||
module.exports = function() {
|
||||
|
||||
const intrinsics = [
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const {
|
||||
F_OK,
|
||||
O_SYMLINK,
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const { Buffer } = require('buffer');
|
||||
|
||||
const { FSReqCallback, close, read } = internalBinding('fs');
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const {
|
||||
FSReqCallback,
|
||||
writeBuffers
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Reflect } = primordials;
|
||||
|
||||
const { Buffer, kMaxLength } = require('buffer');
|
||||
const {
|
||||
codes: {
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Reflect } = primordials;
|
||||
|
||||
const assert = require('internal/assert');
|
||||
const Stream = require('stream');
|
||||
const Readable = Stream.Readable;
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
/* eslint-disable no-use-before-define */
|
||||
|
||||
const { Math, Reflect } = primordials;
|
||||
|
||||
const {
|
||||
assertCrypto,
|
||||
customInspectSymbol: kInspect,
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const binding = internalBinding('http2');
|
||||
const {
|
||||
codes: {
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
/* eslint-disable no-restricted-globals */
|
||||
|
||||
const { types } = internalBinding('options');
|
||||
const hasCrypto = Boolean(process.versions.openssl);
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const { JSON, Reflect } = primordials;
|
||||
|
||||
const { NativeModule } = require('internal/bootstrap/loaders');
|
||||
const { pathToFileURL } = require('internal/url');
|
||||
const { deprecate } = require('internal/util');
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { JSON } = primordials;
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const {
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { JSON, Reflect } = primordials;
|
||||
|
||||
const {
|
||||
ERR_MANIFEST_TDZ,
|
||||
} = require('internal/errors').codes;
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Reflect } = primordials;
|
||||
|
||||
const {
|
||||
// For easy access to the nextTick state in the C++ land,
|
||||
// and to avoid unnecessary calls into JS land.
|
||||
|
@ -3,6 +3,8 @@
|
||||
// Implements coverage collection exposed by the `NODE_V8_COVERAGE`
|
||||
// environment variable which can also be used in the user land.
|
||||
|
||||
const { JSON } = primordials;
|
||||
|
||||
let coverageDirectory;
|
||||
|
||||
function writeCoverage() {
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const { ERR_INVALID_OPT_VALUE } = require('internal/errors').codes;
|
||||
|
||||
function highWaterMarkFrom(options, isDuplex, duplexKey) {
|
||||
|
@ -72,6 +72,8 @@
|
||||
// timers within (or creation of a new list). However, these operations combined
|
||||
// have shown to be trivial in comparison to other timers architectures.
|
||||
|
||||
const { Math, Reflect } = primordials;
|
||||
|
||||
const {
|
||||
scheduleTimer,
|
||||
toggleTimerRef,
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Reflect } = primordials;
|
||||
|
||||
const { inspect } = require('internal/util/inspect');
|
||||
const {
|
||||
encodeStr,
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Reflect } = primordials;
|
||||
|
||||
const {
|
||||
ERR_INVALID_ARG_TYPE,
|
||||
ERR_NO_CRYPTO,
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { JSON, Math } = primordials;
|
||||
|
||||
const {
|
||||
getOwnNonIndexProperties,
|
||||
getPromiseDetails,
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { JSON } = primordials;
|
||||
|
||||
const vm = require('vm');
|
||||
|
||||
const scriptFiles = [
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const {
|
||||
ERR_INVALID_CURSOR_POS,
|
||||
ERR_INVALID_OPT_VALUE
|
||||
|
@ -42,6 +42,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const {
|
||||
builtinLibs,
|
||||
makeRequireFunction,
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const {
|
||||
immediateInfo,
|
||||
toggleImmediateRef
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const { Reflect } = primordials;
|
||||
|
||||
const {
|
||||
codes: {
|
||||
ERR_FALSY_VALUE_REJECTION,
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const { Math } = primordials;
|
||||
|
||||
const {
|
||||
codes: {
|
||||
ERR_BROTLI_INVALID_PARAM,
|
||||
|
Loading…
x
Reference in New Issue
Block a user