From ed0388263174794c9b88d55e68400cbebd4481ea Mon Sep 17 00:00:00 2001 From: Victorien Elvinger Date: Thu, 23 May 2024 16:39:58 +0200 Subject: [PATCH] refactor: `--only=` run all rules of a group --- crates/biome_cli/src/commands/mod.rs | 8 +- crates/biome_cli/src/execute/mod.rs | 7 +- .../main_commands_lint/lint_help.snap | 8 +- .../lint_only_group_with_disabled_rule.snap | 34 + .../biome_configuration/src/linter/rules.rs | 1862 +---------------- crates/biome_service/src/file_handlers/css.rs | 32 +- .../src/file_handlers/javascript.rs | 29 +- .../biome_service/src/file_handlers/json.rs | 38 +- crates/biome_service/src/file_handlers/mod.rs | 44 +- xtask/codegen/src/generate_configuration.rs | 38 +- 10 files changed, 112 insertions(+), 1988 deletions(-) diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 5630d968a5f5..215230e0669c 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -193,11 +193,9 @@ pub enum BiomeCommand { #[bpaf(external, hide_usage)] cli_options: CliOptions, - /// Run only the given rule or rule group. - /// - /// When a rule is passed, its severity level is set to `error' if it is a recommended rule, or `warn' otherwise. - /// - /// When a rule group is passed, the `recommended` flag is enabled, but if the `all` flag is enabled. + /// Run only the given rule or group of rules. + /// If the severity level of a rule is `off`, + /// then the severity level of the rule is set to `error` if it is a recommended rule or `warn` otherwise. /// /// Example: `biome lint --only=correctness/noUnusedVariables --only=suspicious` #[bpaf(long("only"), argument("GROUP|RULE"))] diff --git a/crates/biome_cli/src/execute/mod.rs b/crates/biome_cli/src/execute/mod.rs index 62ab419eb09b..e4d2a34a2590 100644 --- a/crates/biome_cli/src/execute/mod.rs +++ b/crates/biome_cli/src/execute/mod.rs @@ -127,10 +127,9 @@ pub enum TraversalMode { /// 1. The virtual path to the file /// 2. The content of the file stdin: Option, - /// Run only the given rule or rule group. - /// The option overrides the Biome configuration file as follows: - /// - When a rule is passed, its severity level is set to `error' if it is a recommended rule, or `warn' otherwise. - /// - When a rule group is passed, the `recommended` flag is enabled, but if the `all` flag is enabled. + /// Run only the given rule or group of rules. + /// If the severity level of a rule is `off`, + /// then the severity level of the rule is set to `error` if it is a recommended rule or `warn` otherwise. only: Vec, /// Skip the given rule or group of rules by setting the severity level of the rules to `off`. /// This option takes precedence over `--only`. diff --git a/crates/biome_cli/tests/snapshots/main_commands_lint/lint_help.snap b/crates/biome_cli/tests/snapshots/main_commands_lint/lint_help.snap index 9724dba2bd4d..316f2da0c85f 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_lint/lint_help.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_lint/lint_help.snap @@ -72,11 +72,9 @@ Available options: --apply Alias for `--write`, writes safe fixes (deprecated, use `--write`) --apply-unsafe Alias for `--write --unsafe`, writes safe and unsafe fixes (deprecated, use `--write --unsafe`) - --only= Run only the given rule or rule group. - When a rule is passed, its severity level is set to `error' if it is a - recommended rule, or `warn' otherwise. - When a rule group is passed, the `recommended` flag is enabled, but if - the `all` flag is enabled. + --only= Run only the given rule or group of rules. If the severity level of a rule + is `off`, then the severity level of the rule is set to `error` if it is + a recommended rule or `warn` otherwise. Example: `biome lint --only=correctness/noUnusedVariables --only=suspicious` --skip= Skip the given rule or group of rules by setting the severity level of the rules to `off`. This option takes precedence over `--only`. diff --git a/crates/biome_cli/tests/snapshots/main_commands_lint/lint_only_group_with_disabled_rule.snap b/crates/biome_cli/tests/snapshots/main_commands_lint/lint_only_group_with_disabled_rule.snap index 27f006ecb729..5007548c6627 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_lint/lint_only_group_with_disabled_rule.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_lint/lint_only_group_with_disabled_rule.snap @@ -24,10 +24,44 @@ expression: content debugger; } +``` + +# Termination Message + +```block +lint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Some errors were emitted while running checks. + + + ``` # Emitted Messages +```block +check.js:3:9 lint/suspicious/noDebugger FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × This is an unexpected use of the debugger statement. + + 2 │ export function CONSTANT_CASE(){ + > 3 │ debugger; + │ ^^^^^^^^^ + 4 │ } + 5 │ + + i Unsafe fix: Remove debugger statement + + 1 1 │ + 2 2 │ export function CONSTANT_CASE(){ + 3 │ - ········debugger; + 4 3 │ } + 5 4 │ + + +``` + ```block Checked 1 file in