csslint icon indicating copy to clipboard operation
csslint copied to clipboard

Detect duplicate selectors

Open serdar opened this issue 11 years ago • 3 comments

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?

serdar avatar Oct 13 '14 07:10 serdar

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.

dancek avatar Feb 09 '16 15:02 dancek

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.

matthew-dalton-sirca avatar Nov 18 '16 05:11 matthew-dalton-sirca

@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

CubeOfCheese avatar Mar 27 '21 20:03 CubeOfCheese