From 8d29726acb4596b5abcfae1ddb48cdf2d1bcbe86 Mon Sep 17 00:00:00 2001 From: Victorien Elvinger Date: Fri, 23 Aug 2024 17:52:17 +0200 Subject: [PATCH] refactor: allow filtering nursery in --only and --skip (#3704) --- CHANGELOG.md | 15 +++++++-- crates/biome_cli/tests/commands/lint.rs | 31 ------------------- .../lint_only_nursery_group.snap | 24 -------------- .../biome_configuration/src/analyzer/mod.rs | 8 +---- 4 files changed, 14 insertions(+), 64 deletions(-) delete mode 100644 crates/biome_cli/tests/snapshots/main_commands_lint/lint_only_nursery_group.snap diff --git a/CHANGELOG.md b/CHANGELOG.md index 2df28fb7240d..a9c807f03776 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,7 +61,8 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b - `biome init` now generates a new config file with more options set. This change intends to improve discoverability of the options and to set the more commonly used options to their default values. Contributed by @Conaclos -- The `--verbose` flag how reports the list of files that were evaluated, and the list of files that were fixed. + +- The `--verbose` flag now reports the list of files that were evaluated, and the list of files that were fixed. The **evaluated** files are the those files that can be handled by Biome, files that are ignored, don't have an extension or have an extension that Biome can't evaluate are excluded by this list. The **fixed** files are those files that were handled by Biome and *changed*. Files that stays the same after the process are excluded from this list. @@ -83,6 +84,16 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b Contributed by @ematipico +- Allow passing `nursery` to the `--only` and `--skip` filters. + + The `--only` option allows you to run a given rule or rule group. + The `--skip` option allows you to skip the execution of a given group or a given rule. + + Previously, it was not possible to pass `nursery`. + This restriction is now removed, as it may make sense to skip the nursery rules that a project has enabled. + + Contributed by @Conaclos + #### Bug fixes - `biome lint --write` now takes `--only` and `--skip` into account ([#3470](https://github.com/biomejs/biome/issues/3470)). Contributed by @Conaclos @@ -757,7 +768,7 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b biome lint --skip=style --skip=suspicious/noExplicitAny ``` - You can also use `--only` and `--skip` together. `--skip` oevrrides `--only`. + You can also use `--only` and `--skip` together. `--skip` overrides `--only`. The following command executes only the rules from the `style` group, but the `style/useNamingConvention` rule. ```shell diff --git a/crates/biome_cli/tests/commands/lint.rs b/crates/biome_cli/tests/commands/lint.rs index b3a7a4578f86..6612b73314b7 100644 --- a/crates/biome_cli/tests/commands/lint.rs +++ b/crates/biome_cli/tests/commands/lint.rs @@ -3729,37 +3729,6 @@ fn lint_only_group() { )); } -#[test] -fn lint_only_nursery_group() { - let mut fs = MemoryFileSystem::default(); - let mut console = BufferConsole::default(); - let content = ""; - - let file_path = Path::new("check.js"); - fs.insert(file_path.into(), content.as_bytes()); - - let result = run_cli( - DynRef::Borrowed(&mut fs), - &mut console, - Args::from( - [ - ("lint"), - "--only=nursery", - file_path.as_os_str().to_str().unwrap(), - ] - .as_slice(), - ), - ); - - assert_cli_snapshot(SnapshotPayload::new( - module_path!(), - "lint_only_nursery_group", - fs, - console, - result, - )); -} - #[test] fn lint_only_group_with_disabled_rule() { let mut fs = MemoryFileSystem::default(); diff --git a/crates/biome_cli/tests/snapshots/main_commands_lint/lint_only_nursery_group.snap b/crates/biome_cli/tests/snapshots/main_commands_lint/lint_only_nursery_group.snap deleted file mode 100644 index 3c25a1ef419c..000000000000 --- a/crates/biome_cli/tests/snapshots/main_commands_lint/lint_only_nursery_group.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/biome_cli/tests/snap_test.rs -expression: content ---- -## `check.js` - -```js - -``` - -# Termination Message - -```block -flags/invalid ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Failed to parse CLI arguments. - - Caused by: - couldn't parse `nursery`: The `nursery` group cannot be selected. Select a specific nursery rule - instead. - - - -``` diff --git a/crates/biome_configuration/src/analyzer/mod.rs b/crates/biome_configuration/src/analyzer/mod.rs index 23bba790f586..f1da7dd8a932 100644 --- a/crates/biome_configuration/src/analyzer/mod.rs +++ b/crates/biome_configuration/src/analyzer/mod.rs @@ -316,13 +316,7 @@ impl FromStr for RuleSelector { } } else { match linter::RuleGroup::from_str(selector) { - Ok(group) => { - if matches!(group, linter::RuleGroup::Nursery) { - Err("The `nursery` group cannot be selected. Select a specific nursery rule instead.") - } else { - Ok(RuleSelector::Group(group)) - } - } + Ok(group) => Ok(RuleSelector::Group(group)), Err(_) => Err( "This group doesn't exist. Use the syntax `/` to specify a rule.", ),