bemlinter icon indicating copy to clipboard operation
bemlinter copied to clipboard

Should we compile the scss?

Open tzi opened this issue 8 years ago • 3 comments

Because we do not compile the SCSS files, we can not detect BEM errors like this one:

.block__element {
    &__antoher-element {}
}

Another example is a selector created by a mixin.

For now, we choose to throw an error when the & operator is used to concatenate class name #4

tzi avatar Jan 27 '17 09:01 tzi

It's maybe possible to keep source line number reference with a trick. Do you know how babel keep the reference to the source when it transforms js code on the fly ?

fdubost avatar Jan 27 '17 09:01 fdubost

Can we base ourselves on generated sourcemaps to detect those kind of things ? But a temporary solution would be to add a warning when we fall to case like this &__. Some people may prefer to code like this.

dtrillian avatar Jan 27 '17 09:01 dtrillian

Thanks @malikba, you could be right! It's became a bad practice to use Sass concatenation for CSS class names. It prevents simple search and complexify the sources.

We seem to use 22 times for now in our project in only 4 files. A warning is the simplest solution and also a way to push for best practices :+1:

Maybe we could also compile the scss, but later, in v2, or v3 :tongue:

tzi avatar Jan 27 '17 10:01 tzi