Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: Replace Symbol global by the primordials Symbol #30737

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@ rules:
message: "Use `const { Object } = primordials;` instead of the global."
- name: Reflect
message: "Use `const { Reflect } = primordials;` instead of the global."
- name: Symbol
message: "Use `const { Symbol } = primordials;` instead of the global."
no-restricted-syntax:
# Config copied from .eslintrc.js
- error
1 change: 1 addition & 0 deletions lib/_http_agent.js
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ const {
ObjectKeys,
ObjectSetPrototypeOf,
ObjectValues,
Symbol,
} = primordials;

const net = require('net');
1 change: 1 addition & 0 deletions lib/_http_common.js
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@

const {
MathMin,
Symbol,
} = primordials;
const { setImmediate } = require('timers');

1 change: 1 addition & 0 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ const {
ObjectKeys,
ObjectPrototypeHasOwnProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const { getDefaultHighWaterMark } = require('internal/streams/state');
1 change: 1 addition & 0 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
const {
ObjectKeys,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const net = require('net');
1 change: 1 addition & 0 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ const {
NumberIsNaN,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

module.exports = Readable;
1 change: 1 addition & 0 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ const {
Array,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

module.exports = Writable;
1 change: 1 addition & 0 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ const {
ObjectAssign,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/async_hooks.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
const {
NumberIsSafeInteger,
ReflectApply,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/buffer.js
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ const {
ObjectDefineProperties,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/domain.js
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ const {
Array,
ObjectDefineProperty,
ReflectApply,
Symbol,
} = primordials;

const EventEmitter = require('events');
1 change: 1 addition & 0 deletions lib/events.js
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ const {
ObjectKeys,
ReflectApply,
ReflectOwnKeys,
Symbol,
} = primordials;
const kRejection = Symbol.for('nodejs.rejection');

1 change: 1 addition & 0 deletions lib/inspector.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
const {
JSONParse,
JSONStringify,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/internal/async_hooks.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ const {
FunctionPrototypeBind,
NumberIsSafeInteger,
ObjectDefineProperty,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/internal/child_process.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ const {
ArrayIsArray,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/internal/child_process/serialization.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
const {
JSONParse,
JSONStringify,
Symbol,
} = primordials;
const { Buffer } = require('buffer');
const { StringDecoder } = require('string_decoder');
1 change: 1 addition & 0 deletions lib/internal/console/constructor.js
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ const {
ObjectPrototypeHasOwnProperty,
ObjectValues,
ReflectOwnKeys,
Symbol,
} = primordials;

const { trace } = internalBinding('trace_events');
1 change: 1 addition & 0 deletions lib/internal/crypto/hash.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

const {
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/internal/crypto/keys.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

const {
ObjectDefineProperty,
Symbol,
} = primordials;

const {
4 changes: 4 additions & 0 deletions lib/internal/crypto/util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const {
getCiphers: _getCiphers,
getCurves: _getCurves,
5 changes: 5 additions & 0 deletions lib/internal/dgram.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const { codes } = require('internal/errors');
const { UDP } = internalBinding('udp_wrap');
const { guessHandleType } = internalBinding('util');
1 change: 1 addition & 0 deletions lib/internal/encoding.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ const {
ObjectCreate,
ObjectDefineProperties,
ObjectGetOwnPropertyDescriptors,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ const {
NumberIsInteger,
ObjectDefineProperty,
ObjectKeys,
Symbol,
} = primordials;

const messages = new Map();
2 changes: 1 addition & 1 deletion lib/internal/freeze_intrinsics.js
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ module.exports = function() {
getOwnPropertyDescriptors,
getOwnPropertyNames,
getOwnPropertySymbols,
getPrototypeOf
getPrototypeOf,
} = Object;
const objectHasOwnProperty = Object.prototype.hasOwnProperty;
const { ownKeys } = Reflect;
1 change: 1 addition & 0 deletions lib/internal/fs/dir.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

const {
ObjectDefineProperty,
Symbol,
} = primordials;

const pathModule = require('path');
1 change: 1 addition & 0 deletions lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ const {
MathMax,
MathMin,
NumberIsSafeInteger,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ const {
NumberIsFinite,
ObjectSetPrototypeOf,
ReflectOwnKeys,
Symbol,
} = primordials;

const { Buffer } = require('buffer');
1 change: 1 addition & 0 deletions lib/internal/fs/watchers.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
const {
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const errors = require('internal/errors');
4 changes: 4 additions & 0 deletions lib/internal/http.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const { setUnrefTimeout } = require('internal/timers');
const { PerformanceEntry, notify } = internalBinding('performance');

1 change: 1 addition & 0 deletions lib/internal/http2/compat.js
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ const {
ObjectKeys,
ObjectPrototypeHasOwnProperty,
ReflectGetPrototypeOf,
Symbol,
} = primordials;

const assert = require('internal/assert');
1 change: 1 addition & 0 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ const {
ObjectDefineProperty,
ObjectPrototypeHasOwnProperty,
ReflectGetPrototypeOf,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/internal/http2/util.js
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ const {
Number,
ObjectCreate,
ObjectKeys,
Symbol,
} = primordials;

const binding = internalBinding('http2');
4 changes: 4 additions & 0 deletions lib/internal/js_stream_socket.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const { setImmediate } = require('timers');
const assert = require('internal/assert');
const { Socket } = require('net');
4 changes: 4 additions & 0 deletions lib/internal/net.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const Buffer = require('buffer').Buffer;
const { writeBuffer } = internalBinding('fs');
const errors = require('internal/errors');
1 change: 1 addition & 0 deletions lib/internal/priority_queue.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

const {
Array,
Symbol,
} = primordials;

const kCompare = Symbol('compare');
4 changes: 4 additions & 0 deletions lib/internal/repl/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const acorn = require('internal/deps/acorn/acorn/dist/acorn');
const privateMethods =
require('internal/deps/acorn-plugins/acorn-private-methods/index');
1 change: 1 addition & 0 deletions lib/internal/stream_base_commons.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

const {
Array,
Symbol,
} = primordials;

const { Buffer } = require('buffer');
1 change: 1 addition & 0 deletions lib/internal/streams/async_iterator.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ const {
ObjectCreate,
ObjectGetPrototypeOf,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const finished = require('internal/streams/end-of-stream');
4 changes: 4 additions & 0 deletions lib/internal/streams/buffer_list.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const { Buffer } = require('buffer');
const { inspect } = require('internal/util/inspect');

5 changes: 5 additions & 0 deletions lib/internal/streams/duplexpair.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const { Duplex } = require('stream');

const kCallback = Symbol('Callback');
4 changes: 4 additions & 0 deletions lib/internal/streams/from.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
Symbol,
} = primordials;

const {
ERR_INVALID_ARG_TYPE
} = require('internal/errors').codes;
1 change: 1 addition & 0 deletions lib/internal/timers.js
Original file line number Diff line number Diff line change
@@ -77,6 +77,7 @@ const {
MathTrunc,
NumberMIN_SAFE_INTEGER,
ObjectCreate,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/internal/trace_events_async_hooks.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ const {
ObjectKeys,
SafeMap,
SafeSet,
Symbol,
} = primordials;

const { trace } = internalBinding('trace_events');
1 change: 1 addition & 0 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ const {
ObjectKeys,
ReflectGetOwnPropertyDescriptor,
ReflectOwnKeys,
Symbol,
} = primordials;

const { inspect } = require('internal/util/inspect');
2 changes: 2 additions & 0 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
@@ -11,7 +11,9 @@ const {
ObjectGetPrototypeOf,
ObjectSetPrototypeOf,
ReflectConstruct,
Symbol,
} = primordials;

const {
codes: {
ERR_INVALID_ARG_TYPE,
2 changes: 1 addition & 1 deletion lib/internal/vm/module.js
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@ const {
ArrayIsArray,
ObjectCreate,
ObjectDefineProperty,
Symbol,
SafePromise,
Symbol,
} = primordials;

const { isContext } = internalBinding('contextify');
1 change: 1 addition & 0 deletions lib/internal/worker.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ const {
MathMax,
ObjectCreate,
ObjectEntries,
Symbol,
} = primordials;

const EventEmitter = require('events');
1 change: 1 addition & 0 deletions lib/internal/worker/io.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ const {
ObjectGetOwnPropertyDescriptors,
ObjectGetPrototypeOf,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/net.js
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ const {
NumberIsNaN,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const EventEmitter = require('events');
1 change: 1 addition & 0 deletions lib/os.js
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@

const {
ObjectDefineProperties,
Symbol,
} = primordials;

const { safeGetenv } = internalBinding('credentials');
1 change: 1 addition & 0 deletions lib/perf_hooks.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ const {
ObjectDefineProperties,
ObjectDefineProperty,
ObjectKeys,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/readline.js
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ const {
NumberIsNaN,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/repl.js
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@ const {
ObjectKeys,
ObjectPrototypeHasOwnProperty,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const {
1 change: 1 addition & 0 deletions lib/string_decoder.js
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
const {
ArrayBufferIsView,
ObjectDefineProperties,
Symbol,
} = primordials;

const { Buffer } = require('buffer');
1 change: 1 addition & 0 deletions lib/trace_events.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

const {
ArrayIsArray,
Symbol,
} = primordials;

const { hasTracing } = internalBinding('config');
1 change: 1 addition & 0 deletions lib/v8.js
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
const {
Array,
ObjectPrototypeToString,
Symbol,
} = primordials;

const { Buffer } = require('buffer');
1 change: 1 addition & 0 deletions lib/vm.js
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
const {
ArrayIsArray,
ArrayPrototypeForEach,
Symbol,
} = primordials;

const {
4 changes: 3 additions & 1 deletion lib/wasi.js
Original file line number Diff line number Diff line change
@@ -5,8 +5,10 @@ const {
ArrayPrototypeForEach,
ArrayPrototypeMap,
FunctionPrototypeBind,
ObjectKeys
ObjectKeys,
Symbol,
} = primordials;

const {
ERR_INVALID_ARG_TYPE,
ERR_WASI_ALREADY_STARTED
1 change: 1 addition & 0 deletions lib/zlib.js
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ const {
ObjectGetPrototypeOf,
ObjectKeys,
ObjectSetPrototypeOf,
Symbol,
} = primordials;

const {