Skip to content

noDuplicateCustomProperties

¥Summary

¥How to configure

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

¥Description

禁止在声明块中重复自定义属性。

¥Disallow duplicate custom properties within declaration blocks.

此规则检查声明块中是否存在重复的自定义属性。

¥This rule checks the declaration blocks for duplicate custom properties.

¥Examples

¥Invalid

a { --custom-property: pink; --custom-property: orange; }
code-block.css:1:30 lint/suspicious/noDuplicateCustomProperties ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Duplicate custom properties can lead to unexpected behavior and may override previous declarations unintentionally.

> 1 │ a { —custom-property: pink; —custom-property: orange; }
^^^^^^^^^^^^^^^^^
2 │

—custom-property is already defined here.

> 1 │ a { —custom-property: pink; —custom-property: orange; }
^^^^^^^^^^^^^^^^^
2 │

Remove or rename the duplicate custom property to ensure consistent styling.

a { --custom-property: pink; background: orange; --custom-property: orange }
code-block.css:1:50 lint/suspicious/noDuplicateCustomProperties ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Duplicate custom properties can lead to unexpected behavior and may override previous declarations unintentionally.

> 1 │ a { —custom-property: pink; background: orange; —custom-property: orange }
^^^^^^^^^^^^^^^^^
2 │

—custom-property is already defined here.

> 1 │ a { —custom-property: pink; background: orange; —custom-property: orange }
^^^^^^^^^^^^^^^^^
2 │

Remove or rename the duplicate custom property to ensure consistent styling.

¥Valid

a { --custom-property: pink; }
a { --custom-property: pink; --cUstOm-prOpErtY: orange; }

¥Related links