@xylabs/ts-scripts-yarn3 6.4.0 → 6.4.2

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/xy/xy.mjs CHANGED
@@ -701,7 +701,8 @@ function getImportsFromFile(filePath, importPaths) {
701
701
  ts.forEachChild(node, visit);
702
702
  }
703
703
  visit(sourceFile);
704
- const cleanedImports = imports.filter((imp) => !imp.startsWith(".") && !imp.startsWith("#") && !imp.startsWith("node:")).map(getBasePackageName);
704
+ const importsStartsWithExcludes = [".", "#", "node:", "@types/"];
705
+ const cleanedImports = imports.filter((imp) => !importsStartsWithExcludes.some((exc) => imp.startsWith(exc))).map(getBasePackageName);
705
706
  for (const imp of cleanedImports) {
706
707
  importPaths[imp] = importPaths[imp] || [];
707
708
  importPaths[imp].push(filePath);
@@ -743,7 +744,8 @@ function getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles }) {
743
744
  function check({
744
745
  name,
745
746
  location,
746
- devDeps = false
747
+ devDeps = false,
748
+ peerDeps = false
747
749
  }) {
748
750
  const { prodSourceFiles, devSourceFiles } = findFiles(location);
749
751
  const {
@@ -759,6 +761,7 @@ function check({
759
761
  } = getDependenciesFromPackageJson(`${location}/package.json`);
760
762
  let unlistedDependencies = 0;
761
763
  let unlistedDevDependencies = 0;
764
+ let unusedDependencies = 0;
762
765
  for (const imp of externalProdImports) {
763
766
  if (!dependencies.includes(imp) && !peerDependencies.includes(imp)) {
764
767
  unlistedDependencies++;
@@ -769,20 +772,22 @@ function check({
769
772
  }
770
773
  for (const dep of dependencies) {
771
774
  if (!externalProdImports.includes(dep)) {
772
- unlistedDependencies++;
775
+ unusedDependencies++;
773
776
  console.log(`[${chalk12.blue(name)}] Unused dependency in package.json: ${chalk12.red(dep)}`);
774
777
  console.log(` ${location}/package.json
775
778
  `);
776
779
  console.log("");
777
780
  }
778
781
  }
779
- for (const dep of peerDependencies) {
780
- if (!externalProdImports.includes(dep)) {
781
- unlistedDependencies++;
782
- console.log(`[${chalk12.blue(name)}] Unused peerDependency in package.json: ${chalk12.red(dep)}`);
783
- console.log(` ${location}/package.json
782
+ if (peerDeps) {
783
+ for (const dep of peerDependencies) {
784
+ if (!externalProdImports.includes(dep)) {
785
+ unusedDependencies++;
786
+ console.log(`[${chalk12.blue(name)}] Unused peerDependency in package.json: ${chalk12.red(dep)}`);
787
+ console.log(` ${location}/package.json
784
788
  `);
785
- console.log("");
789
+ console.log("");
790
+ }
786
791
  }
787
792
  }
788
793
  if (devDeps) {
@@ -794,7 +799,7 @@ function check({
794
799
  }
795
800
  }
796
801
  }
797
- const totalErrors = unlistedDependencies + unlistedDevDependencies;
802
+ const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies;
798
803
  return totalErrors;
799
804
  }
800
805
  var deplint = ({ pkg }) => {