CSSLint / csslint

Automated linting of Cascading Stylesheets
http://csslint.net
Other
4.76k stars 483 forks source link

Detect duplicate selectors #548

Open serdar opened 9 years ago

serdar commented 9 years ago

Hello! I'd like to propose an additional check that detects duplicate CSS selectors and displays a warning regarding code maintainability/redundancy.

For example:

#content {
 border: 1px solid black;
}

#content {
 color: #fff;
}

Will be detected with a suggestion to either merge the two together or remove one of the selectors.

Thoughts?

dancek commented 8 years ago

I'd also like to see this. Right now I'd have some use for it at work, so if I can convince the customer that it's worthwhile, I might even be able to implement it.

matthew-dalton-sirca commented 7 years ago

Me too, with the additional requirement that it be able to detect such duplicates when they appear in different css files. Currently csslint appears to treat each file as an independent unit.

CubeOfCheese commented 3 years ago

@matthew-dalton-sirca That seems out of scope of the linter unless it was only doing that for css imports. But parsing html files to see which css files coexist seems out of scope