You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's relatively common for authors to write selectors like .context & as a way of logically scoping the current style rule to a given context. However, this isn't very reliable in mixins, because the mixin may be included within another nested style rule, at which point the .context may be misplaced.
It would be useful to have a lint for this case to help authors ensure they're not accidentally making assumptions in their mixins. It should specifically warn for & in style rules when:
They're within a @mixin.
They're nested within another style rule.
They aren't at the beginning of a given complex selector. (That is, & .foo is fine, as is .foo, & .bar.)
They aren't within @at-root, since that can't be affected by parent style rules anyway. (This isn't accurate, & is still affected by outer style rules.)
It would even be possible to suggest a fix for this by pulling the parent selector into the child and making the child style rule a sibling. For example:
It's relatively common for authors to write selectors like
.context &
as a way of logically scoping the current style rule to a given context. However, this isn't very reliable in mixins, because the mixin may be included within another nested style rule, at which point the.context
may be misplaced.It would be useful to have a lint for this case to help authors ensure they're not accidentally making assumptions in their mixins. It should specifically warn for
&
in style rules when:@mixin
.& .foo
is fine, as is.foo, & .bar
.)They aren't within(This isn't accurate,@at-root
, since that can't be affected by parent style rules anyway.&
is still affected by outer style rules.)It would even be possible to suggest a fix for this by pulling the parent selector into the child and making the child style rule a sibling. For example:
could be adjusted to:
The text was updated successfully, but these errors were encountered: