scss_lint 0.44.0 → 0.45.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +4 -0
- data/data/property-sort-orders/recess.txt +3 -0
- data/lib/scss_lint/config.rb +4 -3
- data/lib/scss_lint/engine.rb +5 -1
- data/lib/scss_lint/file_finder.rb +1 -1
- data/lib/scss_lint/linter/border_zero.rb +6 -6
- data/lib/scss_lint/linter/single_line_per_property.rb +2 -0
- data/lib/scss_lint/linter/space_after_variable_colon.rb +62 -0
- data/lib/scss_lint/linter/trailing_semicolon.rb +2 -3
- data/lib/scss_lint/plugins.rb +1 -1
- data/lib/scss_lint/version.rb +1 -1
- data/spec/scss_lint/file_finder_spec.rb +14 -12
- data/spec/scss_lint/linter/border_zero_spec.rb +22 -0
- data/spec/scss_lint/linter/indentation_spec.rb +12 -0
- data/spec/scss_lint/linter/single_line_per_property_spec.rb +20 -0
- data/spec/scss_lint/linter/space_after_variable_colon_spec.rb +186 -0
- data/spec/scss_lint/linter/trailing_semicolon_spec.rb +188 -24
- data/spec/scss_lint/plugins_spec.rb +3 -2
- metadata +15 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c80256e0f694ade8ef5c0651dfc3cd95d1ed76a
|
4
|
+
data.tar.gz: ea61d9083a223c299df36c0bc827e92716b941e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdd1c5afb4507f544ec533ee8387506edcf1ad30e8466b0d01a0faaec2db376c4413fbd7b822fac687ba6c7ffd9672ad8103fdf2796a8521c6ae08815511269d
|
7
|
+
data.tar.gz: 22a40913e53ebf7e82b181aca67af574a26d5a00ce10b7b090c77f7ba1756e084b038d634b0ff4dc244bd0561922a02f2a780b0f073aa4419e93a7638fea54b9
|
data/config/default.yml
CHANGED
data/lib/scss_lint/config.rb
CHANGED
@@ -8,7 +8,7 @@ module SCSSLint
|
|
8
8
|
FILE_NAME = '.scss-lint.yml'.freeze
|
9
9
|
DEFAULT_FILE = File.join(SCSS_LINT_HOME, 'config', 'default.yml')
|
10
10
|
|
11
|
-
attr_reader :options, :warnings
|
11
|
+
attr_reader :options, :warnings, :file
|
12
12
|
|
13
13
|
class << self
|
14
14
|
def default
|
@@ -20,7 +20,7 @@ module SCSSLint
|
|
20
20
|
def load(file, options = {})
|
21
21
|
config_options = load_options_hash_from_file(file)
|
22
22
|
|
23
|
-
config = new(config_options)
|
23
|
+
config = new(config_options, file)
|
24
24
|
|
25
25
|
# Need to call this before merging with the default configuration so
|
26
26
|
# that plugins can override the default configuration while still being
|
@@ -201,9 +201,10 @@ module SCSSLint
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
|
-
def initialize(options)
|
204
|
+
def initialize(options, file = Config.user_file)
|
205
205
|
@options = options
|
206
206
|
@warnings = []
|
207
|
+
@file = file
|
207
208
|
|
208
209
|
validate_linters
|
209
210
|
end
|
data/lib/scss_lint/engine.rb
CHANGED
@@ -24,8 +24,12 @@ module SCSSLint
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# Need to force encoding to avoid Windows-related bugs.
|
27
|
+
# Need to encode with universal newline to avoid other Windows-related bugs.
|
27
28
|
# Need `to_a` for Ruby 1.9.3.
|
28
|
-
|
29
|
+
encoding = 'UTF-8'
|
30
|
+
@lines = @contents.force_encoding(encoding)
|
31
|
+
.encode(encoding, universal_newline: true)
|
32
|
+
.lines.to_a
|
29
33
|
@tree = @engine.to_tree
|
30
34
|
find_any_control_commands
|
31
35
|
rescue Encoding::UndefinedConversionError, Sass::SyntaxError, ArgumentError => error
|
@@ -23,17 +23,17 @@ module SCSSLint
|
|
23
23
|
|
24
24
|
def visit_prop(node)
|
25
25
|
return unless BORDER_PROPERTIES.include?(node.name.first.to_s)
|
26
|
-
check_border(node, node.value.to_sass.strip)
|
26
|
+
check_border(node, node.name.first.to_s, node.value.to_sass.strip)
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
-
def check_border(node,
|
32
|
-
return unless %w[0 none].include?(
|
33
|
-
return if @preference[0] ==
|
31
|
+
def check_border(node, border_property, border_value)
|
32
|
+
return unless %w[0 none].include?(border_value)
|
33
|
+
return if @preference[0] == border_value
|
34
34
|
|
35
|
-
add_lint(node, "
|
36
|
-
"
|
35
|
+
add_lint(node, "`#{border_property}: #{@preference[0]}` is preferred over " \
|
36
|
+
"`#{border_property}: #{@preference[1]}`")
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module SCSSLint
|
2
|
+
# Checks for spaces following the colon that separates a variable's name from
|
3
|
+
# its value.
|
4
|
+
class Linter::SpaceAfterVariableColon < Linter
|
5
|
+
include LinterRegistry
|
6
|
+
|
7
|
+
def visit_variable(node)
|
8
|
+
whitespace = whitespace_after_colon(node)
|
9
|
+
|
10
|
+
case config['style']
|
11
|
+
when 'no_space'
|
12
|
+
check_for_no_spaces(node, whitespace)
|
13
|
+
when 'one_space'
|
14
|
+
check_for_one_space(node, whitespace)
|
15
|
+
when 'at_least_one_space'
|
16
|
+
check_for_at_least_one_space(node, whitespace)
|
17
|
+
when 'one_space_or_newline'
|
18
|
+
check_for_one_space_or_newline(node, whitespace)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def check_for_no_spaces(node, whitespace)
|
25
|
+
return if whitespace == []
|
26
|
+
add_lint(node, 'Colon after variable should not be followed by any spaces')
|
27
|
+
end
|
28
|
+
|
29
|
+
def check_for_one_space(node, whitespace)
|
30
|
+
return if whitespace == [' ']
|
31
|
+
add_lint(node, 'Colon after variable should be followed by one space')
|
32
|
+
end
|
33
|
+
|
34
|
+
def check_for_at_least_one_space(node, whitespace)
|
35
|
+
return if whitespace.uniq == [' ']
|
36
|
+
add_lint(node, 'Colon after variable should be followed by at least one space')
|
37
|
+
end
|
38
|
+
|
39
|
+
def check_for_one_space_or_newline(node, whitespace)
|
40
|
+
return if whitespace == [' '] || whitespace == ["\n"]
|
41
|
+
return if whitespace[0] == "\n" && whitespace[1..-1].uniq == [' ']
|
42
|
+
add_lint(node, 'Colon after variable should be followed by one space or a newline')
|
43
|
+
end
|
44
|
+
|
45
|
+
def whitespace_after_colon(node)
|
46
|
+
whitespace = []
|
47
|
+
offset = 0
|
48
|
+
start_pos = node.source_range.start_pos
|
49
|
+
|
50
|
+
# Find the colon after the variable name
|
51
|
+
offset = offset_to(start_pos, ':', offset) + 1
|
52
|
+
|
53
|
+
# Count spaces after the colon
|
54
|
+
while [' ', "\t", "\n"].include? character_at(start_pos, offset)
|
55
|
+
whitespace << character_at(start_pos, offset)
|
56
|
+
offset += 1
|
57
|
+
end
|
58
|
+
|
59
|
+
whitespace
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -19,9 +19,8 @@ module SCSSLint
|
|
19
19
|
# `node.expr` will give us everything except the last right paren, and
|
20
20
|
# the semicolon if it exists. In these cases, use the source range of
|
21
21
|
# `node` as above.
|
22
|
-
if
|
23
|
-
node.expr.is_a?(Sass::Script::Tree::MapLiteral)
|
24
|
-
!node_on_single_line?(node)
|
22
|
+
if node.expr.is_a?(Sass::Script::Tree::ListLiteral) ||
|
23
|
+
node.expr.is_a?(Sass::Script::Tree::MapLiteral)
|
25
24
|
return check_semicolon(node)
|
26
25
|
end
|
27
26
|
|
data/lib/scss_lint/plugins.rb
CHANGED
data/lib/scss_lint/version.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
describe SCSSLint::FileFinder do
|
4
5
|
let(:config) { SCSSLint::Config.default }
|
@@ -21,12 +22,12 @@ describe SCSSLint::FileFinder do
|
|
21
22
|
|
22
23
|
context 'and there are SCSS files under the current directory' do
|
23
24
|
before do
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
FileUtils.touch('blah.scss')
|
26
|
+
FileUtils.mkdir_p('more')
|
27
|
+
FileUtils.touch(File.join('more', 'more.scss'))
|
27
28
|
end
|
28
29
|
|
29
|
-
it { should == ['blah.scss', 'more
|
30
|
+
it { should == ['blah.scss', File.join('more', 'more.scss')] }
|
30
31
|
end
|
31
32
|
|
32
33
|
context 'and a default set of files is specified in the config' do
|
@@ -45,7 +46,7 @@ describe SCSSLint::FileFinder do
|
|
45
46
|
|
46
47
|
context 'and those files exist' do
|
47
48
|
before do
|
48
|
-
|
49
|
+
FileUtils.touch('test.txt')
|
49
50
|
end
|
50
51
|
|
51
52
|
it { should == ['test.txt'] }
|
@@ -66,10 +67,10 @@ describe SCSSLint::FileFinder do
|
|
66
67
|
|
67
68
|
context 'and they contain SCSS files' do
|
68
69
|
before do
|
69
|
-
|
70
|
+
FileUtils.touch(File.join('some-dir', 'test.scss'))
|
70
71
|
end
|
71
72
|
|
72
|
-
it { should == ['some-dir
|
73
|
+
it { should == [File.join('some-dir', 'test.scss')] }
|
73
74
|
|
74
75
|
context 'and those SCSS files are excluded by the config' do
|
75
76
|
before do
|
@@ -82,19 +83,20 @@ describe SCSSLint::FileFinder do
|
|
82
83
|
|
83
84
|
context 'and they contain CSS files' do
|
84
85
|
before do
|
85
|
-
|
86
|
+
FileUtils.touch(File.join('some-dir', 'test.css'))
|
86
87
|
end
|
87
88
|
|
88
|
-
it { should == ['some-dir
|
89
|
+
it { should == [File.join('some-dir', 'test.css')] }
|
89
90
|
end
|
90
91
|
|
91
92
|
context 'and they contain more directories with files with recognized extensions' do
|
92
93
|
before do
|
93
94
|
`mkdir -p some-dir/more-dir`
|
94
|
-
|
95
|
+
FileUtils.mkdir_p(File.join('some-dir', 'more-dir'))
|
96
|
+
FileUtils.touch(File.join('some-dir', 'more-dir', 'test.scss'))
|
95
97
|
end
|
96
98
|
|
97
|
-
it { should == ['some-dir
|
99
|
+
it { should == [File.join('some-dir', 'more-dir', 'test.scss')] }
|
98
100
|
|
99
101
|
context 'and those SCSS files are excluded by the config' do
|
100
102
|
before do
|
@@ -107,7 +109,7 @@ describe SCSSLint::FileFinder do
|
|
107
109
|
|
108
110
|
context 'and they contain no SCSS files' do
|
109
111
|
before do
|
110
|
-
|
112
|
+
FileUtils.touch(File.join('some-dir', 'test.txt'))
|
111
113
|
end
|
112
114
|
|
113
115
|
it 'raises an error' do
|
@@ -11,6 +11,8 @@ describe SCSSLint::Linter::BorderZero do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
context 'when a property' do
|
14
|
+
let(:lint_description) { subject.lints.first.description }
|
15
|
+
|
14
16
|
context 'contains a normal border' do
|
15
17
|
let(:scss) { <<-SCSS }
|
16
18
|
p {
|
@@ -39,6 +41,10 @@ describe SCSSLint::Linter::BorderZero do
|
|
39
41
|
SCSS
|
40
42
|
|
41
43
|
it { should report_lint line: 2 }
|
44
|
+
|
45
|
+
it 'should report lint with the border property in the description' do
|
46
|
+
lint_description.should == '`border: 0` is preferred over `border: none`'
|
47
|
+
end
|
42
48
|
end
|
43
49
|
|
44
50
|
context 'has a border-top of none' do
|
@@ -49,6 +55,10 @@ describe SCSSLint::Linter::BorderZero do
|
|
49
55
|
SCSS
|
50
56
|
|
51
57
|
it { should report_lint line: 2 }
|
58
|
+
|
59
|
+
it 'should report lint with the border-top property in the description' do
|
60
|
+
lint_description.should == '`border-top: 0` is preferred over `border-top: none`'
|
61
|
+
end
|
52
62
|
end
|
53
63
|
|
54
64
|
context 'has a border-right of none' do
|
@@ -59,6 +69,10 @@ describe SCSSLint::Linter::BorderZero do
|
|
59
69
|
SCSS
|
60
70
|
|
61
71
|
it { should report_lint line: 2 }
|
72
|
+
|
73
|
+
it 'should report lint with the border-right property in the description' do
|
74
|
+
lint_description.should == '`border-right: 0` is preferred over `border-right: none`'
|
75
|
+
end
|
62
76
|
end
|
63
77
|
|
64
78
|
context 'has a border-bottom of none' do
|
@@ -69,6 +83,10 @@ describe SCSSLint::Linter::BorderZero do
|
|
69
83
|
SCSS
|
70
84
|
|
71
85
|
it { should report_lint line: 2 }
|
86
|
+
|
87
|
+
it 'should report lint with the border-bottom property in the description' do
|
88
|
+
lint_description.should == '`border-bottom: 0` is preferred over `border-bottom: none`'
|
89
|
+
end
|
72
90
|
end
|
73
91
|
|
74
92
|
context 'has a border-left of none' do
|
@@ -79,6 +97,10 @@ describe SCSSLint::Linter::BorderZero do
|
|
79
97
|
SCSS
|
80
98
|
|
81
99
|
it { should report_lint line: 2 }
|
100
|
+
|
101
|
+
it 'should report lint with the border-left property in the description' do
|
102
|
+
lint_description.should == '`border-left: 0` is preferred over `border-left: none`'
|
103
|
+
end
|
82
104
|
end
|
83
105
|
end
|
84
106
|
|
@@ -19,6 +19,11 @@ describe SCSSLint::Linter::Indentation do
|
|
19
19
|
SCSS
|
20
20
|
|
21
21
|
it { should_not report_lint }
|
22
|
+
|
23
|
+
context 'with carriage returns for newlines' do
|
24
|
+
let(:scss) { "p {\r margin: 0;\r}" }
|
25
|
+
it { should_not report_lint }
|
26
|
+
end
|
22
27
|
end
|
23
28
|
|
24
29
|
context 'when lines in a rule set are not properly indented' do
|
@@ -33,6 +38,13 @@ describe SCSSLint::Linter::Indentation do
|
|
33
38
|
it { should report_lint line: 2 }
|
34
39
|
it { should_not report_lint line: 3 }
|
35
40
|
it { should report_lint line: 4 }
|
41
|
+
|
42
|
+
context 'with carriage returns for newlines' do
|
43
|
+
let(:scss) { "p {\rmargin: 0;\r padding: 1em;}" }
|
44
|
+
it { should_not report_lint line: 1 }
|
45
|
+
it { should report_lint line: 2 }
|
46
|
+
it { should_not report_lint line: 3 }
|
47
|
+
end
|
36
48
|
end
|
37
49
|
|
38
50
|
context 'when selector of a nested rule set is not properly indented' do
|
@@ -70,4 +70,24 @@ describe SCSSLint::Linter::SingleLinePerProperty do
|
|
70
70
|
it { should report_lint }
|
71
71
|
end
|
72
72
|
end
|
73
|
+
|
74
|
+
context 'when a nested single line rule set contains a single property' do
|
75
|
+
let(:scss) { <<-SCSS }
|
76
|
+
.my-selector {
|
77
|
+
p { color: #fff; }
|
78
|
+
}
|
79
|
+
SCSS
|
80
|
+
|
81
|
+
context 'and single line rule sets are allowed' do
|
82
|
+
let(:linter_config) { { 'allow_single_line_rule_sets' => true } }
|
83
|
+
|
84
|
+
it { should_not report_lint }
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'and single line rule sets are not allowed' do
|
88
|
+
let(:linter_config) { { 'allow_single_line_rule_sets' => false } }
|
89
|
+
|
90
|
+
it { should report_lint }
|
91
|
+
end
|
92
|
+
end
|
73
93
|
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::SpaceAfterVariableColon do
|
4
|
+
let(:linter_config) { { 'style' => style } }
|
5
|
+
|
6
|
+
context 'when one space is preferred' do
|
7
|
+
let(:style) { 'one_space' }
|
8
|
+
|
9
|
+
context 'when the colon after a variable is not followed by space' do
|
10
|
+
let(:scss) { '$my-color:#fff;' }
|
11
|
+
|
12
|
+
it { should report_lint line: 1 }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when the colon after a variable is followed by more than one space' do
|
16
|
+
let(:scss) { '$my-color: #fff;' }
|
17
|
+
|
18
|
+
it { should report_lint line: 1 }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when the colon after a variable is followed by a space' do
|
22
|
+
let(:scss) { '$my-color: #fff;' }
|
23
|
+
|
24
|
+
it { should_not report_lint }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when the colon after a variable is surrounded by spaces' do
|
28
|
+
let(:scss) { '$my-color : #fff;' }
|
29
|
+
|
30
|
+
it { should_not report_lint }
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when the colon after a variable is followed by a space and a newline' do
|
34
|
+
let(:scss) { <<-SCSS }
|
35
|
+
$my-color:\s
|
36
|
+
#fff;
|
37
|
+
SCSS
|
38
|
+
|
39
|
+
it { should report_lint line: 1 }
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when the colon after a property is followed by a tab' do
|
43
|
+
let(:scss) { <<-SCSS }
|
44
|
+
$my-color:\t#fff;
|
45
|
+
SCSS
|
46
|
+
|
47
|
+
it { should report_lint line: 1 }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when no spaces are allowed' do
|
52
|
+
let(:style) { 'no_space' }
|
53
|
+
|
54
|
+
context 'when the colon after a variable is not followed by space' do
|
55
|
+
let(:scss) { '$my-color:#fff;' }
|
56
|
+
|
57
|
+
it { should_not report_lint }
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when colon after variable is not followed by space and the semicolon is missing' do
|
61
|
+
let(:scss) { '$my-color:#fff' }
|
62
|
+
|
63
|
+
it { should_not report_lint }
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when the colon after a property is followed by a space' do
|
67
|
+
let(:scss) { '$my-color: #fff;' }
|
68
|
+
|
69
|
+
it { should report_lint line: 1 }
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when the colon after a property is surrounded by spaces' do
|
73
|
+
let(:scss) { '$my-color : #fff;' }
|
74
|
+
|
75
|
+
it { should report_lint line: 1 }
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when the colon after a property is followed by multiple spaces' do
|
79
|
+
let(:scss) { '$my-color: #fff;' }
|
80
|
+
|
81
|
+
it { should report_lint line: 1 }
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when the colon after a property is followed by a newline' do
|
85
|
+
let(:scss) { <<-SCSS }
|
86
|
+
$my-color:
|
87
|
+
#fff;
|
88
|
+
SCSS
|
89
|
+
|
90
|
+
it { should report_lint line: 1 }
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when the colon after a property is followed by a tab' do
|
94
|
+
let(:scss) { <<-SCSS }
|
95
|
+
$my-color:\t#fff;
|
96
|
+
SCSS
|
97
|
+
|
98
|
+
it { should report_lint line: 1 }
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'when at least one space is preferred' do
|
103
|
+
let(:style) { 'at_least_one_space' }
|
104
|
+
|
105
|
+
context 'when the colon after a variable is not followed by space' do
|
106
|
+
let(:scss) { '$my-color:#fff;' }
|
107
|
+
|
108
|
+
it { should report_lint line: 1 }
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'when colon after variable is not followed by space and the semicolon is missing' do
|
112
|
+
let(:scss) { '$my-color:#fff' }
|
113
|
+
|
114
|
+
it { should report_lint line: 1 }
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'when the colon after a variable is followed by a space' do
|
118
|
+
let(:scss) { '$my-color: #fff;' }
|
119
|
+
|
120
|
+
it { should_not report_lint }
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'when the colon after a variable is surrounded by spaces' do
|
124
|
+
let(:scss) { '$my-color : #fff;' }
|
125
|
+
|
126
|
+
it { should_not report_lint }
|
127
|
+
end
|
128
|
+
|
129
|
+
context 'when the colon after a variable is followed by multiple spaces' do
|
130
|
+
let(:scss) { '$my-color: #fff;' }
|
131
|
+
|
132
|
+
it { should_not report_lint }
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'when the colon after a property is followed by multiple spaces and a tab' do
|
136
|
+
let(:scss) { <<-SCSS }
|
137
|
+
$my-color: \t#fff;
|
138
|
+
SCSS
|
139
|
+
|
140
|
+
it { should report_lint line: 1 }
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context 'when one space or newline is preferred' do
|
145
|
+
let(:style) { 'one_space_or_newline' }
|
146
|
+
|
147
|
+
context 'when the colon after a variabl is not followed by space' do
|
148
|
+
let(:scss) { '$my-color:#fff;' }
|
149
|
+
|
150
|
+
it { should report_lint line: 1 }
|
151
|
+
end
|
152
|
+
|
153
|
+
context 'when the colon after a variable is followed by a space' do
|
154
|
+
let(:scss) { '$my-color: #fff;' }
|
155
|
+
|
156
|
+
it { should_not report_lint }
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'when the colon after a variable is followed by a newline and spaces' do
|
160
|
+
let(:scss) { <<-SCSS }
|
161
|
+
$my-color:
|
162
|
+
#fff;
|
163
|
+
SCSS
|
164
|
+
|
165
|
+
it { should_not report_lint }
|
166
|
+
end
|
167
|
+
|
168
|
+
context 'when the colon after a variable is followed by a newline and no spaces' do
|
169
|
+
let(:scss) { <<-SCSS }
|
170
|
+
$my-color:
|
171
|
+
#fff;
|
172
|
+
SCSS
|
173
|
+
|
174
|
+
it { should_not report_lint }
|
175
|
+
end
|
176
|
+
|
177
|
+
context 'when the colon after a variable is followed by a space and then a newline' do
|
178
|
+
let(:scss) { <<-SCSS }
|
179
|
+
$my-color:\s
|
180
|
+
#fff;
|
181
|
+
SCSS
|
182
|
+
|
183
|
+
it { should report_lint line: 1 }
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
@@ -442,62 +442,226 @@ describe SCSSLint::Linter::TrailingSemicolon do
|
|
442
442
|
end
|
443
443
|
end
|
444
444
|
|
445
|
-
context 'when a variable declaration contains a
|
446
|
-
context 'with
|
445
|
+
context 'when a variable declaration contains a list' do
|
446
|
+
context 'with parentheses' do
|
447
447
|
context 'and ends with a semicolon' do
|
448
|
-
let(:scss) {
|
448
|
+
let(:scss) { '$foo: (1 2);' }
|
449
449
|
|
450
450
|
it { should_not report_lint }
|
451
451
|
end
|
452
452
|
|
453
453
|
context 'and is missing a semicolon' do
|
454
|
-
let(:scss) {
|
454
|
+
let(:scss) { '$foo: (1 2)' }
|
455
455
|
|
456
456
|
it { should report_lint }
|
457
457
|
end
|
458
|
+
|
459
|
+
context 'and a nested list' do
|
460
|
+
context 'with parentheses' do
|
461
|
+
context 'on a single line' do
|
462
|
+
context 'and ends with a semicolon' do
|
463
|
+
let(:scss) { '$foo: (1 (2 3));' }
|
464
|
+
|
465
|
+
it { should_not report_lint }
|
466
|
+
end
|
467
|
+
|
468
|
+
context 'and is missing a semicolon' do
|
469
|
+
let(:scss) { '$foo: (1 (2 3))' }
|
470
|
+
|
471
|
+
it { should report_lint }
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
context 'over multiple lines' do
|
476
|
+
context 'and ends with a semicolon' do
|
477
|
+
let(:scss) { <<-SCSS }
|
478
|
+
$foo: (1
|
479
|
+
(2 3)
|
480
|
+
);
|
481
|
+
SCSS
|
482
|
+
it { should_not report_lint }
|
483
|
+
end
|
484
|
+
|
485
|
+
context 'and is missing a semicolon' do
|
486
|
+
let(:scss) { <<-SCSS }
|
487
|
+
$foo: (1
|
488
|
+
(2 3)
|
489
|
+
)
|
490
|
+
SCSS
|
491
|
+
|
492
|
+
it { should report_lint }
|
493
|
+
end
|
494
|
+
end
|
495
|
+
end
|
496
|
+
|
497
|
+
context 'without parentheses' do
|
498
|
+
context 'and ends with a semicolon' do
|
499
|
+
let(:scss) { <<-SCSS }
|
500
|
+
$foo: (10
|
501
|
+
20 21 22
|
502
|
+
30);
|
503
|
+
SCSS
|
504
|
+
|
505
|
+
it { should_not report_lint }
|
506
|
+
end
|
507
|
+
|
508
|
+
context 'and is missing a semicolon' do
|
509
|
+
let(:scss) { <<-SCSS }
|
510
|
+
$foo: (10
|
511
|
+
20 21 22
|
512
|
+
30)
|
513
|
+
SCSS
|
514
|
+
|
515
|
+
it { should report_lint }
|
516
|
+
end
|
517
|
+
end
|
518
|
+
end
|
458
519
|
end
|
459
520
|
|
460
|
-
context 'without
|
521
|
+
context 'without parentheses' do
|
461
522
|
context 'and ends with a semicolon' do
|
462
|
-
let(:scss) {
|
523
|
+
let(:scss) { '$foo: 1 2;' }
|
463
524
|
|
464
525
|
it { should_not report_lint }
|
465
526
|
end
|
466
527
|
|
467
528
|
context 'and is missing a semicolon' do
|
468
|
-
let(:scss) {
|
529
|
+
let(:scss) { '$foo: 1 2' }
|
469
530
|
|
470
531
|
it { should report_lint }
|
471
532
|
end
|
533
|
+
|
534
|
+
context 'and a nested list' do
|
535
|
+
context 'with parentheses' do
|
536
|
+
context 'on a single line' do
|
537
|
+
context 'and ends with a semicolon' do
|
538
|
+
let(:scss) { '$foo: 1 (2 3);' }
|
539
|
+
|
540
|
+
it { should_not report_lint }
|
541
|
+
end
|
542
|
+
|
543
|
+
context 'and is missing a semicolon' do
|
544
|
+
let(:scss) { '$foo: 1 (2 3)' }
|
545
|
+
|
546
|
+
it { should report_lint }
|
547
|
+
end
|
548
|
+
end
|
549
|
+
|
550
|
+
context 'over multiple lines' do
|
551
|
+
context 'and ends with a semicolon' do
|
552
|
+
let(:scss) { <<-SCSS }
|
553
|
+
$foo: 1
|
554
|
+
(2 3);
|
555
|
+
SCSS
|
556
|
+
it { should_not report_lint }
|
557
|
+
end
|
558
|
+
|
559
|
+
context 'and is missing a semicolon' do
|
560
|
+
let(:scss) { <<-SCSS }
|
561
|
+
$foo: 1
|
562
|
+
(2 3)
|
563
|
+
SCSS
|
564
|
+
|
565
|
+
it { should report_lint }
|
566
|
+
end
|
567
|
+
end
|
568
|
+
end
|
569
|
+
|
570
|
+
context 'without parentheses' do
|
571
|
+
context 'and ends with a semicolon' do
|
572
|
+
let(:scss) { <<-SCSS }
|
573
|
+
$foo: 1,
|
574
|
+
2 3;
|
575
|
+
SCSS
|
576
|
+
|
577
|
+
it { should_not report_lint }
|
578
|
+
end
|
579
|
+
|
580
|
+
context 'and is missing a semicolon' do
|
581
|
+
let(:scss) { <<-SCSS }
|
582
|
+
$foo: 1,
|
583
|
+
2 3
|
584
|
+
SCSS
|
585
|
+
|
586
|
+
it { should report_lint }
|
587
|
+
end
|
588
|
+
end
|
589
|
+
end
|
472
590
|
end
|
591
|
+
end
|
473
592
|
|
474
|
-
|
593
|
+
context 'when a variable declaration contains a map' do
|
594
|
+
context 'on a single line' do
|
475
595
|
context 'and ends with a semicolon' do
|
476
|
-
let(:scss) {
|
477
|
-
$foo: (
|
478
|
-
"a": (
|
479
|
-
"b",
|
480
|
-
"c"
|
481
|
-
)
|
482
|
-
);
|
483
|
-
SCSS
|
596
|
+
let(:scss) { '$foo: ("a": ("b": "c"));' }
|
484
597
|
|
485
598
|
it { should_not report_lint }
|
486
599
|
end
|
487
600
|
|
488
601
|
context 'and is missing a semicolon' do
|
489
|
-
let(:scss) {
|
490
|
-
$foo: (
|
491
|
-
"a": (
|
492
|
-
"b",
|
493
|
-
"c"
|
494
|
-
)
|
495
|
-
)
|
496
|
-
SCSS
|
602
|
+
let(:scss) { '$foo: ("a": ("b": "c"))' }
|
497
603
|
|
498
604
|
it { should report_lint }
|
499
605
|
end
|
500
606
|
end
|
607
|
+
|
608
|
+
context 'over multiple lines' do
|
609
|
+
context 'with a trailing comma' do
|
610
|
+
context 'and ends with a semicolon' do
|
611
|
+
let(:scss) { "$foo: (\n one: 1,\ntwo: 2,\n);" }
|
612
|
+
|
613
|
+
it { should_not report_lint }
|
614
|
+
end
|
615
|
+
|
616
|
+
context 'and is missing a semicolon' do
|
617
|
+
let(:scss) { "$foo: (\n one: 1,\ntwo: 2,\n)" }
|
618
|
+
|
619
|
+
it { should report_lint }
|
620
|
+
end
|
621
|
+
end
|
622
|
+
|
623
|
+
context 'without a trailing comma' do
|
624
|
+
context 'and ends with a semicolon' do
|
625
|
+
let(:scss) { "$foo: (\n one: 1,\ntwo: 2\n);" }
|
626
|
+
|
627
|
+
it { should_not report_lint }
|
628
|
+
end
|
629
|
+
|
630
|
+
context 'and is missing a semicolon' do
|
631
|
+
let(:scss) { "$foo: (\n one: 1,\ntwo: 2\n)" }
|
632
|
+
|
633
|
+
it { should report_lint }
|
634
|
+
end
|
635
|
+
end
|
636
|
+
|
637
|
+
context 'and a nested list' do
|
638
|
+
context 'and ends with a semicolon' do
|
639
|
+
let(:scss) { <<-SCSS }
|
640
|
+
$foo: (
|
641
|
+
"a": (
|
642
|
+
"b",
|
643
|
+
"c"
|
644
|
+
)
|
645
|
+
);
|
646
|
+
SCSS
|
647
|
+
|
648
|
+
it { should_not report_lint }
|
649
|
+
end
|
650
|
+
|
651
|
+
context 'and is missing a semicolon' do
|
652
|
+
let(:scss) { <<-SCSS }
|
653
|
+
$foo: (
|
654
|
+
"a": (
|
655
|
+
"b",
|
656
|
+
"c"
|
657
|
+
)
|
658
|
+
)
|
659
|
+
SCSS
|
660
|
+
|
661
|
+
it { should report_lint }
|
662
|
+
end
|
663
|
+
end
|
664
|
+
end
|
501
665
|
end
|
502
666
|
|
503
667
|
context 'with an @extend directive' do
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module SCSSLint
|
4
4
|
describe Plugins do
|
5
|
-
let(:subject) { described_class.new(Config.new(config_options)) }
|
5
|
+
let(:subject) { described_class.new(Config.new(config_options, Config.user_file)) }
|
6
6
|
|
7
7
|
describe '#load' do
|
8
8
|
context 'when gem plugins are specified' do
|
@@ -22,9 +22,10 @@ module SCSSLint
|
|
22
22
|
context 'when directory plugins are specified' do
|
23
23
|
let(:config_options) { { 'plugin_directories' => ['some_dir'] } }
|
24
24
|
let(:plugin) { double(load: nil) }
|
25
|
+
let(:plugin_dir) { File.join(File.dirname(Config.user_file), 'some_dir') }
|
25
26
|
|
26
27
|
before do
|
27
|
-
Plugins::LinterDir.stub(:new).with(
|
28
|
+
Plugins::LinterDir.stub(:new).with(plugin_dir).and_return(plugin)
|
28
29
|
end
|
29
30
|
|
30
31
|
it 'loads the plugin' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scss_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.45.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brigade Engineering
|
@@ -9,22 +9,28 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.9'
|
21
|
+
- - "<"
|
19
22
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
23
|
+
version: '11'
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
|
-
- - "
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0.9'
|
31
|
+
- - "<"
|
26
32
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
33
|
+
version: '11'
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: sass
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,6 +132,7 @@ files:
|
|
126
132
|
- lib/scss_lint/linter/space_after_comma.rb
|
127
133
|
- lib/scss_lint/linter/space_after_property_colon.rb
|
128
134
|
- lib/scss_lint/linter/space_after_property_name.rb
|
135
|
+
- lib/scss_lint/linter/space_after_variable_colon.rb
|
129
136
|
- lib/scss_lint/linter/space_after_variable_name.rb
|
130
137
|
- lib/scss_lint/linter/space_around_operator.rb
|
131
138
|
- lib/scss_lint/linter/space_before_brace.rb
|
@@ -210,6 +217,7 @@ files:
|
|
210
217
|
- spec/scss_lint/linter/space_after_comma_spec.rb
|
211
218
|
- spec/scss_lint/linter/space_after_property_colon_spec.rb
|
212
219
|
- spec/scss_lint/linter/space_after_property_name_spec.rb
|
220
|
+
- spec/scss_lint/linter/space_after_variable_colon_spec.rb
|
213
221
|
- spec/scss_lint/linter/space_after_variable_name_spec.rb
|
214
222
|
- spec/scss_lint/linter/space_around_operator_spec.rb
|
215
223
|
- spec/scss_lint/linter/space_before_brace_spec.rb
|
@@ -320,6 +328,7 @@ test_files:
|
|
320
328
|
- spec/scss_lint/linter/space_after_comma_spec.rb
|
321
329
|
- spec/scss_lint/linter/space_after_property_colon_spec.rb
|
322
330
|
- spec/scss_lint/linter/space_after_property_name_spec.rb
|
331
|
+
- spec/scss_lint/linter/space_after_variable_colon_spec.rb
|
323
332
|
- spec/scss_lint/linter/space_after_variable_name_spec.rb
|
324
333
|
- spec/scss_lint/linter/space_around_operator_spec.rb
|
325
334
|
- spec/scss_lint/linter/space_before_brace_spec.rb
|