csscss icon indicating copy to clipboard operation
csscss copied to clipboard

Incorrectly reporting duplicate declarations when using media queries

Open jjenzz opened this issue 12 years ago • 4 comments

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?

jjenzz avatar Apr 12 '13 11:04 jjenzz

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.

zmoazeni avatar Apr 12 '13 13:04 zmoazeni

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.

Melindrea avatar May 21 '13 09:05 Melindrea

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?

alexkilgour avatar Aug 09 '13 12:08 alexkilgour

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!

cibulka avatar Apr 16 '15 23:04 cibulka