diff --git a/.changeset/every-ties-wink.md b/.changeset/every-ties-wink.md new file mode 100644 index 0000000000..31eff3fb9a --- /dev/null +++ b/.changeset/every-ties-wink.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Fixed an issue causing the `repo lint` command to fail when the `--max-warnings` option was used. diff --git a/packages/cli/cli-report.md b/packages/cli/cli-report.md index 3c2e01a08e..94add97f9c 100644 --- a/packages/cli/cli-report.md +++ b/packages/cli/cli-report.md @@ -452,6 +452,7 @@ Options: --since --successCache --successCacheDir + --max-warnings --fix -h, --help ``` diff --git a/packages/cli/src/modules/lint/alpha.ts b/packages/cli/src/modules/lint/alpha.ts index 8703e73b5e..617f71d5c9 100644 --- a/packages/cli/src/modules/lint/alpha.ts +++ b/packages/cli/src/modules/lint/alpha.ts @@ -38,7 +38,7 @@ export default createCliPlugin({ ); command.option( '--max-warnings ', - 'Fail if more than this number of warnings. -1 allows warnings. (default: 0)', + 'Fail if more than this number of warnings. -1 allows warnings. (default: -1)', ); command.description('Lint a package'); command.action( @@ -76,6 +76,10 @@ export default createCliPlugin({ '--since ', 'Only lint packages that changed since the specified ref', ); + command.option( + '--max-warnings ', + 'Fail if more than this number of warnings. -1 allows warnings. (default: -1)', + ); command.description('Lint a repository'); command.action(lazy(() => import('./commands/repo/lint'), 'command')); diff --git a/packages/cli/src/modules/lint/commands/repo/lint.ts b/packages/cli/src/modules/lint/commands/repo/lint.ts index 15a3584020..ab6597c70a 100644 --- a/packages/cli/src/modules/lint/commands/repo/lint.ts +++ b/packages/cli/src/modules/lint/commands/repo/lint.ts @@ -111,6 +111,7 @@ export async function command(opts: OptionValues, cmd: Command): Promise { fix: Boolean(opts.fix), format: opts.format as string | undefined, shouldCache: Boolean(cacheContext), + maxWarnings: opts.maxWarnings ?? -1, successCache: cacheContext?.entries, rootDir: paths.targetRoot, }, @@ -120,6 +121,7 @@ export async function command(opts: OptionValues, cmd: Command): Promise { shouldCache, successCache, rootDir, + maxWarnings, }) => { const { ESLint } = require('eslint') as typeof import('eslint'); const crypto = require('crypto') as typeof import('crypto'); @@ -131,7 +133,6 @@ export async function command(opts: OptionValues, cmd: Command): Promise { return async ({ fullDir, relativeDir, - lintOptions, parentHash, }): Promise<{ relativeDir: string; @@ -199,7 +200,6 @@ export async function command(opts: OptionValues, cmd: Command): Promise { await ESLint.outputFixes(results); } - const maxWarnings = lintOptions?.maxWarnings ?? 0; const ignoreWarnings = +maxWarnings === -1; const resultText = formatter.format(results) as string; diff --git a/packages/cli/src/modules/lint/index.ts b/packages/cli/src/modules/lint/index.ts index e2bfcd0779..dfa0916efb 100644 --- a/packages/cli/src/modules/lint/index.ts +++ b/packages/cli/src/modules/lint/index.ts @@ -31,7 +31,7 @@ export function registerPackageCommands(command: Command) { .option('--fix', 'Attempt to automatically fix violations') .option( '--max-warnings ', - 'Fail if more than this number of warnings. -1 allows warnings. (default: 0)', + 'Fail if more than this number of warnings. -1 allows warnings. (default: -1)', ) .description('Lint a package') .action(lazy(() => import('./commands/package/lint'), 'default')); @@ -62,6 +62,10 @@ export function registerRepoCommands(command: Command) { '--successCacheDir ', 'Set the success cache location, (default: node_modules/.cache/backstage-cli)', ) + .option( + '--max-warnings ', + 'Fail if more than this number of warnings. -1 allows warnings. (default: -1)', + ) .option('--fix', 'Attempt to automatically fix violations') .action(lazy(() => import('./commands/repo/lint'), 'command')); }