Skip to main content

declaration-block-no-shorthand-property-overrides

Disallow shorthand properties that override related longhand properties.

a { background-repeat: repeat; background: green; }
/** ↑
* This overrides the longhand property before it */

Use this rule to avoid longhands that a later shorthand silently undoes. Browsers reset every longhand a shorthand covers.

This rule reports physical shorthands, like padding, that override flow-relative properties, such as padding-inline.

This rule supports 2 message arguments: the shorthand property and the overridden longhand declaration.

Options​

true​

{
"declaration-block-no-shorthand-property-overrides": true
}

The following patterns are considered problems:

a {
padding-left: 10px;
padding: 20px;
}
a {
padding-inline: 10px;
padding: 20px;
}
a {
transition-property: opacity;
transition: opacity 1s linear;
}
a {
-webkit-transition-property: opacity;
-webkit-transition: opacity 1s linear;
}
a {
border-top-width: 1px;
top: 0;
bottom: 3px;
border: 2px solid blue;
}

The following patterns are not considered problems:

a { padding: 10px; padding-left: 20px; }
a { padding: 10px; padding-inline: 20px; }
a { transition-property: opacity; } a { transition: opacity 1s linear; }
a { transition-property: opacity; -webkit-transition: opacity 1s linear; }