cli: add --since flag for repo lint command

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-02-13 21:27:28 +01:00
parent aa892fccc5
commit 103278ecb9
2 changed files with 10 additions and 1 deletions
+4
View File
@@ -51,6 +51,10 @@ export function registerRepoCommand(program: CommanderStatic) {
'Lint report output format',
'eslint-formatter-friendly',
)
.option(
'--since <ref>',
'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)));
}
+6 -1
View File
@@ -22,7 +22,12 @@ import { runWorkerQueueThreads } from '../../lib/parallel';
import { paths } from '../../lib/paths';
export async function command(cmd: Command): Promise<void> {
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') {