Skip to content

Commit

Permalink
fix(ci): rule check error messages (#3158)
Browse files Browse the repository at this point in the history
This commit also fixes a false negative of the rule `noUnmatchableAnbSelector`.
  • Loading branch information
Sec-ant committed Jun 10, 2024
1 parent 39db99b commit 535acc7
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 159 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ New entries must be placed in a section entitled `Unreleased`.
Read
our [guidelines for writing a good changelog entry](https://github.com/biomejs/biome/blob/main/CONTRIBUTING.md#changelog).

## Unreleased

### Analyzer

### CLI

### Configuration

### Editors

### Formatter

### JavaScript APIs

### Linter

#### Bug fixes

- The [`noUnmatchableAnbSelector`](https://biomejs.dev/linter/rules/no-unmatchable-anb-selector/) rule is now able to catch unmatchable `an+b` selectors like `0n+0` or `-0n+0`. Contributed by @Sec-ant.

### Parser

## v1.8.1 (2024-06-10)

### Analyzer
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_configuration/src/linter/rules.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ fn is_unmatchable(nth: &AnyCssPseudoClassNth) -> bool {
AnyCssPseudoClassNth::CssPseudoClassNthIdentifier(_) => false,
AnyCssPseudoClassNth::CssPseudoClassNth(nth) => {
let coefficient = nth.value();
let constant = nth.offset();
let constant = nth.offset().and_then(|offset| offset.value().ok());

match (coefficient, constant) {
(Some(a), Some(b)) => a.text() == "0" && b.text() == "0",
(Some(a), None) => a.text() == "0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,63 @@ invalid.css:4:13 lint/nursery/noUnmatchableAnbSelector ━━━━━━━━
i For more details, see the official spec for An+B selectors.
```

```
invalid.css:5:13 lint/nursery/noUnmatchableAnbSelector ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! This selector will never match any elements.
3 │ a:nth-child(+0n) {}
4 │ a:nth-child(-0n) {}
> 5 │ a:nth-child(0n+0) {}
│ ^^^^
6 │ a:nth-child(0n-0) {}
7 │ a:nth-child(-0n-0) {}
i Avoid using An+B selectors that always evaluate to 0.
i For more details, see the official spec for An+B selectors.
```

```
invalid.css:6:13 lint/nursery/noUnmatchableAnbSelector ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! This selector will never match any elements.
4 │ a:nth-child(-0n) {}
5 │ a:nth-child(0n+0) {}
> 6 │ a:nth-child(0n-0) {}
│ ^^^^
7 │ a:nth-child(-0n-0) {}
8 │ a:nth-child(0 of a) {}
i Avoid using An+B selectors that always evaluate to 0.
i For more details, see the official spec for An+B selectors.
```

```
invalid.css:7:13 lint/nursery/noUnmatchableAnbSelector ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! This selector will never match any elements.
5 │ a:nth-child(0n+0) {}
6 │ a:nth-child(0n-0) {}
> 7 │ a:nth-child(-0n-0) {}
│ ^^^^^
8 │ a:nth-child(0 of a) {}
9 │ a:nth-child(0), a:nth-child(1) {}
i Avoid using An+B selectors that always evaluate to 0.
i For more details, see the official spec for An+B selectors.
```

```
Expand Down
2 changes: 1 addition & 1 deletion packages/@biomejs/backend-jsonrpc/src/workspace.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/@biomejs/biome/configuration_schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 535acc7

Please sign in to comment.