scss-lint
scss-lint copied to clipboard
Add a validator to force an empty line before and after a block
Expected behaviour The linter should inform developer if there are missing empty lines before and after a block.
Bad
.classname {
text-transform: uppercase;
.child {
text-align: center;
}
}
Good
.classname {
text-transform: uppercase;
.child {
text-align: center;
}
}
Would this be different from the EmptyLineBetweenBlocks linter?
An other blank line is added after the block not only before. When you have a lot of block within your scss file, adding a blank line after each of them helps to read better the code
I never saw the benefit of having an empty line after the last child element. Doesn't seem to be a convention afaik.
The validator would allow to do this:
.#{$namespace}list-table {
@include list-table($namespace);
.#{$namespace}list-table-body {
.#{$namespace}list-table-row {
.#{$namespace}list-table-cell {
border-top: 0.0625rem solid;
}
}
}
}
Instead of this that IMHO is harder to read even to figure out where is the }
of the list-table-row
:
.#{$namespace}list-table {
@include list-table($namespace);
.#{$namespace}list-table-body {
.#{$namespace}list-table-row {
.#{$namespace}list-table-cell {
border-top: 0.0625rem solid;
}
}
}
}
While this convention is certainly a bit out of the ordinary (I've never seen a codebase that enforced spacing after a block), I am happy to accept a pull request with tests adding support for this to EmptyLineBetweenBlocks
via some configuration option (for example, empty_line_before_and_after
). Thanks!