Back to Biomejs

noDuplicateSelectorsKeyframeBlock

src/content/docs/linter/rules/no-duplicate-selectors-keyframe-block.mdx

latest4.8 KB
Original Source

import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs> <TabItem label="CSS" icon="seti:css"> ## Summary - Rule available since: `v1.8.0` - Diagnostic Category: [`lint/suspicious/noDuplicateSelectorsKeyframeBlock`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule doesn't have a fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`keyframe-block-no-duplicate-selectors`](https://github.com/stylelint/stylelint/blob/main/lib/rules/keyframe-block-no-duplicate-selectors/README.md)

How to configure

json
{
	"linter": {
		"rules": {
			"suspicious": {
				"noDuplicateSelectorsKeyframeBlock": "error"
			}
		}
	}
}

Description

Disallow duplicate selectors within keyframe blocks.

Examples

Invalid

css
@keyframes foo { from {} from {} }
<pre class="language-text"><code class="language-text">code-block.css:1:26 <a href="https://biomejs.dev/linter/rules/no-duplicate-selectors-keyframe-block">lint/suspicious/noDuplicateSelectorsKeyframeBlock</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">The duplicate keyframe selector is overwritten by later one.</span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>@keyframes foo &#123; from &#123;&#125; from &#123;&#125; &#125; <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>2 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Consider using a different percentage value or keyword to avoid duplication</span> </code></pre>
css
@keyframes foo { from {} FROM {} }
<pre class="language-text"><code class="language-text">code-block.css:1:26 <a href="https://biomejs.dev/linter/rules/no-duplicate-selectors-keyframe-block">lint/suspicious/noDuplicateSelectorsKeyframeBlock</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">The duplicate keyframe selector is overwritten by later one.</span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>@keyframes foo &#123; from &#123;&#125; FROM &#123;&#125; &#125; <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>2 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Consider using a different percentage value or keyword to avoid duplication</span> </code></pre>
css
@keyframes foo { 0% {} 0% {} }
<pre class="language-text"><code class="language-text">code-block.css:1:24 <a href="https://biomejs.dev/linter/rules/no-duplicate-selectors-keyframe-block">lint/suspicious/noDuplicateSelectorsKeyframeBlock</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">The duplicate keyframe selector is overwritten by later one.</span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>@keyframes foo &#123; 0% &#123;&#125; 0% &#123;&#125; &#125; <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>2 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Consider using a different percentage value or keyword to avoid duplication</span> </code></pre>

Valid

css
@keyframes foo { 0% {} 100% {} }
css
@keyframes foo { from {} to {} }
</TabItem> </Tabs>