From 103278ecb9b08e65658a83faa3e82998b7750ba3 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 13 Feb 2022 21:27:28 +0100 Subject: [PATCH] cli: add --since flag for repo lint command Signed-off-by: Patrik Oldsberg --- packages/cli/src/commands/index.ts | 4 ++++ packages/cli/src/commands/repo/lint.ts | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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') {