declaration-block-no-duplicate-properties
What it does
Section titled “What it does”Reports a property declared twice in one block, on the earlier declaration (on the later one when only the earlier one is !important). src and custom properties are not reported. With ignore_consecutive_different_values a repeat right after the same property with another value is left alone.
Why it matters
Section titled “Why it matters”The later declaration replaces the earlier one, so the earlier one does nothing. Most often it is a copy and paste mistake or a leftover of an edit, and the author reads the wrong value as the one in force.
To fix, delete the declaration that is not meant to apply. A deliberate fallback for old browsers (display: -webkit-box; display: flex) can stay with ignore_consecutive_different_values.
Example
Section titled “Example”a { color: red; color: blue; --x: 1;...Configuration
Section titled “Configuration”css: lint: rules: declaration-block-no-duplicate-properties: level: warn # off (default), warn, error options: ignore_consecutive_different_values: falseless: lint: rules: declaration-block-no-duplicate-properties: level: warn # off (default), warn, error options: ignore_consecutive_different_values: falsescss: lint: rules: declaration-block-no-duplicate-properties: level: warn # off (default), warn, error options: ignore_consecutive_different_values: false| Option | Type | Default | Description |
|---|---|---|---|
ignore_consecutive_different_values |
bool | false |
Leave a repeat right after the same property with another value alone (display: -webkit-box; display: flex). |
Enabled by the presets: css/stylelint-recommended.
Suppress one line with sudsy-disable-next-line declaration-block-no-duplicate-properties in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| stylelint | declaration-block-no-duplicate-properties |
full |