EmptyLineBetweenBlocks should lint around @if, etc.
It seems like EmptyLineBetweenBlocks should lint around @if, no? It currently doesn't:
$ cat -n a.scss
1 a {
2 margin: 1px;
3 @if (1 + 1 == 2) {
4 padding: 2px;
5 }
6 .b {
7 margin: 1px;
8 }
9 }
$ bundle exec ./bin/scss-lint a.scss
a.scss:6 [W] EmptyLineBetweenBlocks: Rule declaration should be preceded by an empty line
$
I expected an additional lint on line 3.
I haven't checked other block types.
@if is tricky because of @else if/@else. I also think that since it deals with control flow the same rules need not necessarily apply.
I would certainly be open to extending EmptyLineBetweenBlocks to accept a configuration option that allows you to choose which type of block statements for which you want to enforce blank lines.
For reference, EmptyLineBetweenBlocks currently appears to expect spaces around:
@mixindeclarations@includedeclarations- rule declarations
@functiondeclarations
and not expect spaces around:
@mediadeclarations@ifdeclarations@at-rootdeclarations@fordeclarations@eachdeclarations@whiledeclarations
I would argue that EmptyLineBetweenBlocks should lint on @media and @at-root out of the box. But maybe control flow directives are special. So the configuration option special_block_types (?) could take the value :control_directives. I can't really identify better categorizations...
I think allowing you to name each type of node separately would be sufficient, rather than introducing fancy names for entire types of blocks. So adding a spaced_blocks option where you can specify:
spaced_blocks:
- media
- if
- for
- each
...
...would likely suffice.