Back to Biomejs

noShorthandPropertyOverrides

src/content/docs/linter/rules/no-shorthand-property-overrides.mdx

latest2.9 KB
Original Source

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

<Tabs> <TabItem label="CSS" icon="seti:css"> ## Summary - Rule available since: `v1.8.2` - Diagnostic Category: [`lint/suspicious/noShorthandPropertyOverrides`](/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 [`declaration-block-no-shorthand-property-overrides`](https://github.com/stylelint/stylelint/blob/main/lib/rules/declaration-block-no-shorthand-property-overrides/README.md)

How to configure

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

Description

Disallow shorthand properties that override related longhand properties.

For details on shorthand properties, see the MDN web docs.

Examples

Invalid

css
a { padding-left: 10px; padding: 20px; }
<pre class="language-text"><code class="language-text">code-block.css:1:25 <a href="https://biomejs.dev/linter/rules/no-shorthand-property-overrides">lint/suspicious/noShorthandPropertyOverrides</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">Unexpected shorthand property </span><span style="color: Tomato;"><strong>padding</strong></span><span style="color: Tomato;"> after </span><span style="color: Tomato;"><strong>padding-left</strong></span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>a &#123; padding-left: 10px; padding: 20px; &#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><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>2 │ </strong> </code></pre>

Valid

css
a { padding: 10px; padding-left: 20px; }
css
a { transition-property: opacity; } a { transition: opacity 1s linear; }
</TabItem> </Tabs>