Skip to content

Commit

Permalink
Fix PlaceholderInExtend to report comma sequences
Browse files Browse the repository at this point in the history
Fixes sds#747
  • Loading branch information
sds committed Aug 27, 2016
1 parent e54da99 commit 254cf91
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* Fix `Shorthand` to not report shorthanded values with `!important` as having
a shorthand length not specified in `allowed_shorthands`
* Fix `UnnecessaryMantissa` to ignore decimal values in URL literals
* Fix `PlaceholderInExtend` to report comma sequences starting with a
placeholder

## 0.49.0

Expand Down
12 changes: 7 additions & 5 deletions lib/scss_lint/linter/placeholder_in_extend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ def visit_extend(node)
# every word boundary (so %placeholder becomes ['%', 'placeholder']).
selector = node.selector.join

# Ignore if this is a placeholder
return if selector.start_with?('%')

add_lint(node, 'Prefer using placeholder selectors (e.g. ' \
'%some-placeholder) with @extend')
if selector.include?(',')
add_lint(node, 'Avoid comma sequences in `@extend` directives; ' \
'prefer single placeholder selectors (e.g. `%some-placeholder`)')
elsif !selector.start_with?('%')
add_lint(node, 'Prefer using placeholder selectors (e.g. ' \
'%some-placeholder) with @extend')
end
end
end
end
10 changes: 10 additions & 0 deletions spec/scss_lint/linter/placeholder_in_extend_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
it { should report_lint line: 2 }
end

context 'when extending with a comma sequence starting with a placeholder' do
let(:scss) { <<-SCSS }
p {
@extend %placeholder, .item;
}
SCSS

it { should report_lint line: 2 }
end

context 'when extending with a placeholder' do
let(:scss) { <<-SCSS }
p {
Expand Down

0 comments on commit 254cf91

Please sign in to comment.