I am refactoring some SCSS, and I have come across a nesting issue using BEM syntax in my SCSS files.
My linting rules state that I cannot use more than three levels of nesting.
However, sometimes I may want to target an element within a modifier selector in my SCSS file.
This is my approach:
.block {
&__element {
&--modifier {
&::after {
// Four levels deep :(
}
}
}
}
This is the only logical way I see around it:
.block {
&__element {
&--modifier {
// Three levels deep
}
&--modifier::after {
// Three levels deep
}
}
}
I am not a fan of this approach because I don't like repeating the modifier classname.
Is there a better solution for this?