@xylabs/ts-scripts-yarn3 5.1.0 → 5.1.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.d.ts CHANGED
@@ -103,6 +103,7 @@ declare const gitlintFix: () => number;
103
103
  declare const license: (pkg?: string) => Promise<number>;
104
104
 
105
105
  interface LintParams {
106
+ fix?: boolean;
106
107
  incremental?: boolean;
107
108
  pkg?: string;
108
109
  verbose?: boolean;
@@ -111,10 +112,10 @@ interface LintPackageParams {
111
112
  pkg: string;
112
113
  verbose?: boolean;
113
114
  }
114
- declare const lintPackage: ({ pkg }: LintParams) => Promise<number>;
115
- declare const lintAll: () => Promise<number>;
116
- declare const lint: ({ pkg, verbose, incremental, }?: LintParams) => Promise<number>;
117
- declare const lintAllPackages: ({ verbose, incremental }?: LintParams) => number;
115
+ declare const lintPackage: ({ pkg, fix }: LintParams) => Promise<number>;
116
+ declare const lintAll: ({ fix }: LintParams) => Promise<void>;
117
+ declare const lint: ({ pkg, verbose, incremental, fix, }?: LintParams) => Promise<number>;
118
+ declare const lintAllPackages: ({ fix, verbose, incremental, }?: LintParams) => number;
118
119
 
119
120
  declare const lintClean: () => Promise<number>;
120
121
 
package/dist/index.mjs CHANGED
@@ -1242,36 +1242,40 @@ var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
1242
1242
  }
1243
1243
  }
1244
1244
  }, "dumpMessages");
1245
- var lintPackage = /* @__PURE__ */ __name(async ({ pkg }) => {
1245
+ var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix: fix2 }) => {
1246
1246
  const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
1247
1247
  if (!workspace) {
1248
1248
  console.error(chalk18.red(`Unable to locate package [${chalk18.magenta(pkg)}]`));
1249
1249
  process.exit(1);
1250
1250
  }
1251
1251
  const engine = new ESLint2({
1252
- cache: true
1252
+ cache: true,
1253
+ fix: fix2
1253
1254
  });
1254
1255
  const lintResults = await engine.lintFiles(workspace.location);
1255
1256
  dumpMessages(lintResults);
1256
1257
  return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
1257
1258
  }, "lintPackage");
1258
- var lintAll = /* @__PURE__ */ __name(async () => {
1259
- const engine = new ESLint2({
1260
- cache: true
1261
- });
1262
- const lintResults = await engine.lintFiles("./**/*.*");
1263
- dumpMessages(lintResults);
1264
- return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
1259
+ var lintAll = /* @__PURE__ */ __name(async ({ fix: fix2 }) => {
1260
+ const workspace = yarnWorkspaces();
1261
+ for (const ws of workspace) {
1262
+ await lintPackage({
1263
+ pkg: ws.name,
1264
+ fix: fix2
1265
+ });
1266
+ }
1265
1267
  }, "lintAll");
1266
- var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental } = {}) => {
1268
+ var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
1267
1269
  return pkg ? await lintPackage({
1268
- pkg
1270
+ pkg,
1271
+ fix: fix2
1269
1272
  }) : lintAllPackages({
1270
1273
  verbose,
1271
- incremental
1274
+ incremental,
1275
+ fix: fix2
1272
1276
  });
1273
1277
  }, "lint");
1274
- var lintAllPackages = /* @__PURE__ */ __name(({ verbose = true, incremental } = {}) => {
1278
+ var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incremental } = {}) => {
1275
1279
  console.log(chalk18.gray("Linting [All-Packages]"));
1276
1280
  const start = Date.now();
1277
1281
  const verboseOptions = verbose ? [
@@ -1279,6 +1283,11 @@ var lintAllPackages = /* @__PURE__ */ __name(({ verbose = true, incremental } =
1279
1283
  ] : [
1280
1284
  "--no-verbose"
1281
1285
  ];
1286
+ const fixOptions = fix2 ? [
1287
+ "--fix"
1288
+ ] : [
1289
+ ""
1290
+ ];
1282
1291
  const incrementalOptions = incremental ? [
1283
1292
  "--since",
1284
1293
  "-Apt"
@@ -1295,7 +1304,8 @@ var lintAllPackages = /* @__PURE__ */ __name(({ verbose = true, incremental } =
1295
1304
  ...verboseOptions,
1296
1305
  ...incrementalOptions,
1297
1306
  "run",
1298
- "package-lint"
1307
+ "package-lint",
1308
+ ...fixOptions
1299
1309
  ]
1300
1310
  ]
1301
1311
  ]);
@@ -2149,8 +2159,8 @@ var packageLint = /* @__PURE__ */ __name(async () => {
2149
2159
  withFileTypes: true
2150
2160
  }).flatMap((dirent) => {
2151
2161
  const res = path7.resolve(dir, dirent.name);
2152
- if (ignorePatterns2.some((pattern) => res.includes(pattern))) return [];
2153
- return dirent.isDirectory() ? getFiles(res, ignorePatterns2) : res.endsWith(".ts") || res.endsWith(".tsx") ? [
2162
+ if (ignorePatterns2.some((pattern) => dir.includes(pattern))) return [];
2163
+ return dirent.isDirectory() ? getFiles(res, ignorePatterns2) : res.endsWith(".ts") || res.endsWith(".tsx") || res.endsWith(".js") || res.endsWith(".jsx") ? [
2154
2164
  res
2155
2165
  ] : [];
2156
2166
  });