eslint-plugin-node-dependencies 0.13.1 → 1.0.0

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.
@@ -192,9 +192,7 @@ function getMetaFromName(name, cachedFilePath) {
192
192
  function getMetaFromNameWithoutCache(name, cachedFilePath) {
193
193
  let meta = [];
194
194
  try {
195
- const allMeta = (0, package_json_1.syncPackageJson)(name, {
196
- allVersions: true,
197
- });
195
+ const allMeta = (0, package_json_1.syncPackageJson)(name);
198
196
  meta = Object.values(allMeta.versions).map((vm) => {
199
197
  return {
200
198
  version: vm.version,
@@ -1,4 +1 @@
1
- import type { AbbreviatedMetadata, Options } from "package-json";
2
- type SyncPackageJson = (packageName: string, options: Options) => AbbreviatedMetadata;
3
- export declare const syncPackageJson: SyncPackageJson;
4
- export {};
1
+ export declare const syncPackageJson: (name: string) => import("package-json").AbbreviatedMetadata;
@@ -3,13 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.syncPackageJson = void 0;
4
4
  const synckit_1 = require("synckit");
5
5
  const module_1 = require("module");
6
- exports.syncPackageJson = (0, synckit_1.createSyncFn)(getWorkerPath());
6
+ exports.syncPackageJson = (0, synckit_1.createSyncFn)(getWorkerPath(), {
7
+ timeout: 10000,
8
+ });
7
9
  function getWorkerPath() {
8
10
  try {
9
- return require.resolve("./worker");
11
+ return require.resolve("./worker.mjs");
10
12
  }
11
13
  catch (_a) {
12
14
  }
13
15
  const r = (0, module_1.createRequire)(__filename);
14
- return r.resolve(`./worker.ts`);
16
+ return r.resolve("./worker.mts");
15
17
  }
@@ -0,0 +1 @@
1
+ export declare function setupProxy(): void;
@@ -0,0 +1,26 @@
1
+ import packageJson from "package-json";
2
+ import { runAsWorker } from "synckit";
3
+ import { ProxyAgent, setGlobalDispatcher } from "undici";
4
+ let proxySet = false;
5
+ const PROXY_ENV = [
6
+ "https_proxy",
7
+ "HTTPS_PROXY",
8
+ "http_proxy",
9
+ "HTTP_PROXY",
10
+ "npm_config_https_proxy",
11
+ "npm_config_http_proxy",
12
+ ];
13
+ export function setupProxy() {
14
+ if (proxySet) {
15
+ return;
16
+ }
17
+ proxySet = true;
18
+ const proxy = PROXY_ENV.map((k) => process.env[k]).find((v) => v);
19
+ if (proxy) {
20
+ setGlobalDispatcher(new ProxyAgent(proxy));
21
+ }
22
+ }
23
+ runAsWorker((packageName) => {
24
+ setupProxy();
25
+ return packageJson(packageName, { allVersions: true });
26
+ });
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "eslint-plugin-node-dependencies",
3
- "version": "0.13.1",
3
+ "version": "1.0.0",
4
4
  "description": "ESLint plugin to check Node.js dependencies.",
5
5
  "engines": {
6
- "node": ">=14.17.0"
6
+ "node": "^18.17.0 || >=20.5.0"
7
7
  },
8
8
  "main": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
@@ -34,11 +34,11 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "jsonc-eslint-parser": "^2.0.2",
37
- "npm-package-arg": "^10.0.0",
38
- "package-json": "^8.1.0",
37
+ "npm-package-arg": "^12.0.2",
38
+ "package-json": "^10.0.1",
39
39
  "semver": "^7.3.5",
40
- "synckit": "^0.7.1",
41
- "tunnel-agent": "^0.6.0"
40
+ "synckit": "^0.11.0",
41
+ "undici": "^6.21.2 || ^7.8.0"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public"
@@ -1 +0,0 @@
1
- export {};
@@ -1,49 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const synckit_1 = require("synckit");
16
- const tunnel_agent_1 = __importDefault(require("tunnel-agent"));
17
- const dynamicImport = new Function("m", "return import(m)");
18
- (0, synckit_1.runAsWorker)((packageName, options) => __awaiter(void 0, void 0, void 0, function* () {
19
- const m = yield dynamicImport("package-json");
20
- const packageJson = (m === null || m === void 0 ? void 0 : m.default) || m;
21
- return packageJson(packageName, withAutoProxy(options));
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
- }