Skip to content

Commit

Permalink
refactor: allow filtering nursery in --only and --skip (#3704)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos authored Aug 23, 2024
1 parent 4240dc7 commit 8d29726
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 64 deletions.
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
31 changes: 0 additions & 31 deletions crates/biome_cli/tests/commands/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

This file was deleted.

8 changes: 1 addition & 7 deletions crates/biome_configuration/src/analyzer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<group>/<rule>` to specify a rule.",
),
Expand Down

0 comments on commit 8d29726

Please sign in to comment.