From 5b7067966cd5285b9425634ca673f0adc65a3b54 Mon Sep 17 00:00:00 2001 From: Paul Schultz Date: Fri, 31 Jan 2025 10:35:43 -0600 Subject: [PATCH] feat: set lint --max-warnings to -1 Signed-off-by: Paul Schultz --- .changeset/tall-meals-prove.md | 7 +++++++ docs/tooling/cli/03-commands.md | 2 +- packages/cli/config/eslint-factory.js | 4 ++-- packages/cli/src/commands/index.ts | 2 +- packages/cli/src/commands/lint.ts | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .changeset/tall-meals-prove.md diff --git a/.changeset/tall-meals-prove.md b/.changeset/tall-meals-prove.md new file mode 100644 index 0000000000..44889aaefd --- /dev/null +++ b/.changeset/tall-meals-prove.md @@ -0,0 +1,7 @@ +--- +'@backstage/cli': minor +--- + +**BREAKING**: ESLint warnings no longer trigger system exit codes like errors do. + +Set the max number of warnings to `-1` during linting to enable the gradual adoption of new ESLint rules. To restore the previous behavior, include the `--max-warnings 0` flag in the `backstage-cli lint` command. diff --git a/docs/tooling/cli/03-commands.md b/docs/tooling/cli/03-commands.md index 9d8dd1543e..ed94bb5efb 100644 --- a/docs/tooling/cli/03-commands.md +++ b/docs/tooling/cli/03-commands.md @@ -189,7 +189,7 @@ Lint a package Options: --format Lint report output format (default: "eslint-formatter-friendly") --fix Attempt to automatically fix violations - --max-warnings Fail if more than this number of warnings. -1 allows warnings. (default: 0) + --max-warnings Fail if more than this number of warnings. -1 allows warnings. (default: -1) ``` ## package test diff --git a/packages/cli/config/eslint-factory.js b/packages/cli/config/eslint-factory.js index 3ae455c4b8..8f50e184ff 100644 --- a/packages/cli/config/eslint-factory.js +++ b/packages/cli/config/eslint-factory.js @@ -95,7 +95,7 @@ function createConfig(dir, extraConfig = {}) { '@typescript-eslint/no-unused-expressions': 'error', '@typescript-eslint/consistent-type-assertions': 'error', '@typescript-eslint/no-unused-vars': [ - 'warn', + 'error', { vars: 'all', args: 'after-used', @@ -173,7 +173,7 @@ function createConfig(dir, extraConfig = {}) { 'no-unused-vars': 'off', 'unused-imports/no-unused-imports': 'error', 'unused-imports/no-unused-vars': [ - 'warn', + 'error', { vars: 'all', varsIgnorePattern: '^_', diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index a48c052f20..ee73c071f8 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -129,7 +129,7 @@ export function registerScriptCommand(program: 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('./lint'), 'default')); diff --git a/packages/cli/src/commands/lint.ts b/packages/cli/src/commands/lint.ts index 8c8877c19c..cd5c265e72 100644 --- a/packages/cli/src/commands/lint.ts +++ b/packages/cli/src/commands/lint.ts @@ -30,7 +30,7 @@ export default async (directories: string[], opts: OptionValues) => { directories.length ? directories : ['.'], ); - const maxWarnings = opts.maxWarnings ?? 0; + const maxWarnings = opts.maxWarnings ?? -1; const ignoreWarnings = +maxWarnings === -1; const failed =