forked from sds/scss-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes sds#468
- Loading branch information
Showing
5 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module SCSSLint | ||
# Checks for trailing whitespace on a line. | ||
class Linter::TrailingWhitespace < Linter | ||
include LinterRegistry | ||
|
||
def visit_root(_node) | ||
engine.lines.each_with_index do |line, index| | ||
next unless line =~ /[ \t]+$/ | ||
|
||
add_lint(index + 1, 'Line contains trailing whitespace') | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'spec_helper' | ||
|
||
describe SCSSLint::Linter::TrailingWhitespace do | ||
context 'when lines contain trailing spaces' do | ||
let(:scss) { <<-SCSS } | ||
p { | ||
margin: 0;\s\s | ||
} | ||
SCSS | ||
|
||
it { should report_lint line: 2 } | ||
end | ||
|
||
context 'when lines contain trailing tabs' do | ||
let(:scss) { <<-SCSS } | ||
p { | ||
margin: 0;\t\t | ||
} | ||
SCSS | ||
|
||
it { should report_lint line: 2 } | ||
end | ||
|
||
context 'when lines does not contain trailing whitespace' do | ||
let(:scss) { <<-SCSS } | ||
p { | ||
margin: 0; | ||
} | ||
SCSS | ||
|
||
it { should_not report_lint } | ||
end | ||
end |