@xylabs/ts-scripts-yarn3 5.1.6 → 5.1.8

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
@@ -1062,18 +1062,13 @@ var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2
1062
1062
  });
1063
1063
  }, "lint");
1064
1064
  var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incremental } = {}) => {
1065
- console.log(chalk15.gray("Linting [All-Packages]"));
1065
+ console.log(chalk15.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
1066
1066
  const start = Date.now();
1067
1067
  const verboseOptions = verbose ? [
1068
1068
  "--verbose"
1069
1069
  ] : [
1070
1070
  "--no-verbose"
1071
1071
  ];
1072
- const fixOptions = fix2 ? [
1073
- "--fix"
1074
- ] : [
1075
- ""
1076
- ];
1077
1072
  const incrementalOptions = incremental ? [
1078
1073
  "--since",
1079
1074
  "-Apt"
@@ -1081,7 +1076,7 @@ var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incre
1081
1076
  "--parallel",
1082
1077
  "-Apt"
1083
1078
  ];
1084
- const result = runSteps("Lint [All-Packages]", [
1079
+ const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
1085
1080
  [
1086
1081
  "yarn",
1087
1082
  [
@@ -1090,12 +1085,11 @@ var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incre
1090
1085
  ...verboseOptions,
1091
1086
  ...incrementalOptions,
1092
1087
  "run",
1093
- fix2 ? "package-fix" : "package-lint",
1094
- ...fixOptions
1088
+ fix2 ? "package-fix" : "package-lint"
1095
1089
  ]
1096
1090
  ]
1097
1091
  ]);
1098
- console.log(`${chalk15.gray("Linted in")} [${chalk15.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk15.gray("seconds")}`);
1092
+ console.log(chalk15.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk15.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk15.gray("seconds")}`));
1099
1093
  return result;
1100
1094
  }, "lintAllPackages");
1101
1095
 
@@ -2107,6 +2101,7 @@ import { pathToFileURL } from "node:url";
2107
2101
  import chalk28 from "chalk";
2108
2102
  import { ESLint as ESLint3 } from "eslint";
2109
2103
  import { findUp } from "find-up";
2104
+ import picomatch from "picomatch";
2110
2105
  var dumpMessages2 = /* @__PURE__ */ __name((lintResults) => {
2111
2106
  const colors = [
2112
2107
  "white",
@@ -2136,37 +2131,41 @@ async function getRootESLintConfig() {
2136
2131
  return pathToFileURL(configPath);
2137
2132
  }
2138
2133
  __name(getRootESLintConfig, "getRootESLintConfig");
2134
+ function getFiles(dir, ignoreFolders) {
2135
+ const currentDirectory = cwd4();
2136
+ return readdirSync(dir, {
2137
+ withFileTypes: true
2138
+ }).flatMap((dirent) => {
2139
+ const res = path7.resolve(dir, dirent.name);
2140
+ const subDirectory = dir.split(currentDirectory)[1];
2141
+ const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name;
2142
+ const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
2143
+ if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
2144
+ return dirent.isDirectory() ? getFiles(res, ignoreFolders) : [
2145
+ res
2146
+ ];
2147
+ });
2148
+ }
2149
+ __name(getFiles, "getFiles");
2139
2150
  var packageLint = /* @__PURE__ */ __name(async (fix2 = false) => {
2140
2151
  const configPath = await getRootESLintConfig();
2141
2152
  const { default: eslintConfig } = await import(configPath.href);
2142
- const ignoreFolders = /* @__PURE__ */ new Set([
2153
+ const ignoreFolders = [
2143
2154
  "node_modules",
2144
2155
  "dist",
2145
- "packages"
2146
- ]);
2147
- function getFiles(dir, ignorePatterns2) {
2148
- return readdirSync(dir, {
2149
- withFileTypes: true
2150
- }).flatMap((dirent) => {
2151
- const res = path7.resolve(dir, dirent.name);
2152
- if (ignorePatterns2.some((pattern) => dir.includes(pattern))) return [];
2153
- return dirent.isDirectory() ? getFiles(res, ignorePatterns2) : res.endsWith(".ts") || res.endsWith(".tsx") || res.endsWith(".js") || res.endsWith(".jsx") ? [
2154
- res
2155
- ] : [];
2156
- });
2157
- }
2158
- __name(getFiles, "getFiles");
2156
+ "packages",
2157
+ ".git",
2158
+ "build"
2159
+ ];
2159
2160
  const engine = new ESLint3({
2160
2161
  baseConfig: [
2161
2162
  ...eslintConfig
2162
2163
  ],
2163
- fix: fix2
2164
+ fix: fix2,
2165
+ warnIgnored: false
2164
2166
  });
2165
- const ignorePatterns = [
2166
- ...eslintConfig.find((cfg) => cfg.ignores)?.ignores ?? [],
2167
- ...ignoreFolders
2168
- ];
2169
- const lintResults = await engine.lintFiles(getFiles(cwd4(), ignorePatterns));
2167
+ const files = getFiles(cwd4(), ignoreFolders);
2168
+ const lintResults = await engine.lintFiles(files);
2170
2169
  dumpMessages2(lintResults);
2171
2170
  return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
2172
2171
  }, "packageLint");