chriseppstein/sass — comment on commit f60bbd47fb7cd574db6c78932ca0fd523edd17df
File:  line 0
By nex3:

I think we should clarify the precise semantics of this warning, both in the text of the warning and in the tests. There are two possible interpretations of it; I assumed one was correct based on the description, but it turns out the other is actually implemented.

The first interpretation is that `@extend A` warns if the selector `A` doesn't exist in the stylesheet. This protects against typos and reminds you if you have more selectors to update for placeholder selectors. However, it _wouldn't_ give a warning for `div {@extend .foo}` if the only use of `.foo` was in `span.foo { ... }`.

The second interpretation is that `@extend A` warns if that particular `@extend` doesn't cause any new selectors to get generated. In addition to the protections given by the first interpretation, this provides the invariant that every `@extend` without the `!optional` flag is actually doing something. However, it also presents more opportunities for unintended errors. Imagine if a mixin containing `@extend .foo` were included in `div { ... }` when only `a.foo { ... }` was defined, for example.

I feel like the first interpretation encompasses all the cases where the user is clearly making a mistake in their use of `@extend`. Certainly `!optional` provides a backdoor for the second interpretation, but I think it's so broad that people will start feeling obligated to use `!optional` much more frequently than would be ideal. I'm open to being convinced otherwise, though.