From 523b74c7d2ebfe9442f3e812b449f291c7706780 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Fri, 8 Sep 2023 00:27:50 -0700 Subject: [PATCH] Restrict use of global URL in certain packages (#246) --- .changeset/fuzzy-walls-shake.md | 2 ++ .eslintrc.js | 12 ++++++++++++ packages/proxy-agent/test/test.ts | 1 + packages/socks-proxy-agent/test/test.ts | 1 + 4 files changed, 16 insertions(+) create mode 100644 .changeset/fuzzy-walls-shake.md diff --git a/.changeset/fuzzy-walls-shake.md b/.changeset/fuzzy-walls-shake.md new file mode 100644 index 00000000..a845151c --- /dev/null +++ b/.changeset/fuzzy-walls-shake.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.eslintrc.js b/.eslintrc.js index 5c9295fb..3d5fb05c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,4 +13,16 @@ module.exports = { 'plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', ], + overrides: [ + { + files: ['packages/{pac-proxy,proxy,socks-proxy}-agent/**/*'], + rules: { + 'no-restricted-globals': [ + 'error', + // https://github.com/TooTallNate/proxy-agents/pull/242 + { name: 'URL', message: 'Use url.URL instead' }, + ], + }, + }, + ], }; diff --git a/packages/proxy-agent/test/test.ts b/packages/proxy-agent/test/test.ts index ca3f8d21..5f6de6e7 100644 --- a/packages/proxy-agent/test/test.ts +++ b/packages/proxy-agent/test/test.ts @@ -1,6 +1,7 @@ import * as fs from 'fs'; import * as http from 'http'; import * as https from 'https'; +import { URL } from 'url'; import { once } from 'events'; import assert from 'assert'; import WebSocket, { WebSocketServer } from 'ws'; diff --git a/packages/socks-proxy-agent/test/test.ts b/packages/socks-proxy-agent/test/test.ts index 4e0619e8..737e8834 100644 --- a/packages/socks-proxy-agent/test/test.ts +++ b/packages/socks-proxy-agent/test/test.ts @@ -3,6 +3,7 @@ import * as https from 'https'; import * as http from 'http'; import * as path from 'path'; import * as fs from 'fs'; +import { URL } from 'url'; import dns2 from 'dns2'; // @ts-expect-error no types import socks from 'socksv5';