★ wanayoo — archive 1999 https://github.com/nodejs/node/commit/0817840f77Nouvelle recherche | Portail wanayoo
Skip to content
Permalink
Browse files
lib: force using primordials for JSON, Math and Reflect
Use the "no-restricted-globals" ESLint rule to lint for it.

PR-URL: #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>
  • Loading branch information
targos authored and ZYSzys committed Apr 3, 2019
1 parent 8a6dcd0 commit 0817840f775032169ddd70c85ac059f18ffcc81c
Showing with 83 additions and 3 deletions.
  1. +1 −0 lib/.eslintrc.yaml
  2. +2 −0 lib/_http_common.js
  3. +2 −0 lib/async_hooks.js
  4. +2 −0 lib/buffer.js
  5. +2 −0 lib/domain.js
  6. +2 −0 lib/events.js
  7. +2 −0 lib/fs.js
  8. +2 −0 lib/inspector.js
  9. +2 −0 lib/internal/assert/assertion_error.js
  10. +2 −0 lib/internal/async_hooks.js
  11. +1 −2 lib/internal/bootstrap/node.js
  12. +1 −1 lib/internal/bootstrap/primordials.js
  13. +2 −0 lib/internal/buffer.js
  14. +2 −0 lib/internal/child_process.js
  15. +2 −0 lib/internal/cli_table.js
  16. +2 −0 lib/internal/console/constructor.js
  17. +2 −0 lib/internal/console/global.js
  18. +2 −0 lib/internal/crypto/random.js
  19. +2 −0 lib/internal/freeze_intrinsics.js
  20. +2 −0 lib/internal/fs/promises.js
  21. +2 −0 lib/internal/fs/read_file_context.js
  22. +2 −0 lib/internal/fs/streams.js
  23. +2 −0 lib/internal/fs/utils.js
  24. +2 −0 lib/internal/http2/compat.js
  25. +2 −0 lib/internal/http2/core.js
  26. +2 −0 lib/internal/http2/util.js
  27. +2 −0 lib/internal/main/print_help.js
  28. +2 −0 lib/internal/modules/cjs/loader.js
  29. +2 −0 lib/internal/process/execution.js
  30. +2 −0 lib/internal/process/policy.js
  31. +2 −0 lib/internal/process/task_queues.js
  32. +2 −0 lib/internal/profiler.js
  33. +2 −0 lib/internal/streams/state.js
  34. +2 −0 lib/internal/timers.js
  35. +2 −0 lib/internal/url.js
  36. +2 −0 lib/internal/util.js
  37. +2 −0 lib/internal/util/inspect.js
  38. +2 −0 lib/internal/v8_prof_processor.js
  39. +2 −0 lib/readline.js
  40. +2 −0 lib/repl.js
  41. +2 −0 lib/timers.js
  42. +2 −0 lib/util.js
  43. +2 −0 lib/zlib.js
@@ -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,

0 comments on commit 0817840

Please sign in to comment.