npm-pkg-lint 5.1.7 → 5.1.9

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.
package/dist/index.js CHANGED
@@ -15,7 +15,11 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
15
15
  throw Error('Dynamic require of "' + x + '" is not supported');
16
16
  });
17
17
  var __commonJS = (cb, mod) => function __require2() {
18
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
+ try {
19
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20
+ } catch (e) {
21
+ throw mod = 0, e;
22
+ }
19
23
  };
20
24
  var __copyProps = (to2, from, except, desc) => {
21
25
  if (from && typeof from === "object" || typeof from === "function") {
@@ -4693,15 +4697,16 @@ var require_range = __commonJS({
4693
4697
  };
4694
4698
  var replaceTilde = (comp, options) => {
4695
4699
  const r = options.loose ? re2[t.TILDELOOSE] : re2[t.TILDE];
4700
+ const z2 = options.includePrerelease ? "-0" : "";
4696
4701
  return comp.replace(r, (_2, M2, m2, p2, pr2) => {
4697
4702
  debug("tilde", comp, _2, M2, m2, p2, pr2);
4698
4703
  let ret;
4699
4704
  if (isX(M2)) {
4700
4705
  ret = "";
4701
4706
  } else if (isX(m2)) {
4702
- ret = `>=${M2}.0.0 <${+M2 + 1}.0.0-0`;
4707
+ ret = `>=${M2}.0.0${z2} <${+M2 + 1}.0.0-0`;
4703
4708
  } else if (isX(p2)) {
4704
- ret = `>=${M2}.${m2}.0 <${M2}.${+m2 + 1}.0-0`;
4709
+ ret = `>=${M2}.${m2}.0${z2} <${M2}.${+m2 + 1}.0-0`;
4705
4710
  } else if (pr2) {
4706
4711
  debug("replaceTilde pr", pr2);
4707
4712
  ret = `>=${M2}.${m2}.${p2}-${pr2} <${M2}.${+m2 + 1}.0-0`;
@@ -7656,7 +7661,7 @@ var blacklist = [
7656
7661
  filename("gulpfile.esm.js"),
7657
7662
  filename("Herebyfile.js"),
7658
7663
  filename("Herebyfile.mjs"),
7659
- /* ci */
7664
+ /* CI */
7660
7665
  /^\.azure-.*$/,
7661
7666
  directory(".circleci"),
7662
7667
  directory(".github"),
@@ -8738,7 +8743,7 @@ var bn = (s3, t) => {
8738
8743
  t = t.slice((e + " ").length);
8739
8744
  let i = t.split("="), r = i.shift();
8740
8745
  if (!r) return s3;
8741
- let n = r.replace(/^SCHILY\.(dev|ino|nlink)/, "$1"), o = i.join("=");
8746
+ let n = r.replace(/^SCHILY\.(dev|ino|nlink)/, "$1"), o = i.join("=").replace(/\0.*/, "");
8742
8747
  return s3[n] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(n) ? new Date(Number(o) * 1e3) : /^[0-9]+$/.test(o) ? +o : o, s3;
8743
8748
  };
8744
8749
  var _n = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
@@ -10661,7 +10666,9 @@ async function getFileList(filename2) {
10661
10666
  await Ft({
10662
10667
  file: filename2,
10663
10668
  strict: true,
10664
- onentry: (entry) => entries.push(entry)
10669
+ onReadEntry(entry) {
10670
+ entries.push(entry);
10671
+ }
10665
10672
  });
10666
10673
  return entries.map((entry) => {
10667
10674
  const filename3 = entry.path;
@@ -10699,11 +10706,11 @@ function blacklistedFiles(filelist) {
10699
10706
  function normalizeRequiredFiles(src) {
10700
10707
  if (typeof src === "string") {
10701
10708
  return [src];
10702
- } else if (Array.isArray(src)) {
10709
+ }
10710
+ if (Array.isArray(src)) {
10703
10711
  return src;
10704
- } else {
10705
- return Object.values(src).filter((it2) => it2 !== false);
10706
10712
  }
10713
+ return Object.values(src).filter((it2) => it2 !== false);
10707
10714
  }
10708
10715
  function* yieldRequiredFiles(src, template) {
10709
10716
  const files = normalizeRequiredFiles(src);
@@ -11473,17 +11480,21 @@ function* validateOrder2(pkgAst, value, path8) {
11473
11480
  const keys = Object.keys(value);
11474
11481
  if (keys.includes("require")) {
11475
11482
  for (const esm of ["import", "module"]) {
11476
- if (keys.includes(esm) && keys.indexOf(esm) > keys.indexOf("require")) {
11477
- const { line, column } = jsonLocation(pkgAst, "member", "exports", ...path8, esm);
11478
- const property = path8.map((it2) => `["${it2}"]`).join("");
11479
- yield {
11480
- ruleId: ruleId5,
11481
- severity: severity3,
11482
- message: `"${esm}" must come before "require" in "exports${property}"`,
11483
- line,
11484
- column
11485
- };
11483
+ if (!keys.includes(esm)) {
11484
+ continue;
11485
+ }
11486
+ if (keys.indexOf(esm) <= keys.indexOf("require")) {
11487
+ continue;
11486
11488
  }
11489
+ const { line, column } = jsonLocation(pkgAst, "member", "exports", ...path8, esm);
11490
+ const property = path8.map((it2) => `["${it2}"]`).join("");
11491
+ yield {
11492
+ ruleId: ruleId5,
11493
+ severity: severity3,
11494
+ message: `"${esm}" must come before "require" in "exports${property}"`,
11495
+ line,
11496
+ column
11497
+ };
11487
11498
  }
11488
11499
  }
11489
11500
  for (const key of keys) {
@@ -11594,7 +11605,7 @@ function getProtocol(version2, field) {
11594
11605
  }
11595
11606
  return null;
11596
11607
  }
11597
- var githubShorthandRe = /^[A-Za-z][\w-]*\/[\w.-]+(?:#.+)?$/;
11608
+ var githubShorthandRe = /^[A-Z][\w-]*\/[\w.-]+(?:#.+)?$/i;
11598
11609
  var gitUrlRe = /^[^@]+@[^:]+:.+/;
11599
11610
  function isGithubShorthand(version2) {
11600
11611
  return !version2.includes(":") && githubShorthandRe.test(version2);
@@ -11720,7 +11731,7 @@ function* outdatedEngines(pkg, pkgAst, ignoreNodeVersion) {
11720
11731
  if (!descriptor.eol) {
11721
11732
  break;
11722
11733
  }
11723
- const expanded = version2.replaceAll(/[*Xx]/g, "999");
11734
+ const expanded = version2.replaceAll(/[*X]/gi, "999");
11724
11735
  if (!import_semver2.default.satisfies(expanded, range)) {
11725
11736
  continue;
11726
11737
  }
@@ -11879,7 +11890,8 @@ async function* getDeepDependencies(pkg, visited, dependency) {
11879
11890
  if (!pkgData) {
11880
11891
  return;
11881
11892
  }
11882
- for (let [key, version2] of Object.entries(pkgData.dependencies ?? {})) {
11893
+ const { dependencies = {} } = pkgData;
11894
+ for (let [key, version2] of Object.entries(dependencies)) {
11883
11895
  if (version2.startsWith("npm:")) {
11884
11896
  const [newKey, newVersion] = version2.slice("npm:".length).split("@", 2);
11885
11897
  key = newKey;
@@ -11951,6 +11963,7 @@ async function verifyEngineConstraint(pkg) {
11951
11963
  // src/validators/validation-error.ts
11952
11964
  var ValidationError = class extends Error {
11953
11965
  validator;
11966
+ /* eslint-disable-next-line unicorn/custom-error-definition -- technical debt */
11954
11967
  constructor(validator, message) {
11955
11968
  super(message);
11956
11969
  this.name = "ValidationError";
@@ -11960,7 +11973,7 @@ var ValidationError = class extends Error {
11960
11973
 
11961
11974
  // src/validators/non-empty.ts
11962
11975
  function isEmpty(value) {
11963
- return value === void 0 || value === null || value === "";
11976
+ return [void 0, null, ""].includes(value);
11964
11977
  }
11965
11978
  function nonempty(key, value) {
11966
11979
  if (isEmpty(value)) {
@@ -12088,7 +12101,8 @@ function validRepoUrl(key, value) {
12088
12101
  function validUrl(key, value) {
12089
12102
  if (typeof value === "string" && /^https:\/\/.+$/.test(value)) {
12090
12103
  return;
12091
- } else if (value && typeof value === "object" && "url" in value) {
12104
+ }
12105
+ if (value && typeof value === "object" && "url" in value) {
12092
12106
  validUrl(`${key}.url`, value.url);
12093
12107
  } else {
12094
12108
  throw new ValidationError(validUrl.name, `"${key}" must be a valid url (https only)`);
@@ -12317,7 +12331,7 @@ async function verifyShebang(pkg, tarball) {
12317
12331
  const contents = await getFileContent(tarball, binaries);
12318
12332
  for (const [filePath, content] of Object.entries(contents)) {
12319
12333
  const text = content.toString("utf-8");
12320
- if (/^#!.+?\r?\n/.test(text)) {
12334
+ if (/^#!.+\r?\n/.test(text)) {
12321
12335
  continue;
12322
12336
  }
12323
12337
  results.push({
@@ -12477,9 +12491,8 @@ async function run() {
12477
12491
  result.messages.sort((a, b2) => {
12478
12492
  if (a.line !== b2.line) {
12479
12493
  return a.line - b2.line;
12480
- } else {
12481
- return a.column - b2.column;
12482
12494
  }
12495
+ return a.column - b2.column;
12483
12496
  });
12484
12497
  }
12485
12498
  const output = stylish(results);