Open janosh opened 2 years ago
What if the language-tools warned of duplicate CSS properties?
@cooolbros There's already css.lint.duplicateProperties
(VS Code docs) which helps with that but would be nice to also sort alphabetically for faster screening of blocks.
Afaict, neither extension supports sorting on save.
I don't think it can be reliably achieved because the CSS property order matters in how they're applied.
For example:
if we sort this by property name
h1 {
background-color: green;
background: red;
}
it would become:
h1 {
background: red;
background-color: green;
}
That will change which CSS got applied. The other alternative is that VSCode can provide a quick fix to remove duplicated properties.
That's a good point - we should instead point out duplicate properties (or rather, the VSCode CSS language service ideally would do that)
Description
I occasionally write repeated CSS rules by accident
In this block
border-radius
appears twice but isn't easy to spot. Rules are faster to search by eye when sorted alphabetically.Proposed solution
Sort CSS rules within each block.
Alternatives
Just a suggestion, feel free to close as not planned.
Additional Information, eg. Screenshots
There appear to be unmaintained VS Code extensions that do this: