@xylabs/ts-scripts-yarn3 7.3.2 → 7.4.0

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.
Files changed (41) hide show
  1. package/dist/actions/cycle.mjs +1 -1
  2. package/dist/actions/cycle.mjs.map +1 -1
  3. package/dist/actions/deplint/checkPackage/checkPackage.mjs +278 -35
  4. package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
  5. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +13 -6
  6. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -1
  7. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +3 -1
  8. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -1
  9. package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +175 -0
  10. package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -0
  11. package/dist/actions/deplint/checkPackage/index.mjs +278 -35
  12. package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
  13. package/dist/actions/deplint/deplint.mjs +281 -38
  14. package/dist/actions/deplint/deplint.mjs.map +1 -1
  15. package/dist/actions/deplint/findFiles.mjs +8 -2
  16. package/dist/actions/deplint/findFiles.mjs.map +1 -1
  17. package/dist/actions/deplint/getExtendsFromTsconfigs.mjs +44 -0
  18. package/dist/actions/deplint/getExtendsFromTsconfigs.mjs.map +1 -0
  19. package/dist/actions/deplint/getExternalImportsFromFiles.mjs +15 -1
  20. package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -1
  21. package/dist/actions/deplint/getRequiredPeerDependencies.mjs +36 -0
  22. package/dist/actions/deplint/getRequiredPeerDependencies.mjs.map +1 -0
  23. package/dist/actions/deplint/getScriptReferencedPackages.mjs +81 -0
  24. package/dist/actions/deplint/getScriptReferencedPackages.mjs.map +1 -0
  25. package/dist/actions/deplint/implicitDevDependencies.mjs +25 -0
  26. package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -0
  27. package/dist/actions/deplint/index.mjs +281 -38
  28. package/dist/actions/deplint/index.mjs.map +1 -1
  29. package/dist/actions/index.mjs +385 -142
  30. package/dist/actions/index.mjs.map +1 -1
  31. package/dist/bin/xy.mjs +328 -85
  32. package/dist/bin/xy.mjs.map +1 -1
  33. package/dist/index.mjs +397 -154
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/xy/index.mjs +328 -85
  36. package/dist/xy/index.mjs.map +1 -1
  37. package/dist/xy/xy.mjs +328 -85
  38. package/dist/xy/xy.mjs.map +1 -1
  39. package/dist/xy/xyLintCommands.mjs +301 -58
  40. package/dist/xy/xyLintCommands.mjs.map +1 -1
  41. package/package.json +15 -16
@@ -1,5 +1,5 @@
1
1
  // src/xy/xyLintCommands.ts
2
- import chalk12 from "chalk";
2
+ import chalk13 from "chalk";
3
3
 
4
4
  // src/lib/checkResult.ts
5
5
  import chalk from "chalk";
@@ -202,7 +202,7 @@ var cycleAll = async ({ verbose = false }) => {
202
202
  combinedDependencies: true,
203
203
  outputType: verbose ? "text" : "err"
204
204
  };
205
- const target = "**/src";
205
+ const target = "**/packages/*/src";
206
206
  console.log(`Checking for circular dependencies in ${target}...`);
207
207
  const result = await cruise([target], cruiseOptions);
208
208
  if (result.output) {
@@ -217,7 +217,7 @@ var cycleAll = async ({ verbose = false }) => {
217
217
  };
218
218
 
219
219
  // src/actions/deplint/deplint.ts
220
- import chalk9 from "chalk";
220
+ import chalk10 from "chalk";
221
221
 
222
222
  // src/actions/deplint/findFilesByGlob.ts
223
223
  import { globSync } from "glob";
@@ -226,12 +226,18 @@ function findFilesByGlob(cwd, pattern) {
226
226
  }
227
227
 
228
228
  // src/actions/deplint/findFiles.ts
229
- function findFiles(path3) {
230
- const allSourceInclude = ["./src/**/*.{ts,tsx}"];
229
+ function findFiles(path5) {
230
+ const allSourceInclude = ["./src/**/*.{ts,tsx,mts,cts,js,mjs,cjs}"];
231
231
  const allDistInclude = ["./dist/**/*.d.ts", "./dist/**/*.{mjs,js,cjs}"];
232
- const srcFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(path3, pattern));
233
- const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(path3, pattern));
234
- return { srcFiles, distFiles };
232
+ const allConfigInclude = ["./*.config.{ts,mts,mjs,js}"];
233
+ const srcFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(path5, pattern));
234
+ const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(path5, pattern));
235
+ const configFiles = allConfigInclude.flatMap((pattern) => findFilesByGlob(path5, pattern));
236
+ return {
237
+ srcFiles,
238
+ distFiles,
239
+ configFiles
240
+ };
235
241
  }
236
242
 
237
243
  // src/actions/deplint/getDependenciesFromPackageJson.ts
@@ -251,10 +257,9 @@ function getDependenciesFromPackageJson(packageJsonPath) {
251
257
  };
252
258
  }
253
259
 
254
- // src/actions/deplint/getImportsFromFile.ts
260
+ // src/actions/deplint/getExtendsFromTsconfigs.ts
255
261
  import fs2 from "fs";
256
- import path2 from "path";
257
- import ts from "typescript";
262
+ import { globSync as globSync2 } from "glob";
258
263
 
259
264
  // src/actions/deplint/getBasePackageName.ts
260
265
  function getBasePackageName(importName) {
@@ -266,7 +271,37 @@ function getBasePackageName(importName) {
266
271
  return importNameScrubbed.split("/")[0];
267
272
  }
268
273
 
274
+ // src/actions/deplint/getExtendsFromTsconfigs.ts
275
+ var isExternalReference = (ref) => !ref.startsWith(".") && !ref.startsWith("/");
276
+ function parseExtendsField(value) {
277
+ if (typeof value === "string") return [value];
278
+ if (Array.isArray(value)) return value.filter((v) => typeof v === "string");
279
+ return [];
280
+ }
281
+ function getExtendsFromTsconfigs(location) {
282
+ const tsconfigFiles = globSync2("./tsconfig*.json", { cwd: location, absolute: true });
283
+ const packages = /* @__PURE__ */ new Set();
284
+ for (const file of tsconfigFiles) {
285
+ try {
286
+ const content = fs2.readFileSync(file, "utf8");
287
+ const cleaned = content.replaceAll(/\/\/.*/g, "").replaceAll(/,\s*([}\]])/g, "$1");
288
+ const parsed = JSON.parse(cleaned);
289
+ const refs = parseExtendsField(parsed.extends);
290
+ for (const ref of refs) {
291
+ if (isExternalReference(ref)) {
292
+ packages.add(getBasePackageName(ref));
293
+ }
294
+ }
295
+ } catch {
296
+ }
297
+ }
298
+ return [...packages];
299
+ }
300
+
269
301
  // src/actions/deplint/getImportsFromFile.ts
