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

tools: add console to the list of restricted globals #42012

Merged
merged 1 commit into from Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/.eslintrc.yaml
Expand Up @@ -93,6 +93,8 @@ rules:
message: Use `const { clearInterval } = require('timers');` instead of the global.
- name: clearTimeout
message: Use `const { clearTimeout } = require('timers');` instead of the global.
- name: console
message: Use `const { console } = require('internal/console/global');` instead of the global.
- name: crypto
message: Use `const { crypto } = require('internal/crypto/webcrypto');` instead of the global.
- name: Crypto
Expand Down
5 changes: 3 additions & 2 deletions lib/internal/freeze_intrinsics.js
Expand Up @@ -19,7 +19,6 @@
// https://github.com/google/caja/blob/HEAD/src/com/google/caja/ses/repairES5.js
// https://github.com/tc39/proposal-ses/blob/e5271cc42a257a05dcae2fd94713ed2f46c08620/shim/src/freeze.js

/* global console */
'use strict';

const {
Expand Down Expand Up @@ -133,6 +132,8 @@ const {
} = globalThis;

module.exports = function() {
const { Console } = require('internal/console/constructor');
const { console } = require('internal/console/global');
const {
clearImmediate,
clearInterval,
Expand Down Expand Up @@ -216,7 +217,7 @@ module.exports = function() {
PromisePrototype, // 27.2

// Other APIs / Web Compatibility
console.Console.prototype,
Console.prototype,
WebAssembly.Module.prototype,
WebAssembly.Instance.prototype,
WebAssembly.Table.prototype,
Expand Down
4 changes: 1 addition & 3 deletions lib/internal/v8_prof_polyfill.js
Expand Up @@ -27,7 +27,7 @@

'use strict';

/* eslint-disable node-core/prefer-primordials */
/* eslint-disable node-core/prefer-primordials, no-restricted-globals */
/* global console */

module.exports = { versionCheck };
Expand Down Expand Up @@ -73,7 +73,6 @@ function read(fileName) {
}
const quit = process.exit;
// Polyfill "readline()".
// eslint-disable-next-line no-restricted-globals
const logFile = globalThis.arguments[globalThis.arguments.length - 1];
try {
fs.accessSync(logFile);
Expand Down Expand Up @@ -163,7 +162,6 @@ function macCppfiltNm(out) {
});
}

// eslint-disable-next-line no-restricted-globals
Object.assign(globalThis, {
os,
print,
Expand Down