diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index b3c9bae6a4..6f534d3e62 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -51,6 +51,10 @@ export function registerRepoCommand(program: CommanderStatic) { 'Lint report output format', 'eslint-formatter-friendly', ) + .option( + '--since ', + 'Only lint packages that changed since the specified ref', + ) .option('--fix', 'Attempt to automatically fix violations') .action(lazy(() => import('./repo/lint').then(m => m.command))); } diff --git a/packages/cli/src/commands/repo/lint.ts b/packages/cli/src/commands/repo/lint.ts index 4c1b912d92..08d111712d 100644 --- a/packages/cli/src/commands/repo/lint.ts +++ b/packages/cli/src/commands/repo/lint.ts @@ -22,7 +22,12 @@ import { runWorkerQueueThreads } from '../../lib/parallel'; import { paths } from '../../lib/paths'; export async function command(cmd: Command): Promise { - const packages = await PackageGraph.listTargetPackages(); + let packages = await PackageGraph.listTargetPackages(); + + if (cmd.since) { + const graph = PackageGraph.fromPackages(packages); + packages = await graph.listChangedPackages({ ref: cmd.since }); + } // This formatter uses the cwd to format file paths, so let's have that happen from the root instead if (cmd.format === 'eslint-formatter-friendly') {