Skip to content

Commit

Permalink
Adjust how TrailingSemicolon lints List and Map variable definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
srawlins committed Nov 9, 2015
1 parent f7168fd commit 8859b8a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/scss_lint/linter/trailing_semicolon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ def visit_variable(node)
# !default`.
return check_semicolon(node) if node.global || node.guarded

# If the variable is a multi-line ListLiteral or MapLiteral, then
# `node.expr` will give us everything except the last right paren, and
# the semicolon if it exists. In these cases, use the source range of
# `node` as above.
if (node.expr.is_a?(Sass::Script::Tree::ListLiteral) ||
node.expr.is_a?(Sass::Script::Tree::MapLiteral)) &&
!node_on_single_line?(node)
return check_semicolon(node)
end

check_semicolon(node.expr)
end

Expand Down
28 changes: 28 additions & 0 deletions spec/scss_lint/linter/trailing_semicolon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,34 @@
it { should report_lint }
end
end

context 'and a nested list' do
context 'and ends with a semicolon' do
let(:scss) { <<-SCSS }
$foo: (
"a": (
"b",
"c"
)
);
SCSS

it { should_not report_lint }
end

context 'and is missing a semicolon' do
let(:scss) { <<-SCSS }
$foo: (
"a": (
"b",
"c"
)
)
SCSS

it { should report_lint }
end
end
end

context 'with an @extend directive' do
Expand Down

0 comments on commit 8859b8a

Please sign in to comment.