travco / postcss-extend

A PostCSS plugin to minimize the number of repeat-selectors and rules you write
MIT License
114 stars 8 forks source link

Extending defined selector throws anti-pattern warning #3

Closed timkelty closed 8 years ago

timkelty commented 8 years ago

Using code from README:

.potato {
  color: white;
  outline: brown;
  font-family: sans-serif;
}

@media (width > 600px) {
  .spud {
    @extend .potato;
  }
}

This throws the anti-pattern warning, though the output is what you would want. Seems like it shouldn't throw the error if the selector is defined in the parent/root context.

Also - errors are formatted with a [postcss-simple-extend]' instead of just[postcss-extend]`

kswedberg commented 8 years ago

Pretty sure we're getting the [postcss-simple-extend] warnings because of this: https://github.com/travco/postcss-extend/blob/master/index.js#L6

Anything keeping you from changing that to "postcss-extend", @travco ?

travco commented 8 years ago

Negative, it'll be out of the codebase by the end of today. Frankly I'm surprised it didn't cause more issues.

Also, I'll look at drastically softening the anti-pattern warnings. They trigger for all functionality that isn't explicitly defined in the spec even if it's stable and shown in the README (originally to comply with cssnext's standards, however it's become progressively apparent that it isn't going to be included in that pack).

travco commented 8 years ago

Fixed via: https://github.com/travco/postcss-extend/commit/b4010ab4d96b4e107ab3a510d6405101aecb859b Bad plugin name (still facepalming over this) sorted, and false-positive antipattern warnings fixed with tests added.

kswedberg commented 8 years ago

thanks, @travco !