/** * Configuration for the PackageTestScripts policy. * * This policy ensures that packages have appropriate test scripts when they * contain test files or have test-related dependencies. * * The policy automatically determines what to check based on what's configured: * - If `testDirectories` is set, checks for test directories * - If `testDependencies` is set, checks for test dependencies * - If both are set, a package triggers validation if either condition is met * * @example * ```typescript * const config: PackageTestScriptsConfig = { * // Check for these test directories * testDirectories: ["test", "tests", "__tests__"], * // Require test script if these devDependencies exist * testDependencies: ["vitest", "jest", "mocha"], * // Required test script names * requiredScripts: ["test"], * }; * ``` * * @alpha */ export interface PackageTestScriptsConfig { /** * Directory names that indicate test files are present. * * If any of these directories exist relative to the package.json, * the policy will require test scripts to be present. * * If not set or empty, directory checking is skipped. * * @example * ```typescript * testDirectories: ["test", "tests", "__tests__"] * ``` */ testDirectories?: string[]; /** * Test framework dependencies that indicate tests are expected. * * If any of these appear in devDependencies, the policy will require * test scripts to be present. * * If not set or empty, dependency checking is skipped. * * @example * ```typescript * testDependencies: ["vitest", "jest", "mocha", "@jest/globals"] * ``` */ testDependencies?: string[]; /** * Script names that must exist when tests are detected. * * @defaultValue ["test"] */ requiredScripts?: string[]; /** * Package names or scopes to exclude from validation. */ excludePackages?: string[]; } /** * A policy that ensures packages have test scripts when test files exist. * * This policy helps maintain testing discipline by requiring test scripts * for packages that have test directories or test framework dependencies. * * @remarks * * The policy detects that tests are expected based on: * * 1. **Test directories**: If `test/`, `tests/`, or `__tests__/` exists * 2. **Test dependencies**: If vitest, jest, mocha, etc. are in devDependencies * * When tests are detected, the policy requires specified test scripts to exist. * * @example * ```typescript * import { makePolicy } from "repopo"; * import { PackageTestScripts } from "repopo/policies"; * * const config: RepopoConfig = { * policies: [ * makePolicy(PackageTestScripts, { * testDirectories: ["test", "tests"], * testDependencies: ["vitest", "jest"], * requiredScripts: ["test"], * }), * ], * }; * ``` * * @alpha */ export declare const PackageTestScripts: import("../policy.js").PolicyShape; //# sourceMappingURL=PackageTestScripts.d.ts.map