scss-lint
scss-lint copied to clipboard
Problems with selector and braces indentation
The clean code (expected)
.foo {
font-size: 18px;
}
But, scss-lint don't give any errors/warnings with these bad indentations :disappointed:
.foo {
font-size: 18px;
}
.foo { // If this is the first line of the file
font-size: 18px;
}
Am I'm missing any settings here or is it really a bug?
scss-lint version I'm referring to is 0.42.2
@sds I agree this is a bug. But is this feasible to lint on? If I add a puts statement showing the source for the RuleNode, I get the following:
cat issue-614.scss
.foo {
font-size: 18px;
}
$ bundle exec bin/scss-lint issue-614.scss
NODE: Sass::Tree::RuleNode '.foo {'
NODE: Sass::Tree::PropNode 'font-size: 18px;'
Looks like we basically just get the source for the selectors of a RuleNode??? :frowning:
Thanks for the report, @saneef.
As @srawlins points out this is actually quite difficult to do since the Sass parser doesn't give us any information about where the closing brace is located. I've thought about this long ago and came to the conclusion that any workarounds would be brittle and still have edge cases, but I'm open to a pull request that attempts to solve this problem.
One approach would be to find the "next node" (i.e. following sibling or an ancestor's sibling), and backtracking from that node until we find a curly brace. I'm sure there are edge cases where that won't work perfectly, however—since we also need to detect whether a node contains curly braces, which is a feat in and of itself (remember that PropNode
s can optionally contain curlies for nested properties).
Open to other proposals that solve this issue!