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