From 08ffc6344c108d692db54c5209cfc493a9cd30d9 Mon Sep 17 00:00:00 2001 From: LiviaMedeiros Date: Mon, 11 Sep 2023 16:39:02 +0800 Subject: [PATCH] tools: restrict internal code from using public `url` module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/49590 Reviewed-By: Yagiz Nizipli Reviewed-By: Chemi Atlow Reviewed-By: Geoffrey Booth Reviewed-By: Antoine du Hamel Reviewed-By: Michaƫl Zasso Reviewed-By: Luigi Pinca --- lib/.eslintrc.yaml | 4 ++++ lib/internal/bootstrap/switches/is_main_thread.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index cc4fa1975016eb..942d7cc1305eb4 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -175,6 +175,10 @@ rules: message: Use `const { structuredClone } = require('internal/structured_clone');` instead of the global. - name: SubtleCrypto message: Use `const { SubtleCrypto } = require('internal/crypto/webcrypto');` instead of the global. + no-restricted-modules: + - error + - name: url + message: Require `internal/url` instead of `url`. # Custom rules in tools/eslint-rules node-core/avoid-prototype-pollution: error node-core/lowercase-name-for-primitive: error diff --git a/lib/internal/bootstrap/switches/is_main_thread.js b/lib/internal/bootstrap/switches/is_main_thread.js index f2c3478e8bb5bf..8707bc7daaa616 100644 --- a/lib/internal/bootstrap/switches/is_main_thread.js +++ b/lib/internal/bootstrap/switches/is_main_thread.js @@ -290,7 +290,7 @@ rawMethods.resetStdioForTesting = function() { // Needed by the module loader and generally needed everywhere. require('fs'); require('util'); -require('url'); +require('url'); // eslint-disable-line no-restricted-modules require('internal/modules/cjs/loader'); require('internal/modules/esm/utils');