Skip to content

Commit

Permalink
tools: add console to the list of restricted globals
Browse files Browse the repository at this point in the history
PR-URL: #42012
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Mestery <[email protected]>
  • Loading branch information
aduh95 authored and danielleadams committed Apr 24, 2022
1 parent da87c73 commit bbdf285
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit bbdf285

Please sign in to comment.