Skip to content

noEmptyBlock

¥Summary

  • 规则生效日期:v1.8.0

    ¥Rule available since: v1.8.0

  • 诊断类别:lint/suspicious/noEmptyBlock

    ¥Diagnostic Category: lint/suspicious/noEmptyBlock

  • 此规则为推荐规则,默认启用。

    ¥This rule is recommended, which means is enabled by default.

  • 此规则没有修复方案。

    ¥This rule doesn’t have a fix.

  • 此规则的默认严重级别为 warning

    ¥The default severity of this rule is warning.

  • 来源:

    ¥Sources:

¥How to configure

biome.json
{
"linter": {
"rules": {
"suspicious": {
"noEmptyBlock": "error"
}
}
}
}

¥Description

禁止 CSS 空块。

¥Disallow CSS empty blocks.

默认情况下,它将允许带有注释的空块。

¥By default, it will allow empty blocks with comments inside.

¥Examples

¥Invalid

p {}
code-block.css:1:3 lint/suspicious/noEmptyBlock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

An empty block isn’t allowed.

> 1 │ p {}
^^
2 │

Consider removing the empty block or adding styles inside it.

.b {}
code-block.css:1:4 lint/suspicious/noEmptyBlock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

An empty block isn’t allowed.

> 1 │ .b {}
^^
2 │

Consider removing the empty block or adding styles inside it.

@media print { a {} }
code-block.css:1:18 lint/suspicious/noEmptyBlock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

An empty block isn’t allowed.

> 1 │ @media print { a {} }
^^
2 │

Consider removing the empty block or adding styles inside it.

¥Valid

p {
color: red;
}
p { /* foo */ }
@media print { a { color: pink; } }

¥Related links