mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
lib: add globalThis to primordials
PR-URL: https://github.com/nodejs/node/pull/38211 Backport-PR-URL: https://github.com/nodejs/node/pull/39448 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
1ab4f81abc
commit
ea9003a559
6 files changed
+22
No files matched your search
@@ -25,6 +25,10 @@ rules:
|
||||
message: "Please use `require('internal/errors').hideStackFrames()` instead."
|
||||
- selector: "AssignmentExpression:matches([left.name='prepareStackTrace'], [left.property.name='prepareStackTrace'])"
|
||||
message: "Use 'overrideStackTrace' from 'lib/internal/errors.js' instead of 'Error.prepareStackTrace'."
|
||||
no-restricted-globals:
|
||||
- error
|
||||
- name: globalThis
|
||||
message: "Use `const { globalThis } = primordials;` instead of the global."
|
||||
# Custom rules in tools/eslint-rules
|
||||
node-core/lowercase-name-for-primitive: error
|
||||
node-core/non-ascii-character: error
|
||||
|
||||
@@ -9,6 +9,7 @@ const {
|
||||
RegExpPrototypeExec,
|
||||
SafeWeakMap,
|
||||
StringPrototypeStartsWith,
|
||||
globalThis,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
||||
@@ -171,6 +171,14 @@ primordials.SafeWeakSet = makeSafe(
|
||||
}
|
||||
);
|
||||
|
||||
// Create copies of configurable value properties of the global object
|
||||
[
|
||||
'globalThis',
|
||||
].forEach((name) => {
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
primordials[name] = globalThis[name];
|
||||
});
|
||||
|
||||
// Create copies of URI handling functions
|
||||
[
|
||||
decodeURI,
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
globalThis,
|
||||
} = primordials;
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
globalThis,
|
||||
} = primordials;
|
||||
|
||||
process.emitWarning(
|
||||
'These APIs are for internal testing only. Do not use them.',
|
||||
'internal/test/binding');
|
||||
|
||||
@@ -6,6 +6,7 @@ const {
|
||||
SafeSet,
|
||||
SafeWeakMap,
|
||||
SymbolIterator,
|
||||
globalThis,
|
||||
} = primordials;
|
||||
|
||||
// TODO(aduh95): Add FinalizationRegistry to primordials
|
||||
|
||||
Reference in new issue
Block a user