@xylabs/ts-scripts-yarn3 7.4.0 → 7.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/actions/deplint/checkPackage/checkPackage.mjs +41 -3
- package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +41 -3
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/index.mjs +41 -3
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
- package/dist/actions/deplint/deplint.mjs +41 -3
- package/dist/actions/deplint/deplint.mjs.map +1 -1
- package/dist/actions/deplint/implicitDevDependencies.mjs +52 -2
- package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/index.mjs +41 -3
- package/dist/actions/deplint/index.mjs.map +1 -1
- package/dist/actions/index.mjs +45 -7
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy.mjs +41 -3
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.mjs +45 -7
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +41 -3
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +41 -3
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +41 -3
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +2 -2
package/dist/bin/xy.mjs
CHANGED
|
@@ -974,15 +974,49 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
974
974
|
}
|
|
975
975
|
|
|
976
976
|
// src/actions/deplint/implicitDevDependencies.ts
|
|
977
|
+
import fs7 from "fs";
|
|
977
978
|
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
979
|
+
var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
980
|
+
var hasTypescriptFiles = ({ srcFiles, configFiles }) => hasFileWithExtension([...srcFiles, ...configFiles], tsExtensions);
|
|
981
|
+
var decoratorPattern = /^\s*@[a-zA-Z]\w*/m;
|
|
982
|
+
var hasDecorators = ({ srcFiles }) => srcFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
|
|
983
|
+
try {
|
|
984
|
+
const content = fs7.readFileSync(file, "utf8");
|
|
985
|
+
return decoratorPattern.test(content);
|
|
986
|
+
} catch {
|
|
987
|
+
return false;
|
|
988
|
+
}
|
|
989
|
+
});
|
|
990
|
+
var importPlugins = /* @__PURE__ */ new Set(["eslint-plugin-import-x", "eslint-plugin-import"]);
|
|
991
|
+
function hasImportPlugin({ location, allDependencies }) {
|
|
992
|
+
if (allDependencies.some((d) => importPlugins.has(d))) return true;
|
|
993
|
+
for (const dep of allDependencies) {
|
|
994
|
+
const pkgPath = findDepPackageJson(location, dep);
|
|
995
|
+
if (!pkgPath) continue;
|
|
996
|
+
try {
|
|
997
|
+
const pkg = JSON.parse(fs7.readFileSync(pkgPath, "utf8"));
|
|
998
|
+
const transitiveDeps = [
|
|
999
|
+
...Object.keys(pkg.dependencies ?? {}),
|
|
1000
|
+
...Object.keys(pkg.peerDependencies ?? {})
|
|
1001
|
+
];
|
|
1002
|
+
if (transitiveDeps.some((d) => importPlugins.has(d))) return true;
|
|
1003
|
+
} catch {
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
return false;
|
|
1007
|
+
}
|
|
978
1008
|
var rules = [
|
|
979
1009
|
{
|
|
980
1010
|
package: "typescript",
|
|
981
|
-
isNeeded:
|
|
1011
|
+
isNeeded: hasTypescriptFiles
|
|
982
1012
|
},
|
|
983
1013
|
{
|
|
984
1014
|
package: "eslint-import-resolver-typescript",
|
|
985
|
-
isNeeded: (
|
|
1015
|
+
isNeeded: (context) => hasTypescriptFiles(context) && context.allDependencies.includes("eslint") && hasImportPlugin(context)
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
package: "tslib",
|
|
1019
|
+
isNeeded: hasDecorators
|
|
986
1020
|
}
|
|
987
1021
|
];
|
|
988
1022
|
function getImplicitDevDependencies(context) {
|
|
@@ -1026,8 +1060,12 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1026
1060
|
peerDependencies
|
|
1027
1061
|
}, sourceParams, fileContext) {
|
|
1028
1062
|
const allImports = allExternalImports(sourceParams);
|
|
1029
|
-
const implicitDeps = getImplicitDevDependencies(fileContext);
|
|
1030
1063
|
const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
|
|
1064
|
+
const implicitDeps = getImplicitDevDependencies({
|
|
1065
|
+
...fileContext,
|
|
1066
|
+
allDependencies: allDeps,
|
|
1067
|
+
location
|
|
1068
|
+
});
|
|
1031
1069
|
const requiredPeers = getRequiredPeerDependencies(location, allDeps);
|
|
1032
1070
|
const scriptRefs = getScriptReferencedPackages(location, allDeps);
|
|
1033
1071
|
let unusedDevDependencies = 0;
|