eslint-plugin-node-dependencies 0.9.0 → 0.10.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.
@@ -10,15 +10,17 @@ const ast_utils_1 = require("../utils/ast-utils");
10
10
  const semver_2 = require("../utils/semver");
11
11
  const meta_1 = require("../utils/meta");
12
12
  class EnginesContext {
13
- constructor(engineNames) {
13
+ constructor(engineNames, validDependencies = new Set()) {
14
14
  this.unprocessedEngines = new Set();
15
15
  this.invalidEngines = new Map();
16
16
  this.validEngines = new Set();
17
+ this.validDependencies = new Set();
17
18
  this.engines = new Set(engineNames);
18
19
  this.unprocessedEngines = new Set(this.engines);
20
+ this.validDependencies = validDependencies;
19
21
  }
20
22
  nextContext() {
21
- return new EnginesContext(this.unprocessedEngines);
23
+ return new EnginesContext(this.unprocessedEngines, this.validDependencies);
22
24
  }
23
25
  markAsProcessed(module) {
24
26
  this.unprocessedEngines.delete(module);
@@ -48,6 +50,12 @@ class EnginesContext {
48
50
  getInvalid() {
49
51
  return this.invalidEngines;
50
52
  }
53
+ markAsValidDependency(name, ver) {
54
+ this.validDependencies.add(`${name}@${ver}`);
55
+ }
56
+ isValidDependency(name, ver) {
57
+ return this.validDependencies.has(`${name}@${ver}`);
58
+ }
51
59
  }
52
60
  function buildAdjustRangeForSelf(comparisonType, original) {
53
61
  const adjustVers = [];
@@ -198,11 +206,13 @@ exports.default = (0, utils_1.createRule)("compat-engines", {
198
206
  if (ctx.isAllProcessed()) {
199
207
  return;
200
208
  }
209
+ ctx.markAsValidDependency(name, ver);
201
210
  if (deep) {
202
211
  for (const [n, ranges] of extractDependencies(metaList)) {
203
212
  const v = (0, semver_2.normalizeSemverRange)(...ranges);
204
- if (v)
213
+ if (v && !ctx.isValidDependency(n, v.raw)) {
205
214
  processDependencyModule(ctx.nextContext(), n, v.raw, currModules, node);
215
+ }
206
216
  }
207
217
  }
208
218
  }
@@ -35,9 +35,7 @@ exports.default = (0, utils_1.createRule)("no-deprecated", {
35
35
  : "dependencies, peerDependencies"](node) {
36
36
  const name = (0, ast_utils_1.getKeyFromJSONProperty)(node);
37
37
  const ver = (0, jsonc_eslint_parser_1.getStaticJSONValue)(node.value);
38
- if (typeof name !== "string" ||
39
- typeof ver !== "string" ||
40
- !ver) {
38
+ if (typeof name !== "string" || typeof ver !== "string" || !ver) {
41
39
  return;
42
40
  }
43
41
  const meta = (0, meta_1.getMetaFromNpm)(name, ver).get();
@@ -218,9 +218,7 @@ exports.default = (0, utils_1.createRule)("no-restricted-deps", {
218
218
  };
219
219
  }
220
220
  const regexp = (0, regexp_1.toRegExp)(option.package);
221
- const version = option.version
222
- ? (0, semver_2.getSemverRange)(option.version)
223
- : null;
221
+ const version = option.version ? (0, semver_2.getSemverRange)(option.version) : null;
224
222
  const validator = (n, v) => {
225
223
  if (regexp.test(n) && matchVersions(v, version)) {
226
224
  return {
@@ -74,8 +74,7 @@ exports.default = (0, utils_1.createRule)("prefer-caret-range-version", {
74
74
  if (!lowerRange.startsWith("~")) {
75
75
  if (lowerRange.startsWith("^") ||
76
76
  /^\d+$/u.test(range.value) ||
77
- ((range.value.endsWith(".x") ||
78
- range.value.endsWith(".*")) &&
77
+ ((range.value.endsWith(".x") || range.value.endsWith(".*")) &&
79
78
  !/\s+-\s+/u.test(range.value)))
80
79
  continue;
81
80
  }
@@ -75,8 +75,7 @@ exports.default = (0, utils_1.createRule)("prefer-tilde-range-version", {
75
75
  if (lowerRange.startsWith("~") ||
76
76
  /^\d+$/u.test(range.value) ||
77
77
  /^\d+\.\d+$/u.test(range.value) ||
78
- ((range.value.endsWith(".x") ||
79
- range.value.endsWith(".*")) &&
78
+ ((range.value.endsWith(".x") || range.value.endsWith(".*")) &&
80
79
  !/\s+-\s+/u.test(range.value)))
81
80
  continue;
82
81
  }
@@ -6,6 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const utils_1 = require("../utils");
7
7
  const compat_engines_1 = __importDefault(require("./compat-engines"));
8
8
  exports.default = (0, utils_1.createRule)("valid-engines", {
9
- meta: Object.assign(Object.assign({}, compat_engines_1.default.meta), { docs: Object.assign(Object.assign({}, compat_engines_1.default.meta.docs), { replacedBy: ["compat-engines"] }), deprecated: true }),
9
+ meta: Object.assign(Object.assign({}, compat_engines_1.default.meta), { docs: Object.assign({}, compat_engines_1.default.meta.docs), deprecated: true, replacedBy: ["compat-engines"] }),
10
10
  create: compat_engines_1.default.create,
11
11
  });
@@ -196,7 +196,7 @@ function getMetaFromNameWithoutCache(name, cachedFilePath) {
196
196
  };
197
197
  });
198
198
  }
199
- catch (e) {
199
+ catch (_e) {
200
200
  return null;
201
201
  }
202
202
  const timestamp = Date.now();
@@ -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
+ }
@@ -126,10 +126,8 @@ function joinComparators(a, b) {
126
126
  }
127
127
  function toRangeComparator(comparators) {
128
128
  if (comparators.length === 2) {
129
- if (comparators[0].operator === ">" ||
130
- comparators[0].operator === ">=") {
131
- if (comparators[1].operator === "<" ||
132
- comparators[1].operator === "<=") {
129
+ if (comparators[0].operator === ">" || comparators[0].operator === ">=") {
130
+ if (comparators[1].operator === "<" || comparators[1].operator === "<=") {
133
131
  return {
134
132
  min: comparators[0],
135
133
  max: comparators[1],
@@ -138,8 +136,7 @@ function toRangeComparator(comparators) {
138
136
  }
139
137
  else if (comparators[0].operator === "<" ||
140
138
  comparators[0].operator === "<=") {
141
- if (comparators[1].operator === ">" ||
142
- comparators[1].operator === ">=") {
139
+ if (comparators[1].operator === ">" || comparators[1].operator === ">=") {
143
140
  return {
144
141
  min: comparators[1],
145
142
  max: comparators[0],
@@ -148,8 +145,7 @@ function toRangeComparator(comparators) {
148
145
  }
149
146
  }
150
147
  if (comparators.length === 1) {
151
- if (comparators[0].operator === ">" ||
152
- comparators[0].operator === ">=") {
148
+ if (comparators[0].operator === ">" || comparators[0].operator === ">=") {
153
149
  return {
154
150
  min: comparators[0],
155
151
  max: null,
@@ -185,8 +181,7 @@ function maxNextVersion(range) {
185
181
  max = compVer;
186
182
  }
187
183
  }
188
- else if (comparator.operator === ">=" ||
189
- comparator.operator === ">") {
184
+ else if (comparator.operator === ">=" || comparator.operator === ">") {
190
185
  hasMin = true;
191
186
  }
192
187
  }
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.10.0",
4
4
  "description": "ESLint plugin to check Node.js dependencies.",
5
5
  "engines": {
6
6
  "node": ">=14.17.0"
@@ -25,8 +25,11 @@
25
25
  "new": "ts-node ./tools/new-rule.ts",
26
26
  "docs:watch": "export NODE_OPTIONS=--openssl-legacy-provider && vuepress dev --debug docs",
27
27
  "docs:build": "export NODE_OPTIONS=--openssl-legacy-provider && npm run build && vuepress build docs --no-cache",
28
+ "prerelease": "npm run test && npm run build",
29
+ "release": "changeset publish",
28
30
  "preversion": "npm test && git add .",
29
- "version": "env-cmd -e version npm run update && git add ."
31
+ "version": "env-cmd -e version npm run update && git add .",
32
+ "version:ci": "env-cmd -e version-ci npm run update && changeset version"
30
33
  },
31
34
  "repository": {
32
35
  "type": "git",
@@ -51,14 +54,16 @@
51
54
  "eslint": ">=6.0.0"
52
55
  },
53
56
  "devDependencies": {
54
- "@ota-meshi/eslint-plugin": "^0.11.0",
57
+ "@changesets/changelog-github": "^0.4.6",
58
+ "@changesets/cli": "^2.24.2",
59
+ "@ota-meshi/eslint-plugin": "^0.13.0",
55
60
  "@types/chai": "^4.2.18",
56
61
  "@types/eslint": "^8.0.0",
57
62
  "@types/eslint-scope": "^3.7.0",
58
63
  "@types/eslint-visitor-keys": "^1.0.0",
59
- "@types/estree": "^0.0.52",
60
- "@types/mocha": "^9.0.0",
61
- "@types/node": "^16.0.0",
64
+ "@types/estree": "^1.0.0",
65
+ "@types/mocha": "^10.0.0",
66
+ "@types/node": "^18.0.0",
62
67
  "@types/npm-package-arg": "^6.1.1",
63
68
  "@types/semver": "^7.3.8",
64
69
  "@typescript-eslint/eslint-plugin": "^5.0.0",
@@ -68,11 +73,11 @@
68
73
  "eslint": "^8.0.0",
69
74
  "eslint-config-prettier": "^8.0.0",
70
75
  "eslint-plugin-eslint-comments": "^3.2.0",
71
- "eslint-plugin-eslint-plugin": "^4.0.0",
72
- "eslint-plugin-json-schema-validator": "^3.0.0",
76
+ "eslint-plugin-eslint-plugin": "^5.0.0",
77
+ "eslint-plugin-json-schema-validator": "^4.0.0",
73
78
  "eslint-plugin-jsonc": "^2.0.0",
74
79
  "eslint-plugin-node": "^11.1.0",
75
- "eslint-plugin-node-dependencies": "^0.8.0",
80
+ "eslint-plugin-node-dependencies": "^0.9.0",
76
81
  "eslint-plugin-prettier": "^4.0.0",
77
82
  "eslint-plugin-regexp": "^1.0.0",
78
83
  "eslint-plugin-vue": "^9.0.0",
@@ -85,8 +90,8 @@
85
90
  "raw-loader": "^4.0.1",
86
91
  "stylelint": "^14.0.0",
87
92
  "stylelint-config-recommended-vue": "^1.0.0",
88
- "stylelint-config-standard": "^26.0.0",
89
- "stylelint-stylus": "^0.16.0",
93
+ "stylelint-config-standard": "^29.0.0",
94
+ "stylelint-stylus": "^0.17.0",
90
95
  "ts-node": "^10.0.0",
91
96
  "typescript": "^4.0.0",
92
97
  "vue-eslint-editor": "^1.1.0",
@@ -95,9 +100,13 @@
95
100
  },
96
101
  "dependencies": {
97
102
  "jsonc-eslint-parser": "^2.0.2",
98
- "npm-package-arg": "^9.0.0",
103
+ "npm-package-arg": "^10.0.0",
99
104
  "package-json": "^8.1.0",
100
105
  "semver": "^7.3.5",
101
- "synckit": "^0.7.1"
106
+ "synckit": "^0.7.1",
107
+ "tunnel-agent": "^0.6.0"
108
+ },
109
+ "publishConfig": {
110
+ "access": "public"
102
111
  }
103
112
  }