zmoazeni / csscss

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

Incorrectly reporting duplicate declarations when using media queries #45

Open jjenzz opened 11 years ago

jjenzz commented 11 years ago

I have something similar to the following:

@media (min-width: 30em) {
  .m-label {
    display: block;
  }
}

/* because less than IE9 
 * doesn't support media queries */
.lt-ie9 .m-label {
  display: block;
}

Although they are sharing the same declaration, there is no way around that as they are only sharing it if the media query applies.

Would it make more sense for the parser to report duplicated declarations outside media queries separately from those inside media queries?

zmoazeni commented 11 years ago

Thank you @jjenzz that's an interesting thought. I need to chew on it a little. I welcome anyone else to add to the discussion too.

Melindrea commented 11 years ago

I actually just ran into that particular issue. Overall, I extend classes, but that is not possible to do into media queries, so I get an error from the following:

@media (min-width: 24em) {
/* line 81, ../../app/styles/site.scss */
  .contact {
    font-size: 36px;
    font-size: 2rem;
    margin-bottom: 0.825rem;
  }
}

.gamma, h3, .subtitle {
   font-size: 36px;
   font-size: 2rem;
   margin-bottom: 0.825rem;
 }

The particulars being that those three rules are generated as part of a vertical rhythm through typeplate, and once the screen gets wider I want to make the contact icons bigger.

alexkilgour commented 10 years ago

I definitely think that reporting duplicated declarations outside media queries separately from those inside media queries is a good idea. Could there be some way of displaying the media query definition in the output so you can differentiate where the declarations can be found?

cibulka commented 9 years ago

I very much second @howlingmad on 1) keeping duplicated declarations inside MQs but 2) marking them somehow differently in the ouput. Is there any chance you might consider to incorporate that into the plugin?

Thank you!