Skip to content

Commit 0f4f2dd

Browse files
aduh95bengl
authored andcommitted
tools: add console to the list of restricted globals
PR-URL: #42012 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mestery <[email protected]>
1 parent 10ca3bb commit 0f4f2dd

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

lib/.eslintrc.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ rules:
9191
message: Use `const { clearInterval } = require('timers');` instead of the global.
9292
- name: clearTimeout
9393
message: Use `const { clearTimeout } = require('timers');` instead of the global.
94+
- name: console
95+
message: Use `const { console } = require('internal/console/global');` instead of the global.
9496
- name: crypto
9597
message: Use `const { crypto } = require('internal/crypto/webcrypto');` instead of the global.
9698
- name: Crypto

lib/internal/freeze_intrinsics.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
// https://github.com/google/caja/blob/HEAD/src/com/google/caja/ses/repairES5.js
2020
// https://github.com/tc39/proposal-ses/blob/e5271cc42a257a05dcae2fd94713ed2f46c08620/shim/src/freeze.js
2121

22-
/* global console */
2322
'use strict';
2423

2524
const {
@@ -133,6 +132,8 @@ const {
133132
} = globalThis;
134133

135134
module.exports = function() {
135+
const { Console } = require('internal/console/constructor');
136+
const { console } = require('internal/console/global');
136137
const {
137138
clearImmediate,
138139
clearInterval,
@@ -216,7 +217,7 @@ module.exports = function() {
216217
PromisePrototype, // 27.2
217218

218219
// Other APIs / Web Compatibility
219-
console.Console.prototype,
220+
Console.prototype,
220221
WebAssembly.Module.prototype,
221222
WebAssembly.Instance.prototype,
222223
WebAssembly.Table.prototype,

lib/internal/v8_prof_polyfill.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
'use strict';
2929

30-
/* eslint-disable node-core/prefer-primordials */
30+
/* eslint-disable node-core/prefer-primordials, no-restricted-globals */
3131
/* global console */
3232

3333
module.exports = { versionCheck };
@@ -73,7 +73,6 @@ function read(fileName) {
7373
}
7474
const quit = process.exit;
7575
// Polyfill "readline()".
76-
// eslint-disable-next-line no-restricted-globals
7776
const logFile = globalThis.arguments[globalThis.arguments.length - 1];
7877
try {
7978
fs.accessSync(logFile);
@@ -163,7 +162,6 @@ function macCppfiltNm(out) {
163162
});
164163
}
165164

166-
// eslint-disable-next-line no-restricted-globals
167165
Object.assign(globalThis, {
168166
os,
169167
print,

0 commit comments

Comments
 (0)