@xylabs/ts-scripts-yarn3 6.4.2 → 6.4.4
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/actions/deplint.mjs +53 -7
- package/dist/actions/deplint.mjs.map +1 -1
- package/dist/actions/index.mjs +53 -7
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy.mjs +53 -7
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.mjs +53 -7
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +53 -7
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +53 -7
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +53 -7
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +4 -5
package/dist/xy/index.mjs
CHANGED
|
@@ -681,7 +681,7 @@ function getBasePackageName(importName) {
|
|
|
681
681
|
}
|
|
682
682
|
return importName.split("/")[0];
|
|
683
683
|
}
|
|
684
|
-
function getImportsFromFile(filePath, importPaths) {
|
|
684
|
+
function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
685
685
|
const sourceCode = fs2.readFileSync(filePath, "utf8");
|
|
686
686
|
const sourceFile = ts.createSourceFile(
|
|
687
687
|
path3.basename(filePath),
|
|
@@ -690,24 +690,41 @@ function getImportsFromFile(filePath, importPaths) {
|
|
|
690
690
|
true
|
|
691
691
|
);
|
|
692
692
|
const imports = [];
|
|
693
|
+
const typeImports = [];
|
|
693
694
|
function visit(node) {
|
|
694
695
|
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
|
|
695
696
|
const moduleSpecifier = node.moduleSpecifier?.getFullText();
|
|
697
|
+
const isTypeImport = ts.isImportDeclaration(node) ? node.importClause?.isTypeOnly ?? false : false;
|
|
696
698
|
if (moduleSpecifier) {
|
|
697
699
|
const trimmed = moduleSpecifier.split("'").at(1) ?? moduleSpecifier;
|
|
700
|
+
if (isTypeImport) {
|
|
701
|
+
typeImports.push(trimmed);
|
|
702
|
+
} else {
|
|
703
|
+
imports.push(trimmed);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
} else if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
|
|
707
|
+
const [arg] = node.arguments;
|
|
708
|
+
if (ts.isStringLiteral(arg)) {
|
|
709
|
+
const trimmed = arg.text;
|
|
698
710
|
imports.push(trimmed);
|
|
699
711
|
}
|
|
700
712
|
}
|
|
701
713
|
ts.forEachChild(node, visit);
|
|
702
714
|
}
|
|
703
715
|
visit(sourceFile);
|
|
704
|
-
const importsStartsWithExcludes = [".", "#", "node:"
|
|
716
|
+
const importsStartsWithExcludes = [".", "#", "node:"];
|
|
705
717
|
const cleanedImports = imports.filter((imp) => !importsStartsWithExcludes.some((exc) => imp.startsWith(exc))).map(getBasePackageName);
|
|
718
|
+
const cleanedTypeImports = typeImports.filter((imp) => !importsStartsWithExcludes.some((exc) => imp.startsWith(exc))).map(getBasePackageName);
|
|
706
719
|
for (const imp of cleanedImports) {
|
|
707
720
|
importPaths[imp] = importPaths[imp] || [];
|
|
708
721
|
importPaths[imp].push(filePath);
|
|
709
722
|
}
|
|
710
|
-
|
|
723
|
+
for (const imp of cleanedTypeImports) {
|
|
724
|
+
typeImportPaths[imp] = typeImportPaths[imp] || [];
|
|
725
|
+
typeImportPaths[imp].push(filePath);
|
|
726
|
+
}
|
|
727
|
+
return [cleanedImports, cleanedTypeImports];
|
|
711
728
|
}
|
|
712
729
|
function findFilesByGlob(cwd, pattern) {
|
|
713
730
|
return globSync(pattern, { cwd, absolute: true });
|
|
@@ -727,18 +744,29 @@ function findFiles(path4) {
|
|
|
727
744
|
}
|
|
728
745
|
function getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles }) {
|
|
729
746
|
const prodImportPaths = {};
|
|
730
|
-
const
|
|
747
|
+
const prodTypeImportPaths = {};
|
|
748
|
+
const prodImportPairs = prodSourceFiles.map((path4) => getImportsFromFile(path4, prodImportPaths, prodTypeImportPaths));
|
|
749
|
+
const prodImports = prodImportPairs.flatMap((pair) => pair[0]);
|
|
750
|
+
const prodTypeImports = prodImportPairs.flatMap((pair) => pair[1]);
|
|
731
751
|
const devImportPaths = {};
|
|
732
|
-
const
|
|
752
|
+
const devTypeImportPaths = {};
|
|
753
|
+
const devImportPairs = devSourceFiles.map((path4) => getImportsFromFile(path4, devImportPaths, devTypeImportPaths));
|
|
754
|
+
const devImports = devImportPairs.flatMap((pair) => pair[0]);
|
|
755
|
+
const devTypeImports = devImportPairs.flatMap((pair) => pair[1]);
|
|
733
756
|
const externalProdImports = prodImports.filter((imp) => !imp.startsWith(".") && !imp.startsWith("#") && !imp.startsWith("node:"));
|
|
757
|
+
const externalProdTypeImports = prodTypeImports.filter((imp) => !imp.startsWith(".") && !imp.startsWith("#") && !imp.startsWith("node:"));
|
|
734
758
|
const externalDevImports = devImports.filter((imp) => !imp.startsWith(".") && !imp.startsWith("#") && !imp.startsWith("node:"));
|
|
735
759
|
return {
|
|
736
760
|
prodImports,
|
|
737
761
|
devImports,
|
|
738
762
|
prodImportPaths,
|
|
763
|
+
prodTypeImportPaths,
|
|
739
764
|
devImportPaths,
|
|
740
765
|
externalProdImports,
|
|
741
|
-
externalDevImports
|
|
766
|
+
externalDevImports,
|
|
767
|
+
prodTypeImports,
|
|
768
|
+
devTypeImports,
|
|
769
|
+
externalProdTypeImports
|
|
742
770
|
};
|
|
743
771
|
}
|
|
744
772
|
function check({
|
|
@@ -749,7 +777,9 @@ function check({
|
|
|
749
777
|
}) {
|
|
750
778
|
const { prodSourceFiles, devSourceFiles } = findFiles(location);
|
|
751
779
|
const {
|
|
780
|
+
prodTypeImportPaths,
|
|
752
781
|
prodImportPaths,
|
|
782
|
+
externalProdTypeImports,
|
|
753
783
|
devImportPaths,
|
|
754
784
|
externalProdImports,
|
|
755
785
|
externalDevImports
|
|
@@ -762,6 +792,15 @@ function check({
|
|
|
762
792
|
let unlistedDependencies = 0;
|
|
763
793
|
let unlistedDevDependencies = 0;
|
|
764
794
|
let unusedDependencies = 0;
|
|
795
|
+
let typesInDependencies = 0;
|
|
796
|
+
for (const imp of externalProdTypeImports) {
|
|
797
|
+
if (!dependencies.includes(imp) && !peerDependencies.includes(imp) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`)) {
|
|
798
|
+
unlistedDependencies++;
|
|
799
|
+
console.log(`[${chalk12.blue(name)}] Missing dependency in package.json: ${chalk12.red(imp)}`);
|
|
800
|
+
console.log(` ${prodTypeImportPaths[imp].join("\n")}`);
|
|
801
|
+
console.log("");
|
|
802
|
+
}
|
|
803
|
+
}
|
|
765
804
|
for (const imp of externalProdImports) {
|
|
766
805
|
if (!dependencies.includes(imp) && !peerDependencies.includes(imp)) {
|
|
767
806
|
unlistedDependencies++;
|
|
@@ -771,6 +810,13 @@ function check({
|
|
|
771
810
|
}
|
|
772
811
|
}
|
|
773
812
|
for (const dep of dependencies) {
|
|
813
|
+
if (dep.startsWith("@types/")) {
|
|
814
|
+
typesInDependencies++;
|
|
815
|
+
console.log(`[${chalk12.blue(name)}] @types in dependencies in package.json: ${chalk12.red(dep)}`);
|
|
816
|
+
console.log(` ${location}/package.json
|
|
817
|
+
`);
|
|
818
|
+
console.log("");
|
|
819
|
+
}
|
|
774
820
|
if (!externalProdImports.includes(dep)) {
|
|
775
821
|
unusedDependencies++;
|
|
776
822
|
console.log(`[${chalk12.blue(name)}] Unused dependency in package.json: ${chalk12.red(dep)}`);
|
|
@@ -799,7 +845,7 @@ function check({
|
|
|
799
845
|
}
|
|
800
846
|
}
|
|
801
847
|
}
|
|
802
|
-
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies;
|
|
848
|
+
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + typesInDependencies;
|
|
803
849
|
return totalErrors;
|
|
804
850
|
}
|
|
805
851
|
var deplint = ({ pkg }) => {
|