Skip to content

Commit

Permalink
Merge pull request sds#714 from cih/border_zero_description
Browse files Browse the repository at this point in the history
Improve BorderZero lint description
  • Loading branch information
lencioni committed Feb 17, 2016
2 parents 3c13957 + e67cb6b commit 6c15c05
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* Add `SpaceAfterVariableColon` which checks for the spacing after a variable
colon
* Relax rake dependency version to allow >= 0.9
* Improve `BorderZero` by adding the offending border property to the lint
description

## 0.44.0

Expand Down
12 changes: 6 additions & 6 deletions lib/scss_lint/linter/border_zero.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ def visit_root(_node)

def visit_prop(node)
return unless BORDER_PROPERTIES.include?(node.name.first.to_s)
check_border(node, node.value.to_sass.strip)
check_border(node, node.name.first.to_s, node.value.to_sass.strip)
end

private

def check_border(node, border)
return unless %w[0 none].include?(border)
return if @preference[0] == border
def check_border(node, border_property, border_value)
return unless %w[0 none].include?(border_value)
return if @preference[0] == border_value

add_lint(node, "`border: #{@preference[0]}` is preferred over " \
"`border: #{@preference[1]}`")
add_lint(node, "`#{border_property}: #{@preference[0]}` is preferred over " \
"`#{border_property}: #{@preference[1]}`")
end
end
end
22 changes: 22 additions & 0 deletions spec/scss_lint/linter/border_zero_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
end

context 'when a property' do
let(:lint_description) { subject.lints.first.description }

context 'contains a normal border' do
let(:scss) { <<-SCSS }
p {
Expand Down Expand Up @@ -39,6 +41,10 @@
SCSS

it { should report_lint line: 2 }

it 'should report lint with the border property in the description' do
lint_description.should == '`border: 0` is preferred over `border: none`'
end
end

context 'has a border-top of none' do
Expand All @@ -49,6 +55,10 @@
SCSS

it { should report_lint line: 2 }

it 'should report lint with the border-top property in the description' do
lint_description.should == '`border-top: 0` is preferred over `border-top: none`'
end
end

context 'has a border-right of none' do
Expand All @@ -59,6 +69,10 @@
SCSS

it { should report_lint line: 2 }

it 'should report lint with the border-right property in the description' do
lint_description.should == '`border-right: 0` is preferred over `border-right: none`'
end
end

context 'has a border-bottom of none' do
Expand All @@ -69,6 +83,10 @@
SCSS

it { should report_lint line: 2 }

it 'should report lint with the border-bottom property in the description' do
lint_description.should == '`border-bottom: 0` is preferred over `border-bottom: none`'
end
end

context 'has a border-left of none' do
Expand All @@ -79,6 +97,10 @@
SCSS

it { should report_lint line: 2 }

it 'should report lint with the border-left property in the description' do
lint_description.should == '`border-left: 0` is preferred over `border-left: none`'
end
end
end

Expand Down

0 comments on commit 6c15c05

Please sign in to comment.