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