@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/index.mjs CHANGED
@@ -793,7 +793,8 @@ function getImportsFromFile(filePath, importPaths) {
793
793
  ts.forEachChild(node, visit);
794
794
  }
795
795
  visit(sourceFile);
796
- const cleanedImports = imports.filter((imp) => !imp.startsWith(".") && !imp.startsWith("#") && !imp.startsWith("node:")).map(getBasePackageName);
796
+ const importsStartsWithExcludes = [".", "#", "node:", "@types/"];
797
+ const cleanedImports = imports.filter((imp) => !importsStartsWithExcludes.some((exc) => imp.startsWith(exc))).map(getBasePackageName);
797
798
  for (const imp of cleanedImports) {
798
799
  importPaths[imp] = importPaths[imp] || [];
799
800
  importPaths[imp].push(filePath);
@@ -835,7 +836,8 @@ function getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles }) {
835
836
  function check({
836
837
  name,
837
838
  location,
838
- devDeps = false
839
+ devDeps = false,
840
+ peerDeps = false
839
841
  }) {
840
842
  const { prodSourceFiles, devSourceFiles } = findFiles(location);
841
843
  const {
@@ -851,6 +853,7 @@ function check({
851
853
  } = getDependenciesFromPackageJson(`${location}/package.json`);
852
854
  let unlistedDependencies = 0;
853
855
  let unlistedDevDependencies = 0;
856
+ let unusedDependencies = 0;
854
857
  for (const imp of externalProdImports) {
855
858
  if (!dependencies.includes(imp) && !peerDependencies.includes(imp)) {
856
859
  unlistedDependencies++;
@@ -861,20 +864,22 @@ function check({
861
864
  }
862
865
  for (const dep of dependencies) {
863
866
  if (!externalProdImports.includes(dep)) {
864
- unlistedDependencies++;
867
+ unusedDependencies++;
865
868
  console.log(`[${chalk14.blue(name)}] Unused dependency in package.json: ${chalk14.red(dep)}`);
866
869
  console.log(` ${location}/package.json
867
870
  `);
868
871
  console.log("");
869
872
  }
870
873
  }
871
- for (const dep of peerDependencies) {
872
- if (!externalProdImports.includes(dep)) {
873
- unlistedDependencies++;
874
- console.log(`[${chalk14.blue(name)}] Unused peerDependency in package.json: ${chalk14.red(dep)}`);
875
- console.log(` ${location}/package.json
874
+ if (peerDeps) {
875
+ for (const dep of peerDependencies) {
876
+ if (!externalProdImports.includes(dep)) {
877
+ unusedDependencies++;
878
+ console.log(`[${chalk14.blue(name)}] Unused peerDependency in package.json: ${chalk14.red(dep)}`);
879
+ console.log(` ${location}/package.json
876
880
  `);
877
- console.log("");
881
+ console.log("");
882
+ }
878
883
  }
879
884
  }
880
885
  if (devDeps) {
@@ -886,7 +891,7 @@ function check({
886
891
  }
887
892
  }
888
893
  }
889
- const totalErrors = unlistedDependencies + unlistedDevDependencies;
894
+ const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies;
890
895
  return totalErrors;
891
896
  }
892
897
  var deplint = ({ pkg }) => {