| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,10 @@ rules: | |||
| 25 | 25 | message: "Please use `require('internal/errors').hideStackFrames()` instead." | |
| 26 | 26 | - selector: "AssignmentExpression:matches([left.name='prepareStackTrace'], [left.property.name='prepareStackTrace'])" | |
| 27 | 27 | message: "Use 'overrideStackTrace' from 'lib/internal/errors.js' instead of 'Error.prepareStackTrace'." | |
| 28 | + no-restricted-globals: | ||
| 29 | + - error | ||
| 30 | + - name: globalThis | ||
| 31 | + message: "Use `const { globalThis } = primordials;` instead of the global." | ||
| 28 | 32 | # Custom rules in tools/eslint-rules | |
| 29 | 33 | node-core/lowercase-name-for-primitive: error | |
| 30 | 34 | node-core/non-ascii-character: error | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,7 @@ const { | |||
| 9 | 9 | RegExpPrototypeExec, | |
| 10 | 10 | SafeWeakMap, | |
| 11 | 11 | StringPrototypeStartsWith, | |
| 12 | + globalThis, | ||
| 12 | 13 | } = primordials; | |
| 13 | 14 | ||
| 14 | 15 | const { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -171,6 +171,14 @@ primordials.SafeWeakSet = makeSafe( | |||
| 171 | 171 | } | |
| 172 | 172 | ); | |
| 173 | 173 | ||
| 174 | + // Create copies of configurable value properties of the global object | ||
| 175 | + [ | ||
| 176 | + 'globalThis', | ||
| 177 | + ].forEach((name) => { | ||
| 178 | + // eslint-disable-next-line no-restricted-globals | ||
| 179 | + primordials[name] = globalThis[name]; | ||
| 180 | + }); | ||
| 181 | + | ||
| 174 | 182 | // Create copies of URI handling functions | |
| 175 | 183 | [ | |
| 176 | 184 | decodeURI, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,9 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | + const { | ||
| 4 | + globalThis, | ||
| 5 | + } = primordials; | ||
| 6 | + | ||
| 3 | 7 | const path = require('path'); | |
| 4 | 8 | ||
| 5 | 9 | const { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,9 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | + const { | ||
| 4 | + globalThis, | ||
| 5 | + } = primordials; | ||
| 6 | + | ||
| 3 | 7 | process.emitWarning( | |
| 4 | 8 | 'These APIs are for internal testing only. Do not use them.', | |
| 5 | 9 | 'internal/test/binding'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,7 @@ const { | |||
| 6 | 6 | SafeSet, | |
| 7 | 7 | SafeWeakMap, | |
| 8 | 8 | SymbolIterator, | |
| 9 | + globalThis, | ||
| 9 | 10 | } = primordials; | |
| 10 | 11 | ||
| 11 | 12 | // TODO(aduh95): Add FinalizationRegistry to primordials | |
| Back | FazBrowse Home | New Git URL |
0 commit comments