Skip to content

Commit

Permalink
Check if/else statements in SpaceBeforeBrace
Browse files Browse the repository at this point in the history
We forgot to visit if/else statements in this linter. Include them.

Fixes sds#845
  • Loading branch information
sds committed Sep 28, 2016
1 parent 2a35c93 commit 3ba8e32
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/scss_lint/linter/space_before_brace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ def check_node(node)
yield
end

def visit_if(node, &block)
check_node(node, &block)
check_node(node.else, &block) if node.else
end

alias visit_function check_node
alias visit_each check_node
alias visit_for check_node
Expand Down
23 changes: 23 additions & 0 deletions spec/scss_lint/linter/space_before_brace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,29 @@
end
end

context 'with an @if/@else statement' do
context 'when brace is preceded by space' do
let(:scss) { <<-SCSS }
@if some_expression {
} @else {
}
SCSS

it { should_not report_lint }
end

context 'when brace is not preceded by space' do
let(:scss) { <<-SCSS }
@if some_expression{
} @else{
}
SCSS

it { should report_lint line: 1 }
it { should report_lint line: 2 }
end
end

context 'with a mixin include with braces' do
context 'with arguments' do
context 'when brace is preceded by a space' do
Expand Down

0 comments on commit 3ba8e32

Please sign in to comment.