Skip to content

Commit

Permalink
chore: snapshot with options
Browse files Browse the repository at this point in the history
  • Loading branch information
togami2864 committed Apr 18, 2024
1 parent 40376f9 commit a7d229e
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 2,429 deletions.
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.

46 changes: 35 additions & 11 deletions crates/biome_css_analyze/src/lint/nursery/no_css_empty_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ use biome_rowan::AstNode;
use serde::{Deserialize, Serialize};

declare_rule! {
/// Succinct description of the rule.
/// Disallow css empty blocks.
///
/// Put context and details about the rule.
/// As a starting point, you can take the description of the corresponding _ESLint_ rule (if any).
///
/// Try to stay consistent with the descriptions of implemented rules.
///
/// Add a link to the corresponding stylelint rule (if any):
/// This rule disallows empty block.
/// By default, it will allow empty blocks with comments inside.
///
/// ## Examples
///
Expand All @@ -23,6 +19,14 @@ declare_rule! {
/// p {}
/// ```
///
/// ```css,expect_diagnostic
/// .b {}
/// ```
///
/// ```css,expect_diagnostic
/// @media print { a {} }
/// ```
///
/// ### Valid
///
/// ```css
Expand All @@ -31,6 +35,30 @@ declare_rule! {
/// }
/// ```
///
/// ```css
/// p {
/// /* foo */
/// }
/// ```
///
/// ```css
/// @media print { a { color: pink; } }
/// ```
///
/// ## Options
///
/// Exclude comments from being treated as content inside of a block.
///
/// ```json
/// {
/// "noCssEmptyBlock": {
/// "options": {
/// "ignore": ["comments"]
/// }
/// }
/// }
/// ```
///
pub NoCssEmptyBlock {
version: "next",
name: "noCssEmptyBlock",
Expand Down Expand Up @@ -76,10 +104,6 @@ impl Rule for NoCssEmptyBlock {
}

fn diagnostic(_: &RuleContext<Self>, node: &Self::State) -> Option<RuleDiagnostic> {
//
// Read our guidelines to write great diagnostics:
// https://docs.rs/biome_analyze/latest/biome_analyze/#what-a-rule-should-say-to-the-user
//
let span = node.range();
Some(
RuleDiagnostic::new(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
a { /* foo */ }
a {
/* foo */
}

.b { /* foo */ }
.b {
/* foo */
}

@media print { /* foo */ }
@media print {
/* foo */
}
@media print {
a {
/* foo */
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
---
source: crates/biome_css_analyze/tests/spec_tests.rs
expression: disallowComment.css
---
# Input
```css
a { /* foo */ }
a {
/* foo */
}
.b { /* foo */ }
.b {
/* foo */
}
@media print { /* foo */ }
@media print {
/* foo */
}
@media print {
a {
/* foo */
}
}
```

# Diagnostics
```
disallowComment.css:1:3 lint/nursery/noCssEmptyBlock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Unexpected empty block is not allowed
> 1 │ a { /* foo */ }
│ ^^^^^^^^^^^^^
2 │ a {
3/* foo */
i Consider removing the empty block or adding styles inside it.
```
```
disallowComment.css:2:3 lint/nursery/noCssEmptyBlock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Unexpected empty block is not allowed
1a { /* foo */ }
> 2a {
│ ^
> 3 │ /* foo */
> 4 │ }
^
5
6 │ .b { /* foo */ }
i Consider removing the empty block or adding styles inside it.
```
```
disallowComment.css:6:4 lint/nursery/noCssEmptyBlock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Unexpected empty block is not allowed
4}
5 │
> 6 │ .b { /* foo */ }
│ ^^^^^^^^^^^^^
7 │ .b {
8/* foo */
i Consider removing the empty block or adding styles inside it.
```
```
disallowComment.css:7:4 lint/nursery/noCssEmptyBlock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Unexpected empty block is not allowed
6 │ .b { /* foo */ }
> 7 │ .b {
│ ^
> 8 │ /* foo */
> 9 │ }
^
10
11 │ @media print { /* foo */ }
i Consider removing the empty block or adding styles inside it.
```
```
disallowComment.css:11:14 lint/nursery/noCssEmptyBlock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Unexpected empty block is not allowed
9}
10 │
> 11 │ @media print { /* foo */ }
│ ^^^^^^^^^^^^^
12 │ @media print {
13/* foo */
i Consider removing the empty block or adding styles inside it.
```
```
disallowComment.css:12:14 lint/nursery/noCssEmptyBlock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Unexpected empty block is not allowed
11 │ @media print { /* foo */ }
> 12 │ @media print {
│ ^
> 13 │ /* foo */
> 14 │ }
^
15 │ @media print {
16 │ a {
i Consider removing the empty block or adding styles inside it.
```
```
disallowComment.css:16:5 lint/nursery/noCssEmptyBlock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Unexpected empty block is not allowed
14 │ }
15 │ @media print {
> 16 │ a {
│ ^
> 17 │ /* foo */
> 18 │ }
^
19}
i Consider removing the empty block or adding styles inside it.
```

This file was deleted.

This file was deleted.

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 a7d229e

Please sign in to comment.