I'm a beginner in CSS and I'm working on a project that has scss-lint to validate stylesheets formats.
I have the following classes:
.arrow--right {
border-bottom: 12px solid transparent;
border-left: 12px solid $border-color;
border-top: 12px solid transparent;
cursor: pointer;
height: 0;
transform: rotate(0deg);
transition: transform .1s linear;
width: 0;
}
.arrow--right.hover {
border-left-color: $brand-highlight;
}
The idea is that whenever I hover other element, hover
class is added to the arrow thus coloring it.
SCSS-Lint error: MergeableSelector: Merge rule
.arrow--right.hover
with.arrow--right
How can I merge these two rules without affecting the behaviour I'm trying to achieve?
The lint warning means that you should join the .hover
amendment within the main class selector using the &
operator, like this:
.arrow--right {
border-bottom: 12px solid transparent;
border-left: 12px solid $border-color;
border-top: 12px solid transparent;
cursor: pointer;
height: 0;
transform: rotate(0deg);
transition: transform .1s linear;
width: 0;
&.hover {
border-left-color: $brand-highlight;
}
}