Skip to content

Commit

Permalink
EmptyLineBetweenBlocks lints on @media and @at-root now
Browse files Browse the repository at this point in the history
  • Loading branch information
srawlins committed Nov 7, 2015
1 parent 02ad4b1 commit d45cf70
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/scss_lint/linter/empty_line_between_blocks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ module SCSSLint
class Linter::EmptyLineBetweenBlocks < Linter
include LinterRegistry

def visit_atroot(node)
check(node, '@at-root')
yield
end

def visit_function(node)
check(node, '@function')
yield
end

def visit_media(node)
check(node, '@media')
yield
end

def visit_mixin(node)
# Ignore @includes which don't have any block content
check(node, '@include') if node.children
Expand Down
62 changes: 62 additions & 0 deletions spec/scss_lint/linter/empty_line_between_blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,68 @@
it { should_not report_lint }
end

context 'when at-roots are defined' do
context 'and there is no blank line between them' do
let(:scss) { <<-SCSS }
div {
@at-root {
p {
}
}
@at-root {
p {
}
}
}
SCSS

it { should report_lint line: 5 }
end

context 'and there is a blank line between them' do
let(:scss) { <<-SCSS }
div {
@at-root {
p {
}
}
@at-root {
p {
}
}
}
SCSS

it { should_not report_lint }
end
end

context 'when media blocks are defined' do
context 'and there is no blank line between them' do
let(:scss) { <<-SCSS }
@media screen {
}
@media print {
}
SCSS

it { should report_lint line: 2 }
end

context 'and there is a blank line between them' do
let(:scss) { <<-SCSS }
@media screen {
}
@media print {
}
SCSS

it { should_not report_lint }
end
end

context 'when mixins are defined' do
context 'and there is no blank line between them' do
let(:scss) { <<-SCSS }
Expand Down

0 comments on commit d45cf70

Please sign in to comment.