eslint-plugin-node-dependencies 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,11 +8,42 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  const synckit_1 = require("synckit");
16
+ const tunnel_agent_1 = __importDefault(require("tunnel-agent"));
13
17
  const dynamicImport = new Function("m", "return import(m)");
14
18
  (0, synckit_1.runAsWorker)((packageName, options) => __awaiter(void 0, void 0, void 0, function* () {
15
19
  const m = yield dynamicImport("package-json");
16
20
  const packageJson = (m === null || m === void 0 ? void 0 : m.default) || m;
17
- return packageJson(packageName, options);
21
+ return packageJson(packageName, withAutoProxy(options));
18
22
  }));
23
+ function withAutoProxy(options) {
24
+ const PROXY_ENV = [
25
+ "https_proxy",
26
+ "HTTPS_PROXY",
27
+ "http_proxy",
28
+ "HTTP_PROXY",
29
+ "npm_config_https_proxy",
30
+ "npm_config_http_proxy",
31
+ ];
32
+ const proxyStr = PROXY_ENV.map((k) => process.env[k]).find((v) => v);
33
+ if (proxyStr) {
34
+ const proxyUrl = new URL(proxyStr);
35
+ const tunnelOption = {
36
+ proxy: {
37
+ host: proxyUrl.hostname,
38
+ port: Number(proxyUrl.port),
39
+ proxyAuth: proxyUrl.username || proxyUrl.password
40
+ ? `${proxyUrl.username}:${proxyUrl.password}`
41
+ : undefined,
42
+ },
43
+ };
44
+ const httpAgent = tunnel_agent_1.default[`httpOverHttp${proxyUrl.protocol === "https:" ? "s" : ""}`](tunnelOption);
45
+ const httpsAgent = tunnel_agent_1.default[`httpsOverHttp${proxyUrl.protocol === "https:" ? "s" : ""}`](tunnelOption);
46
+ return Object.assign({ agent: { http: httpAgent, https: httpsAgent } }, options);
47
+ }
48
+ return options;
49
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-node-dependencies",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "ESLint plugin to check Node.js dependencies.",
5
5
  "engines": {
6
6
  "node": ">=14.17.0"
@@ -72,7 +72,7 @@
72
72
  "eslint-plugin-json-schema-validator": "^3.0.0",
73
73
  "eslint-plugin-jsonc": "^2.0.0",
74
74
  "eslint-plugin-node": "^11.1.0",
75
- "eslint-plugin-node-dependencies": "^0.8.0",
75
+ "eslint-plugin-node-dependencies": "^0.9.0",
76
76
  "eslint-plugin-prettier": "^4.0.0",
77
77
  "eslint-plugin-regexp": "^1.0.0",
78
78
  "eslint-plugin-vue": "^9.0.0",
@@ -98,6 +98,7 @@
98
98
  "npm-package-arg": "^9.0.0",
99
99
  "package-json": "^8.1.0",
100
100
  "semver": "^7.3.5",
101
- "synckit": "^0.7.1"
101
+ "synckit": "^0.7.1",
102
+ "tunnel-agent": "^0.6.0"
102
103
  }
103
104
  }