@savvy-web/lint-staged 0.8.0 → 1.0.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.
package/index.d.ts CHANGED
@@ -56,10 +56,10 @@ export declare interface BaseHandlerOptions {
56
56
  * 2. Local installation via `pnpm exec biome`
57
57
  * 3. Local installation via `npx biome`
58
58
  *
59
- * Config file discovery order:
60
- * 1. Explicit `config` option if provided
61
- * 2. `lib/configs/biome.jsonc` or `lib/configs/biome.json`
62
- * 3. Standard locations (`biome.jsonc` or `biome.json` at repo root)
59
+ * Config file discovery:
60
+ * - Searches the workspace root for `biome.jsonc` or `biome.json`.
61
+ * - Falls back to CWD when not in a workspace.
62
+ * - No `lib/configs/` convention biome configs live at workspace roots only.
63
63
  *
64
64
  * @throws Error if Biome is not available (globally or locally)
65
65
  *
@@ -90,6 +90,8 @@ export declare class Biome {
90
90
  * @defaultValue `['package.json', 'package-lock.json', '__fixtures__', '__test__/fixtures']`
91
91
  */
92
92
  static readonly defaultExcludes: readonly ["package.json", "package-lock.json", "__fixtures__", "__test__/fixtures"];
93
+ /** Candidate config file names in preference order. */
94
+ private static readonly CONFIG_NAMES;
93
95
  /**
94
96
  * Pre-configured handler with default options.
95
97
  * Auto-discovers biome command and config file location.
@@ -113,15 +115,31 @@ export declare class Biome {
113
115
  */
114
116
  static isAvailable(): boolean;
115
117
  /**
116
- * Find the Biome config file.
118
+ * Find the Biome config file at the workspace root.
117
119
  *
118
- * Searches in order:
119
- * 1. `lib/configs/` directory
120
- * 2. Standard locations (repo root)
120
+ * @remarks
121
+ * Searches the workspace root directory for `biome.jsonc` then `biome.json`.
122
+ * Falls back to CWD when not running inside a workspace. The `lib/configs/`
123
+ * convention is not used — biome configs are expected at workspace roots only.
121
124
  *
122
- * @returns The config file path, or undefined if not found
125
+ * @returns Absolute path to the config file, or undefined if not found
123
126
  */
124
127
  static findConfig(): string | undefined;
128
+ /**
129
+ * Find all Biome config files across workspace roots.
130
+ *
131
+ * @remarks
132
+ * Searches the workspace root and each leaf workspace root for a
133
+ * `biome.jsonc` or `biome.json` config file. At most one config is
134
+ * collected per directory (the first match in preference order).
135
+ * Falls back to CWD when not running inside a workspace.
136
+ *
137
+ * This method is intended for the CLI check command, which validates
138
+ * `$schema` URLs across all workspace biome configs.
139
+ *
140
+ * @returns Array of absolute config file paths (may be empty)
141
+ */
142
+ static findAllConfigs(): string[];
125
143
  /**
126
144
  * Create a handler with custom options.
127
145
  *
@@ -153,7 +171,7 @@ export declare interface BiomeOptions extends BaseHandlerOptions {
153
171
  * Validates the current lint-staged setup and displays detected settings.
154
172
  * With --quiet flag, only outputs warnings (for postinstall usage).
155
173
  */
156
- export declare const checkCommand: Command_2.Command<"check", BiomeSchemaSync | ConfigDiscovery | FileSystem.FileSystem | ManagedSection | ToolDiscovery, JsoncParseError | SectionParseError | PlatformError, {
174
+ export declare const checkCommand: Command_2.Command<"check", ConfigDiscovery | FileSystem.FileSystem | ManagedSection | ToolDiscovery, JsoncParseError | SectionParseError | PlatformError, {
157
175
  readonly quiet: boolean;
158
176
  }>;
159
177
 
@@ -374,84 +392,6 @@ export declare interface CreateConfigOptions {
374
392
  custom?: LintStagedConfig;
375
393
  }
376
394
 
377
- /**
378
- * Result of entry extraction.
379
- */
380
- export declare interface EntryExtractionResult {
381
- /**
382
- * Map of export path to resolved TypeScript file path.
383
- * Keys are export names (e.g., ".", "./utils"), values are file paths.
384
- */
385
- entries: Record<string, string>;
386
- /**
387
- * Export paths that couldn't be resolved to TypeScript files.
388
- */
389
- unresolved: string[];
390
- }
391
-
392
- /**
393
- * Extracts TypeScript entry points from package.json exports field.
394
- *
395
- * @remarks
396
- * Parses the `exports` field of a package.json to find all TypeScript
397
- * source files that are part of the public API. Handles various export
398
- * formats including string, object with conditions, and nested exports.
399
- *
400
- * @example
401
- * ```typescript
402
- * import type { EntryExtractionResult } from '@savvy-web/lint-staged';
403
- * import { EntryExtractor } from '@savvy-web/lint-staged';
404
- *
405
- * const extractor = new EntryExtractor();
406
- * const packageJson = {
407
- * exports: {
408
- * ".": "./src/index.ts",
409
- * "./utils": "./src/utils/index.ts"
410
- * }
411
- * };
412
- * const result: EntryExtractionResult = extractor.extract(packageJson);
413
- * // result.entries = { ".": "./src/index.ts", "./utils": "./src/utils/index.ts" }
414
- * ```
415
- */
416
- export declare class EntryExtractor {
417
- /**
418
- * Extract TypeScript entry points from package.json.
419
- *
420
- * @param packageJson - Parsed package.json object
421
- * @returns Extraction result with entries and unresolved paths
422
- */
423
- extract(packageJson: {
424
- exports?: ExportsField;
425
- main?: string;
426
- module?: string;
427
- }): EntryExtractionResult;
428
- /**
429
- * Recursively extract entries from an exports object.
430
- */
431
- private extractFromObject;
432
- /**
433
- * Find a TypeScript file from condition exports.
434
- * Looks for: source, types, typescript, development, default
435
- */
436
- private findTypeScriptCondition;
437
- /**
438
- * Find source path from conditions, even if not TypeScript.
439
- */
440
- private findSourceCondition;
441
- /**
442
- * Check if a path is a TypeScript file.
443
- */
444
- private isTypeScriptFile;
445
- }
446
-
447
- /**
448
- * Extracts TypeScript entry points from package.json exports.
449
- */
450
- /**
451
- * Shape of package.json exports field.
452
- */
453
- export declare type ExportsField = string | Record<string, unknown> | null;
454
-
455
395
  /**
456
396
  * Utilities for filtering staged file lists.
457
397
  *
@@ -548,6 +488,27 @@ export declare const fmtCommand: Command_2.Command<"fmt", never, never, {
548
488
  }>;
549
489
  }>;
550
490
 
491
+ /**
492
+ * Get absolute paths of all leaf workspace package directories.
493
+ *
494
+ * @returns Array of absolute paths, empty if not in a workspace
495
+ */
496
+ export declare function getWorkspacePackagePaths(): string[];
497
+
498
+ /**
499
+ * Get all leaf workspace packages (excludes root).
500
+ *
501
+ * @returns Array of workspace packages, or null if not in a workspace
502
+ */
503
+ export declare function getWorkspacePackages(): WorkspacePackageInfo[] | null;
504
+
505
+ /**
506
+ * Get the workspace root directory.
507
+ *
508
+ * @returns Absolute path to workspace root, or null if not in a workspace
509
+ */
510
+ export declare function getWorkspaceRoot(): string | null;
511
+
551
512
  /**
552
513
  * Abstract base class for lint-staged handlers.
553
514
  *
@@ -581,152 +542,6 @@ export declare abstract class Handler {
581
542
  static create(_options?: BaseHandlerOptions): LintStagedHandler;
582
543
  }
583
544
 
584
- /**
585
- * Analyzes TypeScript import relationships to discover all files
586
- * reachable from specified entry points.
587
- *
588
- * @remarks
589
- * This class uses the TypeScript compiler API to trace import statements
590
- * and discover all files that are part of the public API. It handles:
591
- *
592
- * - Static imports: `import \{ foo \} from "./module"`
593
- * - Dynamic imports: `import("./module")`
594
- * - Re-exports: `export * from "./module"` and `export \{ foo \} from "./module"`
595
- * - Circular imports (via visited set tracking)
596
- *
597
- * The class automatically filters out:
598
- * - Files in node_modules
599
- * - Declaration files (.d.ts)
600
- * - Test files (*.test.ts, *.spec.ts)
601
- * - Files in __test__ directories
602
- *
603
- * @example
604
- * ```typescript
605
- * import type { ImportGraphOptions } from '@savvy-web/lint-staged';
606
- * import { ImportGraph } from '@savvy-web/lint-staged';
607
- *
608
- * const options: ImportGraphOptions = { rootDir: process.cwd() };
609
- * const graph = new ImportGraph(options);
610
- * const result = graph.traceFromPackageExports('./package.json');
611
- * console.log('Public API files:', result.files);
612
- * ```
613
- */
614
- export declare class ImportGraph {
615
- private readonly options;
616
- private program;
617
- private compilerOptions;
618
- private moduleResolutionCache;
619
- constructor(options: ImportGraphOptions);
620
- /**
621
- * Trace all imports from the given entry points.
622
- *
623
- * @param entryPaths - Paths to entry files (relative to rootDir or absolute)
624
- * @returns Deduplicated list of all reachable TypeScript files
625
- */
626
- traceFromEntries(entryPaths: string[]): ImportGraphResult;
627
- /**
628
- * Trace imports from package.json exports.
629
- *
630
- * @param packageJsonPath - Path to package.json (relative to rootDir or absolute)
631
- * @returns Deduplicated list of all reachable TypeScript files
632
- */
633
- traceFromPackageExports(packageJsonPath: string): ImportGraphResult;
634
- /**
635
- * Initialize the TypeScript program for module resolution.
636
- */
637
- private initializeProgram;
638
- /**
639
- * Find tsconfig.json path.
640
- */
641
- private findTsConfig;
642
- /**
643
- * Resolve entry path to absolute path.
644
- */
645
- private resolveEntryPath;
646
- /**
647
- * Recursively trace imports from a source file.
648
- */
649
- private traceImports;
650
- /**
651
- * Extract all import/export module specifiers from a source file.
652
- */
653
- private extractImports;
654
- /**
655
- * Resolve a module specifier to an absolute file path.
656
- */
657
- private resolveImport;
658
- /**
659
- * Check if a path is an external module (node_modules).
660
- */
661
- private isExternalModule;
662
- /**
663
- * Check if a file should be included in results.
664
- * Filters out test files and non-TypeScript files.
665
- */
666
- private isSourceFile;
667
- /**
668
- * Traces TypeScript imports from entry points.
669
- *
670
- * @param entryPaths - Paths to entry files (relative to rootDir or absolute)
671
- * @param options - Import graph configuration options
672
- * @returns All TypeScript files reachable from the entries
673
- */
674
- static fromEntries(entryPaths: string[], options: ImportGraphOptions): ImportGraphResult;
675
- /**
676
- * Traces TypeScript imports from package.json exports.
677
- *
678
- * @param packageJsonPath - Path to package.json (relative to rootDir or absolute)
679
- * @param options - Import graph configuration options
680
- * @returns All TypeScript files reachable from the package exports
681
- */
682
- static fromPackageExports(packageJsonPath: string, options: ImportGraphOptions): ImportGraphResult;
683
- }
684
-
685
- /**
686
- * Structured error from import graph analysis.
687
- */
688
- export declare interface ImportGraphError {
689
- /** The type of error that occurred. */
690
- type: ImportGraphErrorType;
691
- /** Human-readable error message. */
692
- message: string;
693
- /** The file path related to the error, if applicable. */
694
- path?: string;
695
- }
696
-
697
- /**
698
- * Analyzes TypeScript import relationships to discover all files
699
- * reachable from specified entry points.
700
- */
701
- /**
702
- * Types of errors that can occur during import graph analysis.
703
- */
704
- export declare type ImportGraphErrorType = "tsconfig_not_found" | "tsconfig_read_error" | "tsconfig_parse_error" | "package_json_not_found" | "package_json_parse_error" | "entry_not_found" | "file_read_error";
705
-
706
- /**
707
- * Options for configuring the ImportGraph analyzer.
708
- */
709
- export declare interface ImportGraphOptions {
710
- /** The project root directory. */
711
- rootDir: string;
712
- /** Custom path to the TypeScript configuration file. */
713
- tsconfigPath?: string;
714
- /** Additional patterns to exclude from results. */
715
- excludePatterns?: string[];
716
- }
717
-
718
- /**
719
- * Result of import graph analysis.
720
- */
721
- export declare interface ImportGraphResult {
722
- /** All TypeScript source files reachable from the entry points. */
723
- files: string[];
724
- /** The entry points that were traced. */
725
- entries: string[];
726
- /** Errors encountered during import graph analysis. */
727
- errors: ImportGraphError[];
728
- }
729
-
730
545
  /**
731
546
  * Init command implementation.
732
547
  *
@@ -746,6 +561,20 @@ export declare const initCommand: Command_2.Command<"init", BiomeSchemaSync | Fi
746
561
  readonly preset: "minimal" | "silk" | "standard";
747
562
  }>;
748
563
 
564
+ /**
565
+ * Check if a file path is at a workspace root or leaf workspace root.
566
+ *
567
+ * @remarks
568
+ * Compares the file's parent directory against the workspace root
569
+ * and all leaf workspace roots. Returns true as a permissive
570
+ * fallback when not in a workspace, so single-package repos
571
+ * continue to work.
572
+ *
573
+ * @param filePath - Absolute path to the file
574
+ * @returns true if the file is at a workspace or leaf root
575
+ */
576
+ export declare function isWorkspacePackagePath(filePath: string): boolean;
577
+
749
578
  /**
750
579
  * A lint-staged configuration object.
751
580
  * Maps glob patterns to handlers, commands, or arrays of sequential steps.
@@ -836,9 +665,12 @@ export declare class Markdown {
836
665
  /**
837
666
  * Find the markdownlint config file.
838
667
  *
668
+ * Paths are anchored to the workspace root (via {@link getWorkspaceRoot}),
669
+ * falling back to `process.cwd()` when not inside a workspace.
670
+ *
839
671
  * Searches in order:
840
- * 1. `lib/configs/` directory
841
- * 2. Standard locations (repo root)
672
+ * 1. `{workspaceRoot}/lib/configs/` directory
673
+ * 2. `{workspaceRoot}/` (repo root)
842
674
  *
843
675
  * @returns The config file path, or undefined if not found
844
676
  */
@@ -905,6 +737,19 @@ export declare class PackageJson {
905
737
  * Pre-configured handler with default options.
906
738
  */
907
739
  static readonly handler: LintStagedHandler;
740
+ /**
741
+ * Filter filenames to workspace roots only.
742
+ *
743
+ * @remarks
744
+ * Applies exclude patterns first (for backward compatibility with custom
745
+ * excludes), then filters to workspace root and leaf workspace roots only.
746
+ * Falls back permissively when not in a workspace.
747
+ *
748
+ * @param filenames - Incoming file list from lint-staged
749
+ * @param excludes - Patterns to exclude before workspace filtering
750
+ * @returns Filtered list of files at workspace roots
751
+ */
752
+ private static filterToWorkspaceRoots;
908
753
  /**
909
754
  * Create a handler with custom options.
910
755
  *
@@ -1204,6 +1049,14 @@ export declare type PresetExtendOptions = CreateConfigOptions;
1204
1049
  */
1205
1050
  export declare type PresetType = "minimal" | "standard" | "silk";
1206
1051
 
1052
+ /**
1053
+ * Clear all cached workspace data.
1054
+ *
1055
+ * @remarks
1056
+ * Call this in test teardown to ensure clean state between tests.
1057
+ */
1058
+ export declare function resetWorkspaceCache(): void;
1059
+
1207
1060
  /** Root command for the CLI with all subcommands. */
1208
1061
  export declare const rootCommand: Command_2.Command<"savvy-lint", BiomeSchemaSync | ConfigDiscovery | FileSystem_2 | ManagedSection | ToolDiscovery, Error | JsoncModificationError | JsoncParseError | SectionParseError | SectionWriteError | PlatformError, {
1209
1062
  readonly subcommand: Option< {
@@ -1299,262 +1152,28 @@ export declare interface ToolSearchResult {
1299
1152
  source: "global" | PackageManager | undefined;
1300
1153
  }
1301
1154
 
1302
- /**
1303
- * TSDoc linter using ESLint with bundled configuration.
1304
- *
1305
- * @remarks
1306
- * This class provides programmatic TSDoc linting using ESLint's Node.js API.
1307
- * It bundles the required ESLint configuration internally, so consumers
1308
- * don't need to configure ESLint themselves.
1309
- *
1310
- * The linter checks for TSDoc syntax errors using the `eslint-plugin-tsdoc` plugin.
1311
- *
1312
- * @example
1313
- * ```typescript
1314
- * import type { TsDocLintResult } from '@savvy-web/lint-staged';
1315
- * import { TsDocLinter } from '@savvy-web/lint-staged';
1316
- *
1317
- * const linter = new TsDocLinter();
1318
- * const results: TsDocLintResult[] = await linter.lintFiles(['src/index.ts', 'src/utils.ts']);
1319
- *
1320
- * for (const result of results) {
1321
- * if (result.errorCount > 0) {
1322
- * console.log(`${result.filePath}: ${result.errorCount} errors`);
1323
- * }
1324
- * }
1325
- * ```
1326
- */
1327
- export declare class TsDocLinter {
1328
- private readonly eslint;
1329
- constructor(options?: TsDocLinterOptions);
1330
- /**
1331
- * Lint files for TSDoc issues.
1332
- *
1333
- * @param filePaths - Array of absolute file paths to lint
1334
- * @returns Array of lint results
1335
- */
1336
- lintFiles(filePaths: string[]): Promise<TsDocLintResult[]>;
1337
- /**
1338
- * Lint files and throw if any errors are found.
1339
- *
1340
- * @param filePaths - Array of absolute file paths to lint
1341
- * @throws Error if any TSDoc errors are found
1342
- */
1343
- lintFilesAndThrow(filePaths: string[]): Promise<void>;
1344
- /**
1345
- * Format lint results as a human-readable string.
1346
- *
1347
- * @param results - Array of lint results
1348
- * @returns Formatted string output
1349
- */
1350
- static formatResults(results: TsDocLintResult[]): string;
1351
- /**
1352
- * Check if there are any errors in the results.
1353
- *
1354
- * @param results - Array of lint results
1355
- * @returns True if any errors were found
1356
- */
1357
- static hasErrors(results: TsDocLintResult[]): boolean;
1358
- }
1359
-
1360
- /**
1361
- * Options for TsDocLinter.
1362
- */
1363
- export declare interface TsDocLinterOptions {
1364
- /** Additional patterns to ignore */
1365
- ignorePatterns?: string[];
1366
- }
1367
-
1368
- /**
1369
- * A single lint message.
1370
- */
1371
- export declare interface TsDocLintMessage {
1372
- /** Line number (1-indexed) */
1373
- line: number;
1374
- /** Column number (1-indexed) */
1375
- column: number;
1376
- /** Severity: 1 = warning, 2 = error */
1377
- severity: 1 | 2;
1378
- /** The error/warning message */
1379
- message: string;
1380
- /** The rule that triggered this message */
1381
- ruleId: string | null;
1382
- }
1383
-
1384
- /**
1385
- * TSDoc linter using ESLint with bundled configuration.
1386
- */
1387
- /**
1388
- * Result of linting a file for TSDoc issues.
1389
- */
1390
- export declare interface TsDocLintResult {
1391
- /** Absolute path to the file */
1392
- filePath: string;
1393
- /** Number of errors found */
1394
- errorCount: number;
1395
- /** Number of warnings found */
1396
- warningCount: number;
1397
- /** Individual messages */
1398
- messages: TsDocLintMessage[];
1399
- }
1400
-
1401
- /**
1402
- * Resolves files for TSDoc linting based on workspace configuration.
1403
- *
1404
- * @remarks
1405
- * This class handles both single-package repos and monorepos. It detects
1406
- * workspaces from pnpm-workspace.yaml or package.json and checks for `tsdoc.json`
1407
- * configuration files to determine which packages need TSDoc linting.
1408
- *
1409
- * A workspace is enabled for TSDoc linting if:
1410
- * 1. The workspace has a `tsdoc.json` file in its root, OR
1411
- * 2. The repo has a `tsdoc.json` file at its root
1412
- *
1413
- * For enabled workspaces, the resolver:
1414
- * 1. Extracts entry points from the package.json `exports` field
1415
- * 2. Traces imports from those entries using ImportGraph
1416
- * 3. Returns all public API files for linting
1417
- *
1418
- * @example
1419
- * ```typescript
1420
- * import type { TsDocResolverOptions } from '@savvy-web/lint-staged';
1421
- * import { TsDocResolver } from '@savvy-web/lint-staged';
1422
- *
1423
- * const options: TsDocResolverOptions = { rootDir: process.cwd() };
1424
- * const resolver = new TsDocResolver(options);
1425
- * const result = resolver.resolve();
1426
- *
1427
- * for (const workspace of result.workspaces) {
1428
- * console.log(`${workspace.name}: ${workspace.files.length} files to lint`);
1429
- * }
1430
- * ```
1431
- */
1432
- export declare class TsDocResolver {
1433
- private readonly options;
1434
- constructor(options: TsDocResolverOptions);
1435
- /**
1436
- * Resolve all files that need TSDoc linting.
1437
- *
1438
- * @returns Resolution result with workspaces and their files
1439
- */
1440
- resolve(): TsDocResolverResult;
1441
- /**
1442
- * Resolve files for a single workspace.
1443
- *
1444
- * @param workspacePath - Path to the workspace root
1445
- * @param repoTsdocConfig - Path to repo-level tsdoc.json if present
1446
- * @returns Workspace info if enabled for TSDoc, null otherwise
1447
- */
1448
- private resolveWorkspace;
1449
- /**
1450
- * Filter staged files to only those that need TSDoc linting.
1451
- *
1452
- * @param stagedFiles - Array of staged file paths (absolute)
1453
- * @returns Files that are in workspaces enabled for TSDoc and are public API files
1454
- */
1455
- filterStagedFiles(stagedFiles: string[]): {
1456
- files: string[];
1457
- tsdocConfigPath: string;
1458
- }[];
1459
- /**
1460
- * Check if a specific file needs TSDoc linting.
1461
- *
1462
- * @param filePath - Absolute path to the file
1463
- * @returns True if the file is in a workspace enabled for TSDoc and is a public API file
1464
- */
1465
- needsLinting(filePath: string): boolean;
1466
- /**
1467
- * Get the tsdoc.json config path for a specific file.
1468
- *
1469
- * @param filePath - Absolute path to the file
1470
- * @returns Path to tsdoc.json if the file needs linting, undefined otherwise
1471
- */
1472
- getTsDocConfig(filePath: string): string | undefined;
1473
- /**
1474
- * Find the workspace that contains a file.
1475
- *
1476
- * @param filePath - Absolute path to the file
1477
- * @returns Workspace info if found, undefined otherwise
1478
- */
1479
- findWorkspace(filePath: string): TsDocWorkspace | undefined;
1480
- }
1481
-
1482
- /**
1483
- * Options for TsDocResolver.
1484
- */
1485
- export declare interface TsDocResolverOptions {
1486
- /** The repository root directory */
1487
- rootDir: string;
1488
- /** Custom exclude patterns for import graph analysis */
1489
- excludePatterns?: string[];
1490
- }
1491
-
1492
- /**
1493
- * Result of resolving TSDoc files.
1494
- */
1495
- export declare interface TsDocResolverResult {
1496
- /** Workspaces that are enabled for TSDoc linting */
1497
- workspaces: TsDocWorkspace[];
1498
- /** Whether this is a monorepo */
1499
- isMonorepo: boolean;
1500
- /** Path to repo-level tsdoc.json if present */
1501
- repoTsdocConfig?: string;
1502
- }
1503
-
1504
- /**
1505
- * Resolves files for TSDoc linting based on workspace configuration.
1506
- */
1507
- /**
1508
- * Information about a workspace enabled for TSDoc linting.
1509
- */
1510
- export declare interface TsDocWorkspace {
1511
- /** Workspace name from package.json */
1512
- name: string;
1513
- /** Absolute path to the workspace root */
1514
- path: string;
1515
- /** Path to the tsdoc.json config (workspace-level or repo-level) */
1516
- tsdocConfigPath: string;
1517
- /** Files to lint (absolute paths) */
1518
- files: string[];
1519
- /** Errors encountered during resolution */
1520
- errors: string[];
1521
- }
1522
-
1523
1155
  /**
1524
1156
  * Handler for TypeScript files.
1525
1157
  *
1526
- * Validates TSDoc syntax with ESLint and runs type checking.
1158
+ * Runs type checking with tsgo or tsc.
1527
1159
  *
1528
1160
  * @remarks
1529
- * TSDoc validation uses intelligent file discovery based on workspace
1530
- * configuration:
1531
- *
1532
- * 1. Detects workspaces using the npm/pnpm/yarn workspace protocol
1533
- * 2. A workspace is enabled for TSDoc if it has `tsdoc.json` or the repo root has one
1534
- * 3. For enabled workspaces, extracts entry points from `package.json` exports
1535
- * 4. Traces imports from entries to find all public API files
1536
- * 5. Only lints files that are part of the public API
1537
- *
1538
- * This ensures that:
1539
- * - Only documented public API files are linted
1540
- * - Internal implementation files are skipped
1541
- * - Test files and fixtures are automatically excluded
1542
- *
1543
1161
  * Type checking runs on all staged TypeScript files using the configured
1544
- * compiler (tsgo or tsc).
1162
+ * compiler (tsgo or tsc). The compiler is auto-detected at runtime using
1163
+ * `Command.findTool()`, which correctly handles pnpm catalogs, peer
1164
+ * dependencies, and hoisted/transitive deps.
1545
1165
  *
1546
1166
  * @example
1547
1167
  * ```typescript
1548
1168
  * import { TypeScript } from '\@savvy-web/lint-staged';
1549
1169
  *
1550
1170
  * export default {
1551
- * // Auto-discovers workspaces and lints public API files
1171
+ * // Auto-detects compiler and runs type checking
1552
1172
  * [TypeScript.glob]: TypeScript.handler,
1553
1173
  *
1554
1174
  * // Or explicit config
1555
1175
  * [TypeScript.glob]: TypeScript.create({
1556
1176
  * skipTypecheck: true,
1557
- * skipTsdoc: false,
1558
1177
  * }),
1559
1178
  * };
1560
1179
  * ```
@@ -1570,11 +1189,6 @@ export declare class TypeScript {
1570
1189
  * @defaultValue `[]`
1571
1190
  */
1572
1191
  static readonly defaultExcludes: readonly [];
1573
- /**
1574
- * Default patterns to exclude from TSDoc linting.
1575
- * @defaultValue `['.test.', '.spec.', '__test__', '__tests__']`
1576
- */
1577
- static readonly defaultTsdocExcludes: readonly [".test.", ".spec.", "__test__", "__tests__"];
1578
1192
  /** Cached compiler detection result */
1579
1193
  private static cachedCompilerResult;
1580
1194
  /**
@@ -1617,20 +1231,8 @@ export declare class TypeScript {
1617
1231
  static clearCache(): void;
1618
1232
  /**
1619
1233
  * Pre-configured handler with default options.
1620
- * Auto-discovers workspaces for TSDoc linting.
1621
1234
  */
1622
1235
  static readonly handler: LintStagedHandler;
1623
- /**
1624
- * Check if TSDoc linting is available for the repository.
1625
- *
1626
- * TSDoc linting requires:
1627
- * 1. A `tsdoc.json` file at repo root or workspace level
1628
- * 2. Package(s) with `exports` field in package.json
1629
- *
1630
- * @param cwd - Directory to search from (defaults to process.cwd())
1631
- * @returns `true` if TSDoc linting can be performed
1632
- */
1633
- static isTsdocAvailable(cwd?: string): boolean;
1634
1236
  /**
1635
1237
  * Create a handler with custom options.
1636
1238
  *
@@ -1649,17 +1251,6 @@ export declare type TypeScriptCompiler = "tsgo" | "tsc";
1649
1251
  * Options for the TypeScript handler.
1650
1252
  */
1651
1253
  export declare interface TypeScriptOptions extends BaseHandlerOptions {
1652
- /**
1653
- * Additional patterns to exclude from TSDoc linting.
1654
- * These are in addition to the default test file exclusions.
1655
- * @defaultValue ['.test.', '.spec.', '__test__', '__tests__']
1656
- */
1657
- excludeTsdoc?: string[];
1658
- /**
1659
- * Skip TSDoc validation.
1660
- * @defaultValue false
1661
- */
1662
- skipTsdoc?: boolean;
1663
1254
  /**
1664
1255
  * Skip type checking.
1665
1256
  * @defaultValue false
@@ -1667,15 +1258,30 @@ export declare interface TypeScriptOptions extends BaseHandlerOptions {
1667
1258
  skipTypecheck?: boolean;
1668
1259
  /**
1669
1260
  * Command for type checking.
1670
- * @defaultValue Auto-detected based on package manager and compiler
1261
+ * @defaultValue Auto-detected
1671
1262
  */
1672
1263
  typecheckCommand?: string;
1673
- /**
1674
- * Root directory for workspace detection.
1675
- * Used to find workspaces and tsdoc.json configuration.
1676
- * @defaultValue process.cwd()
1677
- */
1678
- rootDir?: string;
1264
+ }
1265
+
1266
+ /**
1267
+ * Workspace-aware discovery utilities.
1268
+ *
1269
+ * @remarks
1270
+ * Wraps the synchronous APIs from `workspaces-effect` with caching.
1271
+ * Workspace layout does not change during a lint-staged run, so
1272
+ * results are cached on first access. Use `resetWorkspaceCache()`
1273
+ * in tests to clear state between runs.
1274
+ */
1275
+ /**
1276
+ * Minimal shape of a workspace package needed by this module.
1277
+ *
1278
+ * @remarks
1279
+ * Avoids importing the full WorkspacePackage Schema.Class from
1280
+ * workspaces-effect, keeping the sync boundary clean.
1281
+ */
1282
+ export declare interface WorkspacePackageInfo {
1283
+ readonly name: string;
1284
+ readonly path: string;
1679
1285
  }
1680
1286
 
1681
1287
  /**
@@ -1719,9 +1325,12 @@ export declare class Yaml {
1719
1325
  /**
1720
1326
  * Find the yaml-lint config file.
1721
1327
  *
1328
+ * Paths are anchored to the workspace root (via {@link getWorkspaceRoot}),
1329
+ * falling back to `process.cwd()` when not inside a workspace.
1330
+ *
1722
1331
  * Searches in order:
1723
- * 1. `lib/configs/` directory
1724
- * 2. Standard locations (repo root)
1332
+ * 1. `{workspaceRoot}/lib/configs/.yaml-lint.json`
1333
+ * 2. `{workspaceRoot}/.yaml-lint.json`
1725
1334
  *
1726
1335
  * @returns The config file path, or undefined if not found
1727
1336
  */