zmoazeni / csscss

A CSS redundancy analyzer that analyzes redundancy.
http://zmoazeni.github.io/csscss/
MIT License
2.92k stars 151 forks source link

Duplicate CSS selectors not returned int result #93

Open viveksachdeva opened 9 years ago

viveksachdeva commented 9 years ago

Code Snippet:

div.main { width : 100%; }

div.main { background : white; }

Expected output: These two rules should be merged to one.

Actual output: Nothing.

chris-dura commented 9 years ago

@viveksachdeva -- if these rules are in the same *.scss file, you might be able to solve your scenario with SCSS Lint.

However, I think this would still be an excellent enhancement, because I've recently taken over a codebase where someone, for some reason, duplicated a large amount of SCSS rules in the codebase (probably some sort of copy+paste error, or just ignorance). So, now the generated CSS is akin to this:

// line 101
.widget {
   color: red;
   width: 100px;
}

...

// line 3571
.widget {
   color: red;
   width: 100px;
}

There's some tools out there that will remove redundant CSS in the .css file, but I need to get rid of the extra rule definition all together in my .scss files. So, even just getting output which tells me what the duplicate selectors are would be extremely helpful!