302
+ import fs3 from "fs";
303
+ import path2 from "path";
304
+ import ts from "typescript";
270
305
  function isTypeOnlyImportClause(clause) {
271
306
  if (clause === void 0) {
272
307
  return false;
@@ -279,7 +314,7 @@ function isTypeOnlyImportClause(clause) {
279
314
  return clause.isTypeOnly;
280
315
  }
281
316
  function getImportsFromFile(filePath, importPaths, typeImportPaths) {
282
- const sourceCode = fs2.readFileSync(filePath, "utf8");
317
+ const sourceCode = fs3.readFileSync(filePath, "utf8");
283
318
  const isMjsFile = filePath.endsWith(".mjs");
284
319
  const sourceFile = ts.createSourceFile(
285
320
  path2.basename(filePath),
@@ -332,24 +367,38 @@ var internalImportPrefixes = [".", "#", "node:"];
332
367
  var removeInternalImports = (imports) => {
333
368
  return imports.filter((imp) => !internalImportPrefixes.some((prefix) => imp.startsWith(prefix)));
334
369
  };
335
- function getExternalImportsFromFiles({ srcFiles, distFiles }) {
370
+ function getExternalImportsFromFiles({
371
+ srcFiles,
372
+ distFiles,
373
+ configFiles = [],
374
+ tsconfigExtends = []
375
+ }) {
336
376
  const srcImportPaths = {};
337
377
  const distImportPaths = {};
338
378
  const distTypeImportPaths = {};
339
- for (const path3 of srcFiles) getImportsFromFile(path3, srcImportPaths, srcImportPaths).flat();
379
+ const configImportPaths = {};
380
+ for (const path5 of srcFiles) getImportsFromFile(path5, srcImportPaths, srcImportPaths).flat();
381
+ for (const path5 of configFiles) getImportsFromFile(path5, configImportPaths, configImportPaths).flat();
340
382
  const distTypeFiles = distFiles.filter((file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts"));
341
383
  const distCodeFiles = distFiles.filter((file) => !(file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts")));
342
- for (const path3 of distCodeFiles) getImportsFromFile(path3, distImportPaths, distImportPaths).flat();
343
- for (const path3 of distTypeFiles) getImportsFromFile(path3, distTypeImportPaths, distTypeImportPaths).flat();
384
+ for (const path5 of distCodeFiles) getImportsFromFile(path5, distImportPaths, distImportPaths).flat();
385
+ for (const path5 of distTypeFiles) getImportsFromFile(path5, distTypeImportPaths, distTypeImportPaths).flat();
344
386
  const srcImports = Object.keys(srcImportPaths);
345
387
  const distImports = Object.keys(distImportPaths);
346
388
  const distTypeImports = Object.keys(distTypeImportPaths);
347
389
  const externalSrcImports = removeInternalImports(srcImports);
348
390
  const externalDistImports = removeInternalImports(distImports);
349
391
  const externalDistTypeImports = removeInternalImports(distTypeImports);
392
+ const externalConfigImports = removeInternalImports(Object.keys(configImportPaths));
393
+ for (const ext of tsconfigExtends) {
394
+ if (!externalSrcImports.includes(ext)) externalSrcImports.push(ext);
395
+ if (!externalConfigImports.includes(ext)) externalConfigImports.push(ext);
396
+ }
350
397
  return {
398
+ configImportPaths,
351
399
  srcImports,
352
400
  srcImportPaths,
401
+ externalConfigImports,
353
402
  externalSrcImports,
354
403
  distImports,
355
404
  distImportPaths,
@@ -361,6 +410,15 @@ function getExternalImportsFromFiles({ srcFiles, distFiles }) {
361
410
  // src/actions/deplint/checkPackage/getUnlistedDependencies.ts
362
411
  import { builtinModules } from "module";
363
412
  import chalk5 from "chalk";
413
+ function isListedOrBuiltin(imp, name, dependencies, peerDependencies) {
414
+ return dependencies.includes(imp) || imp === name || dependencies.includes(`@types/${imp}`) || peerDependencies.includes(imp) || peerDependencies.includes(`@types/${imp}`) || builtinModules.includes(imp) || builtinModules.includes(`@types/${imp}`);
415
+ }
416
+ function logMissing(name, imp, importPaths) {
417
+ console.log(`[${chalk5.blue(name)}] Missing dependency in package.json: ${chalk5.red(imp)}`);
418
+ if (importPaths[imp]) {
419
+ console.log(` ${importPaths[imp].join("\n ")}`);
420
+ }
421
+ }
364
422
  function getUnlistedDependencies({ name, location }, { dependencies, peerDependencies }, {
365
423
  externalDistImports,
366
424
  externalDistTypeImports,
@@ -368,17 +426,15 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
368
426
  }) {
369
427
  let unlistedDependencies = 0;
370
428
  for (const imp of externalDistImports) {
371
- if (!dependencies.includes(imp) && imp !== name && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !builtinModules.includes(imp) && !builtinModules.includes(`@types/${imp}`)) {
429
+ if (!isListedOrBuiltin(imp, name, dependencies, peerDependencies)) {
372
430
  unlistedDependencies++;
373
- console.log(`[${chalk5.blue(name)}] Missing dependency in package.json: ${chalk5.red(imp)}`);
374
- console.log(` ${distImportPaths[imp].join("\n ")}`);
431
+ logMissing(name, imp, distImportPaths);
375
432
  }
376
433
  }
377
434
  for (const imp of externalDistTypeImports) {
378
- if (!dependencies.includes(imp) && imp !== name && dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && peerDependencies.includes(`@types/${imp}`) && !builtinModules.includes(imp) && builtinModules.includes(`@types/${imp}`)) {
435
+ if (!isListedOrBuiltin(imp, name, dependencies, peerDependencies)) {
379
436
  unlistedDependencies++;
380
- console.log(`[${chalk5.blue(name)}] Missing dependency in package.json: ${chalk5.red(imp)}`);
381
- console.log(` ${distImportPaths[imp].join("\n ")}`);
437
+ logMissing(name, imp, distImportPaths);
382
438
  }
383
439
  }
384
440
  if (unlistedDependencies > 0) {
@@ -406,7 +462,9 @@ function getUnlistedDevDependencies({ name, location }, {
406
462
  if (!distImports.includes(imp) && imp !== name && !dependencies.includes(imp) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`) && !builtinModules2.includes(imp)) {
407
463
  unlistedDevDependencies++;
408
464
  console.log(`[${chalk6.blue(name)}] Missing devDependency in package.json: ${chalk6.red(imp)}`);
409
- console.log(` ${srcImportPaths[imp].join("\n ")}`);
465
+ if (srcImportPaths[imp]) {
466
+ console.log(` ${srcImportPaths[imp].join("\n ")}`);
467
+ }
410
468
  }
411
469
  }
412
470
  if (unlistedDevDependencies > 0) {
@@ -443,29 +501,205 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
443
501
  return unusedDependencies;
444
502
  }
445
503
 
446
- // src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
504
+ // src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
447
505
  import chalk8 from "chalk";
506
+
507
+ // src/actions/deplint/getRequiredPeerDependencies.ts
508
+ import fs4 from "fs";
509
+ import path3 from "path";
510
+ function findDepPackageJson(location, dep) {
511
+ let dir = location;
512
+ while (true) {
513
+ const candidate = path3.join(dir, "node_modules", dep, "package.json");
514
+ if (fs4.existsSync(candidate)) return candidate;
515
+ const parent = path3.dirname(dir);
516
+ if (parent === dir) return void 0;
517
+ dir = parent;
518
+ }
519
+ }
520
+ function getRequiredPeerDependencies(location, allDeps) {
521
+ const required = /* @__PURE__ */ new Set();
522
+ for (const dep of allDeps) {
523
+ const depPkgPath = findDepPackageJson(location, dep);
524
+ if (!depPkgPath) continue;
525
+ try {
526
+ const raw = fs4.readFileSync(depPkgPath, "utf8");
527
+ const pkg = JSON.parse(raw);
528
+ if (pkg.peerDependencies) {
529
+ for (const peer of Object.keys(pkg.peerDependencies)) {
530
+ required.add(peer);
531
+ }
532
+ }
533
+ } catch {
534
+ }
535
+ }
536
+ return required;
537
+ }
538
+
539
+ // src/actions/deplint/getScriptReferencedPackages.ts
540
+ import fs5 from "fs";
541
+ import path4 from "path";
542
+ function getBinNames(location, dep) {
543
+ const depPkgPath = findDepPackageJson(location, dep);
544
+ if (!depPkgPath) return [];
545
+ try {
546
+ const raw = fs5.readFileSync(depPkgPath, "utf8");
547
+ const pkg = JSON.parse(raw);
548
+ if (!pkg.bin) return [];
549
+ if (typeof pkg.bin === "string") return [pkg.name?.split("/").pop() ?? dep];
550
+ return Object.keys(pkg.bin);
551
+ } catch {
552
+ return [];
553
+ }
554
+ }
555
+ function tokenizeScript(script) {
556
+ return script.split(/[&|;$()"`\s]+/).map((t) => t.trim()).filter(Boolean);
557
+ }
558
+ function getScriptReferencedPackages(location, allDeps) {
559
+ const pkgPath = path4.join(location, "package.json");
560
+ let scripts = {};
561
+ try {
562
+ const raw = fs5.readFileSync(pkgPath, "utf8");
563
+ const pkg = JSON.parse(raw);
564
+ scripts = pkg.scripts ?? {};
565
+ } catch {
566
+ return /* @__PURE__ */ new Set();
567
+ }
568
+ const scriptText = Object.values(scripts).join(" ");
569
+ const tokens = new Set(tokenizeScript(scriptText));
570
+ const binToPackage = /* @__PURE__ */ new Map();
571
+ for (const dep of allDeps) {
572
+ const bins = getBinNames(location, dep);
573
+ for (const bin of bins) {
574
+ binToPackage.set(bin, dep);
575
+ }
576
+ }
577
+ const referenced = /* @__PURE__ */ new Set();
578
+ for (const token of tokens) {
579
+ const baseName = getBasePackageName(token);
580
+ if (allDeps.includes(baseName)) {
581
+ referenced.add(baseName);
582
+ }
583
+ const pkg = binToPackage.get(token);
584
+ if (pkg) {
585
+ referenced.add(pkg);
586
+ }
587
+ }
588
+ return referenced;
589
+ }
590
+
591
+ // src/actions/deplint/implicitDevDependencies.ts
592
+ var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
593
+ var rules = [
594
+ {
595
+ package: "typescript",
596
+ isNeeded: ({ srcFiles, configFiles }) => hasFileWithExtension([...srcFiles, ...configFiles], [".ts", ".tsx", ".mts", ".cts"])
597
+ },
598
+ {
599
+ package: "eslint-import-resolver-typescript",
600
+ isNeeded: ({ srcFiles, configFiles }) => hasFileWithExtension([...srcFiles, ...configFiles], [".ts", ".tsx", ".mts", ".cts"])
601
+ }
602
+ ];
603
+ function getImplicitDevDependencies(context) {
604
+ const implicit = /* @__PURE__ */ new Set();
605
+ for (const rule of rules) {
606
+ if (rule.isNeeded(context)) {
607
+ implicit.add(rule.package);
608
+ }
609
+ }
610
+ return implicit;
611
+ }
612
+
613
+ // src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
614
+ var allExternalImports = ({
615
+ externalSrcImports,
616
+ externalDistImports,
617
+ externalDistTypeImports,
618
+ externalConfigImports
619
+ }) => {
620
+ const all = /* @__PURE__ */ new Set([
621
+ ...externalSrcImports,
622
+ ...externalDistImports,
623
+ ...externalDistTypeImports,
624
+ ...externalConfigImports
625
+ ]);
626
+ return all;
627
+ };
628
+ function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs) {
629
+ if (implicitDeps.has(dep)) return true;
630
+ if (requiredPeers.has(dep)) return true;
631
+ if (scriptRefs.has(dep)) return true;
632
+ if (dep.startsWith("@types/")) {
633
+ const baseName = dep.replace(/^@types\//, "");
634
+ return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
635
+ }
636
+ return allImports.has(dep);
637
+ }
638
+ function getUnusedDevDependencies({ name, location }, {
639
+ devDependencies,
640
+ dependencies,
641
+ peerDependencies
642
+ }, sourceParams, fileContext) {
643
+ const allImports = allExternalImports(sourceParams);
644
+ const implicitDeps = getImplicitDevDependencies(fileContext);
645
+ const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
646
+ const requiredPeers = getRequiredPeerDependencies(location, allDeps);
647
+ const scriptRefs = getScriptReferencedPackages(location, allDeps);
648
+ let unusedDevDependencies = 0;
649
+ for (const dep of devDependencies) {
650
+ if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
651
+ if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs)) {
652
+ unusedDevDependencies++;
653
+ console.log(`[${chalk8.blue(name)}] Unused devDependency in package.json: ${chalk8.red(dep)}`);
654
+ }
655
+ }
656
+ if (unusedDevDependencies > 0) {
657
+ const packageLocation = `${location}/package.json`;
658
+ console.log(` ${chalk8.yellow(packageLocation)}
659
+ `);
660
+ }
661
+ return unusedDevDependencies;
662
+ }
663
+
664
+ // src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
665
+ import chalk9 from "chalk";
448
666
  function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }) {
449
667
  let unusedDependencies = 0;
450
668
  for (const dep of peerDependencies) {
451
669
  if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
452
670
  unusedDependencies++;
453
671
  if (dependencies.includes(dep)) {
454
- console.log(`[${chalk8.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk8.red(dep)}`);
672
+ console.log(`[${chalk9.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk9.red(dep)}`);
455
673
  } else {
456
- console.log(`[${chalk8.blue(name)}] Unused peerDependency in package.json: ${chalk8.red(dep)}`);
674
+ console.log(`[${chalk9.blue(name)}] Unused peerDependency in package.json: ${chalk9.red(dep)}`);
457
675
  }
458
676
  }
459
677
  }
460
678
  if (unusedDependencies > 0) {
461
679
  const packageLocation = `${location}/package.json`;
462
- console.log(` ${chalk8.yellow(packageLocation)}
680
+ console.log(` ${chalk9.yellow(packageLocation)}
463
681
  `);
464
682
  }
465
683
  return unusedDependencies;
466
684
  }
467
685
 
468
686
  // src/actions/deplint/checkPackage/checkPackage.ts
687
+ function logVerbose(name, location, srcFiles, distFiles, configFiles, tsconfigExtends) {
688
+ console.info(`Checking package: ${name} at ${location}`);
689
+ console.info(`Source files: ${srcFiles.length}, Distribution files: ${distFiles.length}, Config files: ${configFiles.length}`);
690
+ for (const file of srcFiles) {
691
+ console.info(`Source file: ${file}`);
692
+ }
693
+ for (const file of distFiles) {
694
+ console.info(`Distribution file: ${file}`);
695
+ }
696
+ for (const file of configFiles) {
697
+ console.info(`Config file: ${file}`);
698
+ }
699
+ for (const ext of tsconfigExtends) {
700
+ console.info(`Tsconfig extends: ${ext}`);
701
+ }
702
+ }
469
703
  function checkPackage({
470
704
  name,
471
705
  location,
@@ -474,27 +708,36 @@ function checkPackage({
474
708
  peerDeps = false,
475
709
  verbose = false
476
710
  }) {
477
- const { srcFiles, distFiles } = findFiles(location);
711
+ const {
712
+ srcFiles,
713
+ distFiles,
714
+ configFiles
715
+ } = findFiles(location);
716
+ const tsconfigExtends = getExtendsFromTsconfigs(location);
478
717
  if (verbose) {
479
- console.info(`Checking package: ${name} at ${location}`);
480
- console.info(`Source files: ${srcFiles.length}, Distribution files: ${distFiles.length}`);
481
- for (const file of srcFiles) {
482
- console.info(`Source file: ${file}`);
483
- }
484
- for (const file of distFiles) {
485
- console.info(`Distribution file: ${file}`);
486
- }
718
+ logVerbose(name, location, srcFiles, distFiles, configFiles, tsconfigExtends);
487
719
  }
488
720
  const checkDeps = deps || !(deps || devDeps || peerDeps);
489
721
  const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
490
722
  const checkPeerDeps = peerDeps;
491
- const sourceParams = getExternalImportsFromFiles({ srcFiles, distFiles });
723
+ const sourceParams = getExternalImportsFromFiles({
724
+ srcFiles,
725
+ distFiles,
726
+ configFiles,
727
+ tsconfigExtends
728
+ });
492
729
  const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
493
730
  const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
494
731
  const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
495
732
  const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
733
+ const fileContext = {
734
+ configFiles,
735
+ distFiles,
736
+ srcFiles
737
+ };
738
+ const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext) : 0;
496
739
  const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
497
- const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedPeerDependencies;
740
+ const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
498
741
  return totalErrors;
499
742
  }
500
743
 
@@ -532,21 +775,21 @@ var deplint = ({
532
775
  });
533
776
  }
534
777
  if (totalErrors > 0) {
535
- console.warn(`Deplint: Found ${chalk9.red(totalErrors)} dependency problems. ${chalk9.red("\u2716")}`);
778
+ console.warn(`Deplint: Found ${chalk10.red(totalErrors)} dependency problems. ${chalk10.red("\u2716")}`);
536
779
  } else {
537
- console.info(`Deplint: Found no dependency problems. ${chalk9.green("\u2714")}`);
780
+ console.info(`Deplint: Found no dependency problems. ${chalk10.green("\u2714")}`);
538
781
  }
539
782
  return 0;
540
783
  };
541
784
 
542
785
  // src/actions/lint.ts
543
- import chalk10 from "chalk";
786
+ import chalk11 from "chalk";
544
787
  var lintPackage = ({
545
788
  pkg,
546
789
  fix: fix2,
547
790
  verbose
548
791
  }) => {
549
- console.log(chalk10.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
792
+ console.log(chalk11.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
550
793
  const start = Date.now();
551
794
  const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
552
795
  ["yarn", [
@@ -556,7 +799,7 @@ var lintPackage = ({
556
799
  fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
557
800
  ]]
558
801
  ]);
559
- console.log(chalk10.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk10.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk10.gray("seconds")}`));
802
+ console.log(chalk11.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk11.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk11.gray("seconds")}`));
560
803
  return result;
561
804
  };
562
805
  var lint = ({
@@ -576,13 +819,13 @@ var lint = ({
576
819
  });
577
820
  };
578
821
  var lintAllPackages = ({ fix: fix2 = false } = {}) => {
579
- console.log(chalk10.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
822
+ console.log(chalk11.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
580
823
  const start = Date.now();
581
824
  const fixOptions = fix2 ? ["--fix"] : [];
582
825
  const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
583
826
  ["yarn", ["eslint", "--cache", "--cache-location", ".eslintcache", "--cache-strategy", "content", ...fixOptions]]
584
827
  ]);
585
- console.log(chalk10.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk10.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk10.gray("seconds")}`));
828
+ console.log(chalk11.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk11.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk11.gray("seconds")}`));
586
829
  return result;
587
830
  };
588
831
 
@@ -609,13 +852,13 @@ var publintAll = ({ verbose }) => {
609
852
  };
610
853
 
611
854
  // src/actions/relint.ts
612
- import chalk11 from "chalk";
855
+ import chalk12 from "chalk";
613
856
  var relintPackage = ({
614
857
  pkg,
615
858
  fix: fix2,
616
859
  verbose
617
860
  }) => {
618
- console.log(chalk11.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
861
+ console.log(chalk12.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
619
862
  const start = Date.now();
620
863
  const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
621
864
  ["yarn", [
@@ -625,7 +868,7 @@ var relintPackage = ({
625
868
  fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
626
869
  ]]
627
870
  ]);
628
- console.log(chalk11.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk11.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk11.gray("seconds")}`));
871
+ console.log(chalk12.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk12.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk12.gray("seconds")}`));
629
872
  return result;
630
873
  };
631
874
  var relint = ({
@@ -645,13 +888,13 @@ var relint = ({
645
888
  });
646
889
  };
647
890
  var relintAllPackages = ({ fix: fix2 = false } = {}) => {
648
- console.log(chalk11.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
891
+ console.log(chalk12.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
649
892
  const start = Date.now();
650
893
  const fixOptions = fix2 ? ["--fix"] : [];
651
894
  const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
652
895
  ["yarn", ["eslint", ...fixOptions]]
653
896
  ]);
654
- console.log(chalk11.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk11.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk11.gray("seconds")}`));
897
+ console.log(chalk12.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk12.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk12.gray("seconds")}`));
655
898
  return result;
656
899
  };
657
900
 
@@ -677,7 +920,7 @@ var xyLintCommands = (args) => {
677
920
  const start = Date.now();
678
921
  if (argv.verbose) console.log("Cycle");
679
922
  process.exitCode = await cycle({ pkg: argv.package });
680
- console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
923
+ console.log(chalk13.blue(`Finished in ${Date.now() - start}ms`));
681
924
  }
682
925
  ).command(
683
926
  "lint [package]",
@@ -707,7 +950,7 @@ var xyLintCommands = (args) => {
707
950
  cache: argv.cache,
708
951
  verbose: !!argv.verbose
709
952
  });
710
- console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
953
+ console.log(chalk13.blue(`Finished in ${Date.now() - start}ms`));
711
954
  }
712
955
  ).command(
713
956
  "deplint [package]",
@@ -740,7 +983,7 @@ var xyLintCommands = (args) => {
740
983
  peerDeps: !!argv.peerDeps,
741
984
  verbose: !!argv.verbose
742
985
  });
743
- console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
986
+ console.log(chalk13.blue(`Finished in ${Date.now() - start}ms`));
744
987
  }
745
988
  ).command(
746
989
  "fix [package]",
@@ -752,7 +995,7 @@ var xyLintCommands = (args) => {
752
995
  const start = Date.now();
753
996
  if (argv.verbose) console.log("Fix");
754
997
  process.exitCode = fix();
755
- console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
998
+ console.log(chalk13.blue(`Finished in ${Date.now() - start}ms`));
756
999
  }
757
1000
  ).command(
758
1001
  "relint [package]",
@@ -764,7 +1007,7 @@ var xyLintCommands = (args) => {
764
1007
  if (argv.verbose) console.log("Relinting");
765
1008
  const start = Date.now();
766
1009
  process.exitCode = relint();
767
- console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
1010
+ console.log(chalk13.blue(`Finished in ${Date.now() - start}ms`));
768
1011
  }
769
1012
  ).command(
770
1013
  "publint [package]",
@@ -776,7 +1019,7 @@ var xyLintCommands = (args) => {
776
1019
  if (argv.verbose) console.log("Publint");
777
1020
  const start = Date.now();
778
1021
  process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
779
- console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
1022
+ console.log(chalk13.blue(`Finished in ${Date.now() - start}ms`));
780
1023
  }
781
1024
  ).command(
782
1025
  "knip",
@@ -788,7 +1031,7 @@ var xyLintCommands = (args) => {
788
1031
  if (argv.verbose) console.log("Knip");
789
1032
  const start = Date.now();
790
1033
  process.exitCode = knip();
791
- console.log(chalk12.blue(`Knip finished in ${Date.now() - start}ms`));
1034
+ console.log(chalk13.blue(`Knip finished in ${Date.now() - start}ms`));
792
1035
  }
793
1036
  ).command(
794
1037
  "sonar",
@@ -800,7 +1043,7 @@ var xyLintCommands = (args) => {
800
1043
  const start = Date.now();
801
1044
  if (argv.verbose) console.log("Sonar Check");
802
1045
  process.exitCode = sonar();
803
- console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
1046
+ console.log(chalk13.blue(`Finished in ${Date.now() - start}ms`));
804
1047
  }
805
1048
  );
806
1049
  };