scss_lint 0.41.0 → 0.42.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +21 -0
- data/config/default.yml +1 -0
- data/lib/scss_lint/cli.rb +0 -4
- data/lib/scss_lint/config.rb +1 -1
- data/lib/scss_lint/engine.rb +8 -2
- data/lib/scss_lint/exceptions.rb +0 -4
- data/lib/scss_lint/file_finder.rb +1 -8
- data/lib/scss_lint/linter.rb +3 -3
- data/lib/scss_lint/linter/color_variable.rb +20 -0
- data/lib/scss_lint/linter/else_placement.rb +1 -0
- data/lib/scss_lint/linter/import_path.rb +2 -2
- data/lib/scss_lint/linter/name_format.rb +1 -1
- data/lib/scss_lint/linter/space_after_comma.rb +11 -2
- data/lib/scss_lint/linter/space_around_operator.rb +115 -59
- data/lib/scss_lint/linter/trailing_semicolon.rb +17 -3
- data/lib/scss_lint/linter/url_format.rb +3 -3
- data/lib/scss_lint/linter/variable_for_property.rb +8 -0
- data/lib/scss_lint/linter/vendor_prefix.rb +1 -1
- data/lib/scss_lint/rake_task.rb +6 -1
- data/lib/scss_lint/runner.rb +2 -2
- data/lib/scss_lint/sass/tree.rb +1 -1
- data/lib/scss_lint/selector_visitor.rb +4 -4
- data/lib/scss_lint/version.rb +1 -1
- data/spec/scss_lint/cli_spec.rb +0 -12
- data/spec/scss_lint/file_finder_spec.rb +2 -6
- data/spec/scss_lint/linter/color_variable_spec.rb +41 -1
- data/spec/scss_lint/linter/space_after_comma_spec.rb +891 -153
- data/spec/scss_lint/linter/space_around_operator_spec.rb +25 -0
- data/spec/scss_lint/linter/trailing_semicolon_spec.rb +50 -0
- data/spec/scss_lint/linter/variable_for_property_spec.rb +10 -0
- data/spec/scss_lint/rake_task_spec.rb +59 -10
- data/spec/scss_lint/reporter/clean_files_reporter_spec.rb +2 -2
- data/spec/scss_lint/reporter/default_reporter_spec.rb +3 -3
- data/spec/scss_lint/reporter/files_reporter_spec.rb +1 -1
- metadata +3 -2
@@ -8,7 +8,7 @@ module SCSSLint
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def visit_variable(node)
|
11
|
-
check_semicolon(node)
|
11
|
+
check_semicolon(node.expr)
|
12
12
|
end
|
13
13
|
|
14
14
|
def visit_prop(node)
|
@@ -52,12 +52,26 @@ module SCSSLint
|
|
52
52
|
|
53
53
|
# Checks that the node is ended by a semicolon (with no whitespace)
|
54
54
|
def ends_with_semicolon?(node)
|
55
|
-
|
55
|
+
semicolon_after_parenthesis?(node) ||
|
56
|
+
# Otherwise just check for a semicolon
|
57
|
+
source_from_range(node.source_range) =~ /;(\s*})?$/
|
58
|
+
end
|
59
|
+
|
60
|
+
# Special case: Sass doesn't include the semicolon after an expression
|
61
|
+
# in the source range it reports, so we need a helper to check after the
|
62
|
+
# reported range.
|
63
|
+
def semicolon_after_parenthesis?(node)
|
64
|
+
last_char = character_at(node.source_range.end_pos)
|
65
|
+
char_after = character_at(node.source_range.end_pos, 1)
|
66
|
+
(last_char == ')' && char_after == ';') ||
|
67
|
+
([last_char, char_after].include?("\n") &&
|
68
|
+
engine.lines[node.source_range.end_pos.line] =~ /\);(\s*})?$/)
|
56
69
|
end
|
57
70
|
|
58
71
|
def ends_with_multiple_semicolons?(node)
|
59
72
|
# Look one character past the end to see if there's another semicolon
|
60
|
-
character_at(node.source_range.end_pos
|
73
|
+
character_at(node.source_range.end_pos) == ';' &&
|
74
|
+
character_at(node.source_range.end_pos, 1) == ';'
|
61
75
|
end
|
62
76
|
|
63
77
|
def has_space_before_semicolon?(node)
|
@@ -18,7 +18,7 @@ module SCSSLint
|
|
18
18
|
|
19
19
|
def visit_prop(node)
|
20
20
|
if url_literal?(node.value)
|
21
|
-
url = node.value.to_sass.
|
21
|
+
url = node.value.to_sass.sub(/^url\((.*)\)$/, '\\1')
|
22
22
|
check_url(url, node)
|
23
23
|
end
|
24
24
|
|
@@ -32,7 +32,7 @@ module SCSSLint
|
|
32
32
|
return unless prop_value.value.is_a?(Sass::Script::Value::String)
|
33
33
|
return unless prop_value.value.type == :identifier
|
34
34
|
|
35
|
-
prop_value.to_sass.
|
35
|
+
prop_value.to_sass.start_with?('url(')
|
36
36
|
end
|
37
37
|
|
38
38
|
def url_string?(arg)
|
@@ -43,7 +43,7 @@ module SCSSLint
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def check_url(url, node)
|
46
|
-
return if url.
|
46
|
+
return if url.start_with?('data:')
|
47
47
|
uri = URI(url)
|
48
48
|
|
49
49
|
if uri.scheme || uri.host
|
@@ -15,6 +15,7 @@ module SCSSLint
|
|
15
15
|
return unless @properties.include?(property_name)
|
16
16
|
return if ignored_value?(node.value)
|
17
17
|
return if node.children.first.is_a?(Sass::Script::Tree::Variable)
|
18
|
+
return if variable_property_with_important?(node.value)
|
18
19
|
|
19
20
|
add_lint(node, "Property #{property_name} should use " \
|
20
21
|
'a variable rather than a literal value')
|
@@ -22,6 +23,13 @@ module SCSSLint
|
|
22
23
|
|
23
24
|
private
|
24
25
|
|
26
|
+
def variable_property_with_important?(value)
|
27
|
+
value.is_a?(Sass::Script::Tree::ListLiteral) &&
|
28
|
+
value.children.length == 2 &&
|
29
|
+
value.children.first.is_a?(Sass::Script::Tree::Variable) &&
|
30
|
+
value.children.last.value.value == '!important'
|
31
|
+
end
|
32
|
+
|
25
33
|
def ignored_value?(value)
|
26
34
|
value.respond_to?(:value) &&
|
27
35
|
IGNORED_VALUES.include?(value.value.to_s)
|
@@ -13,7 +13,7 @@ module SCSSLint
|
|
13
13
|
def check_node(node)
|
14
14
|
name = node.name.is_a?(Array) ? node.name.join : node.name
|
15
15
|
# Ignore '@' from @keyframes node name
|
16
|
-
check_identifier(node, name.
|
16
|
+
check_identifier(node, name.sub(/^@/, ''))
|
17
17
|
|
18
18
|
# Check for values
|
19
19
|
return unless node.respond_to?(:value) && node.value.respond_to?(:source_range)
|
data/lib/scss_lint/rake_task.rb
CHANGED
@@ -31,6 +31,10 @@ module SCSSLint
|
|
31
31
|
# @return [String]
|
32
32
|
attr_accessor :config
|
33
33
|
|
34
|
+
# Command-line args to use.
|
35
|
+
# @return [Array<String>]
|
36
|
+
attr_accessor :args
|
37
|
+
|
34
38
|
# List of files to lint (can contain shell globs).
|
35
39
|
#
|
36
40
|
# Note that this will be ignored if you explicitly pass a list of files as
|
@@ -67,7 +71,7 @@ module SCSSLint
|
|
67
71
|
def run_cli(task_args)
|
68
72
|
cli_args = ['--config', config] if config
|
69
73
|
|
70
|
-
result = SCSSLint::CLI.new.run(Array(cli_args) + files_to_lint(task_args))
|
74
|
+
result = SCSSLint::CLI.new.run(Array(cli_args) + Array(args) + files_to_lint(task_args))
|
71
75
|
|
72
76
|
message =
|
73
77
|
case result
|
@@ -98,6 +102,7 @@ module SCSSLint
|
|
98
102
|
def default_description
|
99
103
|
description = 'Run `scss-lint'
|
100
104
|
description += " --config #{config}" if config
|
105
|
+
description += " #{args}" if args
|
101
106
|
description += " #{files.join(' ')}" if files.any?
|
102
107
|
description += ' [files...]`'
|
103
108
|
description
|
data/lib/scss_lint/runner.rb
CHANGED
@@ -8,7 +8,8 @@ module SCSSLint
|
|
8
8
|
def initialize(config)
|
9
9
|
@config = config
|
10
10
|
@lints = []
|
11
|
-
@linters = LinterRegistry.linters.
|
11
|
+
@linters = LinterRegistry.linters.select { |linter| @config.linter_enabled?(linter) }
|
12
|
+
@linters.map!(&:new)
|
12
13
|
end
|
13
14
|
|
14
15
|
# @param files [Array]
|
@@ -44,7 +45,6 @@ module SCSSLint
|
|
44
45
|
|
45
46
|
# For stubbing in tests.
|
46
47
|
def run_linter(linter, engine, file)
|
47
|
-
return unless @config.linter_enabled?(linter)
|
48
48
|
return if @config.excluded_file_for_linter?(file, linter)
|
49
49
|
@lints += linter.run(engine, @config.linter_options(linter))
|
50
50
|
end
|
data/lib/scss_lint/sass/tree.rb
CHANGED
@@ -25,10 +25,10 @@ module SCSSLint
|
|
25
25
|
def selector_node_name(node)
|
26
26
|
# Converts the class name of a node into snake_case form, e.g.
|
27
27
|
# `Sass::Selector::SimpleSequence` -> `simple_sequence`
|
28
|
-
node.class.name.gsub(/.*::(.*?)$/, '\\1')
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
name = node.class.name.gsub(/.*::(.*?)$/, '\\1')
|
29
|
+
name.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
30
|
+
name.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
31
|
+
name.downcase!
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/lib/scss_lint/version.rb
CHANGED
data/spec/scss_lint/cli_spec.rb
CHANGED
@@ -166,18 +166,6 @@ describe SCSSLint::CLI do
|
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
169
|
-
context 'when all specified SCSS files are filtered by exclusions' do
|
170
|
-
before do
|
171
|
-
SCSSLint::FileFinder.any_instance.stub(:find)
|
172
|
-
.and_raise(SCSSLint::Exceptions::AllFilesFilteredError)
|
173
|
-
end
|
174
|
-
|
175
|
-
it 'exits with an appropriate status code' do
|
176
|
-
subject.should_receive(:halt).with(:files_filtered)
|
177
|
-
safe_run
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
169
|
context 'when a config file is specified' do
|
182
170
|
let(:flags) { ['--config', 'custom_config.yml'] }
|
183
171
|
|
@@ -76,9 +76,7 @@ describe SCSSLint::FileFinder do
|
|
76
76
|
config.exclude_file('some-dir/test.scss')
|
77
77
|
end
|
78
78
|
|
79
|
-
it
|
80
|
-
expect { subject }.to raise_error SCSSLint::Exceptions::AllFilesFilteredError
|
81
|
-
end
|
79
|
+
it { should == [] }
|
82
80
|
end
|
83
81
|
end
|
84
82
|
|
@@ -103,9 +101,7 @@ describe SCSSLint::FileFinder do
|
|
103
101
|
config.exclude_file('**/*.scss')
|
104
102
|
end
|
105
103
|
|
106
|
-
it
|
107
|
-
expect { subject }.to raise_error SCSSLint::Exceptions::AllFilesFilteredError
|
108
|
-
end
|
104
|
+
it { should == [] }
|
109
105
|
end
|
110
106
|
end
|
111
107
|
|
@@ -127,7 +127,7 @@ describe SCSSLint::Linter::ColorVariable do
|
|
127
127
|
}
|
128
128
|
SCSS
|
129
129
|
|
130
|
-
it {
|
130
|
+
it { should report_lint line: 2 }
|
131
131
|
end
|
132
132
|
|
133
133
|
context 'when a color literal is used in a map declaration' do
|
@@ -164,4 +164,44 @@ describe SCSSLint::Linter::ColorVariable do
|
|
164
164
|
|
165
165
|
it { should_not report_lint }
|
166
166
|
end
|
167
|
+
|
168
|
+
context 'when a color function containing literals is used in a property' do
|
169
|
+
let(:scss) { <<-SCSS }
|
170
|
+
p {
|
171
|
+
color: rgb(0, 100, 200);
|
172
|
+
}
|
173
|
+
a {
|
174
|
+
color: rgb(0%, 50%, 80%);
|
175
|
+
}
|
176
|
+
i {
|
177
|
+
color: rgba(0, 0, 0, .5);
|
178
|
+
}
|
179
|
+
span {
|
180
|
+
color: hsl(0, 100%, 50%);
|
181
|
+
}
|
182
|
+
.class {
|
183
|
+
color: hsla(0, 100%, 50%, .5);
|
184
|
+
}
|
185
|
+
SCSS
|
186
|
+
|
187
|
+
it { should report_lint line: 2 }
|
188
|
+
it { should report_lint line: 5 }
|
189
|
+
it { should report_lint line: 8 }
|
190
|
+
it { should report_lint line: 11 }
|
191
|
+
it { should report_lint line: 14 }
|
192
|
+
end
|
193
|
+
|
194
|
+
context 'when transforming a variable value in a function call' do
|
195
|
+
let(:scss) { <<-SCSS }
|
196
|
+
p {
|
197
|
+
color: rgba($red, .5);
|
198
|
+
}
|
199
|
+
|
200
|
+
a {
|
201
|
+
color: lighten($red, 5%);
|
202
|
+
}
|
203
|
+
SCSS
|
204
|
+
|
205
|
+
it { should_not report_lint }
|
206
|
+
end
|
167
207
|
end
|
@@ -1,119 +1,856 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SCSSLint::Linter::SpaceAfterComma do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
let(:linter_config) { { 'style' => style } }
|
5
|
+
|
6
|
+
context 'when one space is preferred' do
|
7
|
+
let(:style) { 'one_space' }
|
8
|
+
|
9
|
+
context 'in a mixin declaration' do
|
10
|
+
context 'where spaces do not follow commas' do
|
11
|
+
let(:scss) { <<-SCSS }
|
12
|
+
@mixin mixin($arg1,$arg2,$kwarg1: 'default',$kwarg2: 'default') {
|
13
|
+
}
|
14
|
+
SCSS
|
15
|
+
|
16
|
+
it { should report_lint count: 3 }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'where spaces follow commas' do
|
20
|
+
let(:scss) { <<-SCSS }
|
21
|
+
@mixin mixin($arg1, $arg2, $kwarg1: 'default', $kwarg2: 'default') {
|
22
|
+
}
|
23
|
+
SCSS
|
24
|
+
|
25
|
+
it { should_not report_lint }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'where spaces surround commas' do
|
29
|
+
let(:scss) { <<-SCSS }
|
30
|
+
@mixin mixin($arg1 , $arg2 , $kwarg1: 'default' , $kwarg2: 'default') {
|
31
|
+
}
|
32
|
+
SCSS
|
33
|
+
|
34
|
+
it { should_not report_lint }
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'where commas are followed by a newline' do
|
38
|
+
let(:scss) { <<-SCSS }
|
39
|
+
@mixin mixin($arg1,
|
40
|
+
$arg2,
|
41
|
+
$kwarg1: 'default',
|
42
|
+
$kwarg2: 'default') {
|
43
|
+
}
|
44
|
+
SCSS
|
45
|
+
|
46
|
+
it { should_not report_lint }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'definining a variable argument' do
|
50
|
+
context 'where spaces do not follow commas' do
|
51
|
+
let(:scss) { <<-SCSS }
|
52
|
+
@mixin mixin($arg,$args...) {
|
53
|
+
}
|
54
|
+
SCSS
|
55
|
+
|
56
|
+
it { should report_lint count: 1 }
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'where spaces follow commas' do
|
60
|
+
let(:scss) { <<-SCSS }
|
61
|
+
@mixin mixin($arg, $args...) {
|
62
|
+
}
|
63
|
+
SCSS
|
64
|
+
|
65
|
+
it { should_not report_lint }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'where spaces surround commas' do
|
69
|
+
let(:scss) { <<-SCSS }
|
70
|
+
@mixin mixin($arg , $args...) {
|
71
|
+
}
|
72
|
+
SCSS
|
73
|
+
|
74
|
+
it { should_not report_lint }
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'where commas are followed by a newline' do
|
78
|
+
let(:scss) { <<-SCSS }
|
79
|
+
@mixin mixin($arg,
|
80
|
+
$args...) {
|
81
|
+
}
|
82
|
+
SCSS
|
83
|
+
|
84
|
+
it { should_not report_lint }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'in a mixin inclusion' do
|
90
|
+
context 'where spaces do not follow commas' do
|
91
|
+
let(:scss) { <<-SCSS }
|
92
|
+
p {
|
93
|
+
@include mixin(1,2,3,$args...,$kwarg1: 4,$kwarg2: 5,$kwargs...);
|
94
|
+
}
|
95
|
+
SCSS
|
96
|
+
|
97
|
+
it { should report_lint count: 6 }
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'where spaces follow commas' do
|
101
|
+
let(:scss) { <<-SCSS }
|
102
|
+
p {
|
103
|
+
@include mixin(1, 2, 3, $args..., $kwarg1: 4, $kwarg2: 5, $kwargs...);
|
104
|
+
}
|
105
|
+
SCSS
|
106
|
+
|
107
|
+
it { should_not report_lint }
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'where spaces surround commas' do
|
111
|
+
let(:scss) { <<-SCSS }
|
112
|
+
p {
|
113
|
+
@include mixin(1 , 2 , 3 , $args... , $kwarg1: 4 , $kwarg2: 5 , $kwargs...);
|
114
|
+
}
|
115
|
+
SCSS
|
116
|
+
|
117
|
+
it { should_not report_lint }
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'where commas are followed by a newline' do
|
121
|
+
let(:scss) { <<-SCSS }
|
122
|
+
p {
|
123
|
+
@include mixin(1,
|
124
|
+
2,
|
125
|
+
3,
|
126
|
+
$args...,
|
127
|
+
$kwarg1: 4,
|
128
|
+
$kwarg2: 5,
|
129
|
+
$kwargs...);
|
130
|
+
}
|
131
|
+
SCSS
|
132
|
+
|
133
|
+
it { should_not report_lint }
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context 'in a function declaration' do
|
138
|
+
context 'where spaces do not follow commas' do
|
139
|
+
let(:scss) { <<-SCSS }
|
140
|
+
@function func($arg1,$arg2,$kwarg1: 'default',$kwarg2: 'default') {
|
141
|
+
}
|
142
|
+
SCSS
|
143
|
+
|
144
|
+
it { should report_lint count: 3 }
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'where spaces follow commas' do
|
148
|
+
let(:scss) { <<-SCSS }
|
149
|
+
@function func($arg1, $arg2, $kwarg1: 'default', $kwarg2: 'default') {
|
150
|
+
}
|
151
|
+
SCSS
|
152
|
+
|
153
|
+
it { should_not report_lint }
|
154
|
+
end
|
155
|
+
|
156
|
+
context 'where spaces surround commas' do
|
157
|
+
let(:scss) { <<-SCSS }
|
158
|
+
@function func($arg1 , $arg2 , $kwarg1: 'default' , $kwarg2: 'default') {
|
159
|
+
}
|
160
|
+
SCSS
|
161
|
+
|
162
|
+
it { should_not report_lint }
|
163
|
+
end
|
164
|
+
|
165
|
+
context 'where commas are followed by a newline' do
|
166
|
+
let(:scss) { <<-SCSS }
|
167
|
+
@function func($arg1,
|
168
|
+
$arg2,
|
169
|
+
$kwarg1: 'default',
|
170
|
+
$kwarg2: 'default') {
|
171
|
+
}
|
172
|
+
SCSS
|
173
|
+
|
174
|
+
it { should_not report_lint }
|
175
|
+
end
|
176
|
+
|
177
|
+
context 'definining a variable argument' do
|
178
|
+
context 'where spaces do not follow commas' do
|
179
|
+
let(:scss) { <<-SCSS }
|
180
|
+
@function func($arg,$args...) {
|
181
|
+
}
|
182
|
+
SCSS
|
183
|
+
|
184
|
+
it { should report_lint count: 1 }
|
185
|
+
end
|
186
|
+
|
187
|
+
context 'where spaces follow commas' do
|
188
|
+
let(:scss) { <<-SCSS }
|
189
|
+
@function func($arg, $args...) {
|
190
|
+
}
|
191
|
+
SCSS
|
192
|
+
|
193
|
+
it { should_not report_lint }
|
194
|
+
end
|
195
|
+
|
196
|
+
context 'where spaces surround commas' do
|
197
|
+
let(:scss) { <<-SCSS }
|
198
|
+
@function func($arg , $args...) {
|
199
|
+
}
|
200
|
+
SCSS
|
201
|
+
|
202
|
+
it { should_not report_lint }
|
203
|
+
end
|
204
|
+
|
205
|
+
context 'where commas are followed by a newline' do
|
206
|
+
let(:scss) { <<-SCSS }
|
207
|
+
@function func($arg,
|
208
|
+
$args...) {
|
209
|
+
}
|
210
|
+
SCSS
|
211
|
+
|
212
|
+
it { should_not report_lint }
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
context 'in a function invocation' do
|
218
|
+
context 'where spaces do not follow commas' do
|
219
|
+
let(:scss) { <<-SCSS }
|
220
|
+
p {
|
221
|
+
margin: func(1,2,3,$args...,$kwarg1: 4,$kwarg2: 5,$kwargs...);
|
222
|
+
}
|
223
|
+
SCSS
|
224
|
+
|
225
|
+
it { should report_lint count: 6 }
|
226
|
+
end
|
227
|
+
|
228
|
+
context 'where spaces follow commas' do
|
229
|
+
let(:scss) { <<-SCSS }
|
230
|
+
p {
|
231
|
+
margin: func(1, 2, 3, $args..., $kwarg1: 4, $kwarg2: 5, $kwargs...);
|
232
|
+
}
|
233
|
+
SCSS
|
234
|
+
|
235
|
+
it { should_not report_lint }
|
236
|
+
end
|
237
|
+
|
238
|
+
context 'where spaces surround commas' do
|
239
|
+
let(:scss) { <<-SCSS }
|
240
|
+
p {
|
241
|
+
margin: func(1 , 2 , 3 , $args... , $kwarg1: 4 , $kwarg2: 5 , $kwargs...);
|
242
|
+
}
|
243
|
+
SCSS
|
244
|
+
|
245
|
+
it { should_not report_lint }
|
246
|
+
end
|
247
|
+
|
248
|
+
context 'where commas are followed by a newline' do
|
249
|
+
let(:scss) { <<-SCSS }
|
250
|
+
p {
|
251
|
+
margin: func(1,
|
252
|
+
2,
|
253
|
+
3,
|
254
|
+
$args...,
|
255
|
+
$kwarg1: 4,
|
256
|
+
$kwarg2: 5,
|
257
|
+
$kwargs...);
|
258
|
+
}
|
259
|
+
SCSS
|
260
|
+
|
261
|
+
it { should_not report_lint }
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
context 'in a comma-separated literal list' do
|
266
|
+
context 'where spaces do not follow commas' do
|
267
|
+
let(:scss) { <<-SCSS }
|
268
|
+
p {
|
269
|
+
property: $a,$b,$c,$d;
|
270
|
+
}
|
271
|
+
SCSS
|
272
|
+
|
273
|
+
it { should report_lint count: 3 }
|
274
|
+
end
|
275
|
+
|
276
|
+
context 'where spaces follow commas' do
|
277
|
+
let(:scss) { <<-SCSS }
|
278
|
+
p {
|
279
|
+
property: $a, $b, $c, $d;
|
280
|
+
}
|
281
|
+
SCSS
|
282
|
+
|
283
|
+
it { should_not report_lint }
|
284
|
+
end
|
285
|
+
|
286
|
+
context 'where spaces surround commas' do
|
287
|
+
let(:scss) { <<-SCSS }
|
288
|
+
p {
|
289
|
+
property: $a , $b , $c , $d;
|
290
|
+
}
|
291
|
+
SCSS
|
292
|
+
|
293
|
+
it { should_not report_lint }
|
294
|
+
end
|
295
|
+
|
296
|
+
context 'where commas are followed by a newline' do
|
297
|
+
let(:scss) { <<-SCSS }
|
298
|
+
p {
|
299
|
+
property: $a,
|
300
|
+
$b,
|
301
|
+
$c,
|
302
|
+
$d;
|
303
|
+
}
|
304
|
+
SCSS
|
305
|
+
|
306
|
+
it { should_not report_lint }
|
307
|
+
end
|
308
|
+
|
309
|
+
context 'when commas are followed by a space and a newline' do
|
310
|
+
let(:scss) { <<-SCSS }
|
311
|
+
p {
|
312
|
+
property: $a,\s
|
313
|
+
$b;
|
314
|
+
}
|
315
|
+
SCSS
|
316
|
+
|
317
|
+
it { should_not report_lint }
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
context 'when declaring list variables' do
|
322
|
+
context 'and one argument does not have a trailing comma' do
|
323
|
+
let(:scss) { <<-SCSS }
|
324
|
+
$z-list: (
|
325
|
+
(
|
326
|
+
name1
|
327
|
+
),
|
328
|
+
(
|
329
|
+
name2,
|
330
|
+
)
|
331
|
+
);
|
332
|
+
SCSS
|
333
|
+
|
334
|
+
it { should_not report_lint }
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
context 'when more than one space is preferred' do
|
340
|
+
let(:style) { 'at_least_one_space' }
|
341
|
+
|
342
|
+
context 'in a mixin declaration' do
|
343
|
+
context 'where spaces do not follow commas' do
|
344
|
+
let(:scss) { <<-SCSS }
|
7
345
|
@mixin mixin($arg1,$arg2,$kwarg1: 'default',$kwarg2: 'default') {
|
8
346
|
}
|
9
|
-
|
347
|
+
SCSS
|
348
|
+
|
349
|
+
it { should report_lint count: 3 }
|
350
|
+
end
|
351
|
+
|
352
|
+
context 'where one space follows commas' do
|
353
|
+
let(:scss) { <<-SCSS }
|
354
|
+
@mixin mixin($arg1, $arg2, $kwarg1: 'default', $kwarg2: 'default') {
|
355
|
+
}
|
356
|
+
SCSS
|
357
|
+
|
358
|
+
it { should_not report_lint }
|
359
|
+
end
|
360
|
+
|
361
|
+
context 'where more than one space follows commas' do
|
362
|
+
let(:scss) { <<-SCSS }
|
363
|
+
@mixin mixin($arg1, $arg2, $kwarg1: 'default') {
|
364
|
+
}
|
365
|
+
SCSS
|
366
|
+
|
367
|
+
it { should_not report_lint }
|
368
|
+
end
|
369
|
+
|
370
|
+
context 'where spaces surround commas' do
|
371
|
+
let(:scss) { <<-SCSS }
|
372
|
+
@mixin mixin($arg1 , $arg2 , $kwarg1: 'default' , $kwarg2: 'default') {
|
373
|
+
}
|
374
|
+
SCSS
|
375
|
+
|
376
|
+
it { should_not report_lint }
|
377
|
+
end
|
378
|
+
|
379
|
+
context 'where commas are followed by a newline' do
|
380
|
+
let(:scss) { <<-SCSS }
|
381
|
+
@mixin mixin($arg1,
|
382
|
+
$arg2,
|
383
|
+
$kwarg1: 'default',
|
384
|
+
$kwarg2: 'default') {
|
385
|
+
}
|
386
|
+
SCSS
|
387
|
+
|
388
|
+
it { should_not report_lint }
|
389
|
+
end
|
390
|
+
|
391
|
+
context 'definining a variable argument' do
|
392
|
+
context 'where spaces do not follow commas' do
|
393
|
+
let(:scss) { <<-SCSS }
|
394
|
+
@mixin mixin($arg,$args...) {
|
395
|
+
}
|
396
|
+
SCSS
|
397
|
+
|
398
|
+
it { should report_lint count: 1 }
|
399
|
+
end
|
400
|
+
|
401
|
+
context 'where spaces follow commas' do
|
402
|
+
let(:scss) { <<-SCSS }
|
403
|
+
@mixin mixin($arg, $args...) {
|
404
|
+
}
|
405
|
+
SCSS
|
406
|
+
|
407
|
+
it { should_not report_lint }
|
408
|
+
end
|
409
|
+
|
410
|
+
context 'where multiple spaces follow commas' do
|
411
|
+
let(:scss) { <<-SCSS }
|
412
|
+
@mixin mixin($arg, $args...) {
|
413
|
+
}
|
414
|
+
SCSS
|
415
|
+
|
416
|
+
it { should_not report_lint }
|
417
|
+
end
|
418
|
+
|
419
|
+
context 'where spaces surround commas' do
|
420
|
+
let(:scss) { <<-SCSS }
|
421
|
+
@mixin mixin($arg , $args...) {
|
422
|
+
}
|
423
|
+
SCSS
|
424
|
+
|
425
|
+
it { should_not report_lint }
|
426
|
+
end
|
427
|
+
|
428
|
+
context 'where commas are followed by a newline' do
|
429
|
+
let(:scss) { <<-SCSS }
|
430
|
+
@mixin mixin($arg,
|
431
|
+
$args...) {
|
432
|
+
}
|
433
|
+
SCSS
|
434
|
+
|
435
|
+
it { should_not report_lint }
|
436
|
+
end
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
context 'in a mixin inclusion' do
|
441
|
+
context 'where spaces do not follow commas' do
|
442
|
+
let(:scss) { <<-SCSS }
|
443
|
+
p {
|
444
|
+
@include mixin(1,2,3,$args...,$kwarg1: 4,$kwarg2: 5,$kwargs...);
|
445
|
+
}
|
446
|
+
SCSS
|
447
|
+
|
448
|
+
it { should report_lint count: 6 }
|
449
|
+
end
|
450
|
+
|
451
|
+
context 'where spaces follow commas' do
|
452
|
+
let(:scss) { <<-SCSS }
|
453
|
+
p {
|
454
|
+
@include mixin(1, 2, 3, $args..., $kwarg1: 4, $kwarg2: 5, $kwargs...);
|
455
|
+
}
|
456
|
+
SCSS
|
457
|
+
|
458
|
+
it { should_not report_lint }
|
459
|
+
end
|
460
|
+
|
461
|
+
context 'where multiple spaces follow commas' do
|
462
|
+
let(:scss) { <<-SCSS }
|
463
|
+
p {
|
464
|
+
@include mixin(1, 2, 3, $args..., $kwarg1: 4, $kwargs...);
|
465
|
+
}
|
466
|
+
SCSS
|
467
|
+
|
468
|
+
it { should_not report_lint }
|
469
|
+
end
|
470
|
+
|
471
|
+
context 'where spaces surround commas' do
|
472
|
+
let(:scss) { <<-SCSS }
|
473
|
+
p {
|
474
|
+
@include mixin(1 , 2 , 3 , $args... , $kwarg1: 4 , $kwarg2: 5 , $kwargs...);
|
475
|
+
}
|
476
|
+
SCSS
|
477
|
+
|
478
|
+
it { should_not report_lint }
|
479
|
+
end
|
480
|
+
|
481
|
+
context 'where commas are followed by a newline' do
|
482
|
+
let(:scss) { <<-SCSS }
|
483
|
+
p {
|
484
|
+
@include mixin(1,
|
485
|
+
2,
|
486
|
+
3,
|
487
|
+
$args...,
|
488
|
+
$kwarg1: 4,
|
489
|
+
$kwarg2: 5,
|
490
|
+
$kwargs...);
|
491
|
+
}
|
492
|
+
SCSS
|
493
|
+
|
494
|
+
it { should_not report_lint }
|
495
|
+
end
|
496
|
+
end
|
497
|
+
|
498
|
+
context 'in a function declaration' do
|
499
|
+
context 'where spaces do not follow commas' do
|
500
|
+
let(:scss) { <<-SCSS }
|
501
|
+
@function func($arg1,$arg2,$kwarg1: 'default',$kwarg2: 'default') {
|
502
|
+
}
|
503
|
+
SCSS
|
504
|
+
|
505
|
+
it { should report_lint count: 3 }
|
506
|
+
end
|
507
|
+
|
508
|
+
context 'where spaces follow commas' do
|
509
|
+
let(:scss) { <<-SCSS }
|
510
|
+
@function func($arg1, $arg2, $kwarg1: 'default', $kwarg2: 'default') {
|
511
|
+
}
|
512
|
+
SCSS
|
513
|
+
|
514
|
+
it { should_not report_lint }
|
515
|
+
end
|
516
|
+
|
517
|
+
context 'where multiple spaces follow commas' do
|
518
|
+
let(:scss) { <<-SCSS }
|
519
|
+
@function func($arg1, $kwarg1: 'default', $kwarg2: 'default') {
|
520
|
+
}
|
521
|
+
SCSS
|
522
|
+
|
523
|
+
it { should_not report_lint }
|
524
|
+
end
|
525
|
+
|
526
|
+
context 'where spaces surround commas' do
|
527
|
+
let(:scss) { <<-SCSS }
|
528
|
+
@function func($arg1 , $arg2 , $kwarg1: 'default' , $kwarg2: 'default') {
|
529
|
+
}
|
530
|
+
SCSS
|
531
|
+
|
532
|
+
it { should_not report_lint }
|
533
|
+
end
|
534
|
+
|
535
|
+
context 'where commas are followed by a newline' do
|
536
|
+
let(:scss) { <<-SCSS }
|
537
|
+
@function func($arg1,
|
538
|
+
$arg2,
|
539
|
+
$kwarg1: 'default',
|
540
|
+
$kwarg2: 'default') {
|
541
|
+
}
|
542
|
+
SCSS
|
543
|
+
|
544
|
+
it { should_not report_lint }
|
545
|
+
end
|
546
|
+
|
547
|
+
context 'definining a variable argument' do
|
548
|
+
context 'where spaces do not follow commas' do
|
549
|
+
let(:scss) { <<-SCSS }
|
550
|
+
@function func($arg,$args...) {
|
551
|
+
}
|
552
|
+
SCSS
|
553
|
+
|
554
|
+
it { should report_lint count: 1 }
|
555
|
+
end
|
556
|
+
|
557
|
+
context 'where spaces follow commas' do
|
558
|
+
let(:scss) { <<-SCSS }
|
559
|
+
@function func($arg, $args...) {
|
560
|
+
}
|
561
|
+
SCSS
|
562
|
+
|
563
|
+
it { should_not report_lint }
|
564
|
+
end
|
565
|
+
|
566
|
+
context 'where multiple spaces follow commas' do
|
567
|
+
let(:scss) { <<-SCSS }
|
568
|
+
@function func($arg, $args...) {
|
569
|
+
}
|
570
|
+
SCSS
|
571
|
+
|
572
|
+
it { should_not report_lint }
|
573
|
+
end
|
574
|
+
|
575
|
+
context 'where spaces surround commas' do
|
576
|
+
let(:scss) { <<-SCSS }
|
577
|
+
@function func($arg , $args...) {
|
578
|
+
}
|
579
|
+
SCSS
|
580
|
+
|
581
|
+
it { should_not report_lint }
|
582
|
+
end
|
583
|
+
|
584
|
+
context 'where commas are followed by a newline' do
|
585
|
+
let(:scss) { <<-SCSS }
|
586
|
+
@function func($arg,
|
587
|
+
$args...) {
|
588
|
+
}
|
589
|
+
SCSS
|
590
|
+
|
591
|
+
it { should_not report_lint }
|
592
|
+
end
|
593
|
+
end
|
594
|
+
end
|
595
|
+
|
596
|
+
context 'in a function invocation' do
|
597
|
+
context 'where spaces do not follow commas' do
|
598
|
+
let(:scss) { <<-SCSS }
|
599
|
+
p {
|
600
|
+
margin: func(1,2,3,$args...,$kwarg1: 4,$kwarg2: 5,$kwargs...);
|
601
|
+
}
|
602
|
+
SCSS
|
603
|
+
|
604
|
+
it { should report_lint count: 6 }
|
605
|
+
end
|
606
|
+
|
607
|
+
context 'where spaces follow commas' do
|
608
|
+
let(:scss) { <<-SCSS }
|
609
|
+
p {
|
610
|
+
margin: func(1, 2, 3, $args..., $kwarg1: 4, $kwarg2: 5, $kwargs...);
|
611
|
+
}
|
612
|
+
SCSS
|
613
|
+
|
614
|
+
it { should_not report_lint }
|
615
|
+
end
|
616
|
+
|
617
|
+
context 'where multiple spaces follow commas' do
|
618
|
+
let(:scss) { <<-SCSS }
|
619
|
+
p {
|
620
|
+
margin: func(1, $args..., $kwarg1: 4, $kwargs...);
|
621
|
+
}
|
622
|
+
SCSS
|
623
|
+
|
624
|
+
it { should_not report_lint }
|
625
|
+
end
|
626
|
+
|
627
|
+
context 'where spaces surround commas' do
|
628
|
+
let(:scss) { <<-SCSS }
|
629
|
+
p {
|
630
|
+
margin: func(1 , 2 , 3 , $args... , $kwarg1: 4 , $kwarg2: 5 , $kwargs...);
|
631
|
+
}
|
632
|
+
SCSS
|
10
633
|
|
11
|
-
|
12
|
-
|
634
|
+
it { should_not report_lint }
|
635
|
+
end
|
13
636
|
|
14
|
-
|
15
|
-
|
16
|
-
|
637
|
+
context 'where commas are followed by a newline' do
|
638
|
+
let(:scss) { <<-SCSS }
|
639
|
+
p {
|
640
|
+
margin: func(1,
|
641
|
+
2,
|
642
|
+
3,
|
643
|
+
$args...,
|
644
|
+
$kwarg1: 4,
|
645
|
+
$kwarg2: 5,
|
646
|
+
$kwargs...);
|
17
647
|
}
|
18
|
-
|
648
|
+
SCSS
|
19
649
|
|
20
|
-
|
650
|
+
it { should_not report_lint }
|
651
|
+
end
|
21
652
|
end
|
22
653
|
|
23
|
-
context '
|
24
|
-
|
25
|
-
|
654
|
+
context 'in a comma-separated literal list' do
|
655
|
+
context 'where spaces do not follow commas' do
|
656
|
+
let(:scss) { <<-SCSS }
|
657
|
+
p {
|
658
|
+
property: $a,$b,$c,$d;
|
26
659
|
}
|
27
|
-
|
660
|
+
SCSS
|
28
661
|
|
29
|
-
|
30
|
-
|
662
|
+
it { should report_lint count: 3 }
|
663
|
+
end
|
31
664
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
665
|
+
context 'where spaces follow commas' do
|
666
|
+
let(:scss) { <<-SCSS }
|
667
|
+
p {
|
668
|
+
property: $a, $b, $c, $d;
|
669
|
+
}
|
670
|
+
SCSS
|
671
|
+
|
672
|
+
it { should_not report_lint }
|
673
|
+
end
|
674
|
+
|
675
|
+
context 'where multiple spaces follow commas' do
|
676
|
+
let(:scss) { <<-SCSS }
|
677
|
+
p {
|
678
|
+
property: $a, $b, $c, $d;
|
679
|
+
}
|
680
|
+
SCSS
|
681
|
+
|
682
|
+
it { should_not report_lint }
|
683
|
+
end
|
684
|
+
|
685
|
+
context 'where spaces surround commas' do
|
686
|
+
let(:scss) { <<-SCSS }
|
687
|
+
p {
|
688
|
+
property: $a , $b , $c , $d;
|
689
|
+
}
|
690
|
+
SCSS
|
691
|
+
|
692
|
+
it { should_not report_lint }
|
693
|
+
end
|
694
|
+
|
695
|
+
context 'where commas are followed by a newline' do
|
696
|
+
let(:scss) { <<-SCSS }
|
697
|
+
p {
|
698
|
+
property: $a,
|
699
|
+
$b,
|
700
|
+
$c,
|
701
|
+
$d;
|
702
|
+
}
|
703
|
+
SCSS
|
704
|
+
|
705
|
+
it { should_not report_lint }
|
706
|
+
end
|
707
|
+
|
708
|
+
context 'when commas are followed by a space and a newline' do
|
709
|
+
let(:scss) { <<-SCSS }
|
710
|
+
p {
|
711
|
+
property: $a,\s
|
712
|
+
$b;
|
38
713
|
}
|
39
|
-
|
714
|
+
SCSS
|
715
|
+
|
716
|
+
it { should_not report_lint }
|
717
|
+
end
|
718
|
+
end
|
719
|
+
|
720
|
+
context 'when declaring list variables' do
|
721
|
+
context 'and one argument does not have a trailing comma' do
|
722
|
+
let(:scss) { <<-SCSS }
|
723
|
+
$z-list: (
|
724
|
+
(
|
725
|
+
name1
|
726
|
+
),
|
727
|
+
(
|
728
|
+
name2,
|
729
|
+
)
|
730
|
+
);
|
731
|
+
SCSS
|
40
732
|
|
41
|
-
|
733
|
+
it { should_not report_lint }
|
734
|
+
end
|
42
735
|
end
|
736
|
+
end
|
737
|
+
|
738
|
+
context 'when no space is preferred' do
|
739
|
+
let(:style) { 'no_space' }
|
43
740
|
|
44
|
-
context '
|
741
|
+
context 'in a mixin declaration' do
|
45
742
|
context 'where spaces do not follow commas' do
|
46
743
|
let(:scss) { <<-SCSS }
|
47
|
-
|
48
|
-
|
744
|
+
@mixin mixin($arg1,$arg2,$kwarg1: 'default',$kwarg2: 'default') {
|
745
|
+
}
|
49
746
|
SCSS
|
50
747
|
|
51
|
-
it {
|
748
|
+
it { should_not report_lint }
|
52
749
|
end
|
53
750
|
|
54
751
|
context 'where spaces follow commas' do
|
55
752
|
let(:scss) { <<-SCSS }
|
56
|
-
|
57
|
-
|
753
|
+
@mixin mixin($arg1, $arg2, $kwarg1: 'default', $kwarg2: 'default') {
|
754
|
+
}
|
58
755
|
SCSS
|
59
756
|
|
60
|
-
it {
|
757
|
+
it { should report_lint count: 3 }
|
61
758
|
end
|
62
759
|
|
63
760
|
context 'where spaces surround commas' do
|
64
761
|
let(:scss) { <<-SCSS }
|
65
|
-
|
66
|
-
|
762
|
+
@mixin mixin($arg1 , $arg2 , $kwarg1: 'default' , $kwarg2: 'default') {
|
763
|
+
}
|
67
764
|
SCSS
|
68
765
|
|
69
|
-
it {
|
766
|
+
it { should report_lint count: 3 }
|
70
767
|
end
|
71
768
|
|
72
769
|
context 'where commas are followed by a newline' do
|
73
770
|
let(:scss) { <<-SCSS }
|
771
|
+
@mixin mixin($arg1,
|
772
|
+
$arg2,
|
773
|
+
$kwarg1: 'default',
|
774
|
+
$kwarg2: 'default') {
|
775
|
+
}
|
776
|
+
SCSS
|
777
|
+
|
778
|
+
it { should_not report_lint }
|
779
|
+
end
|
780
|
+
|
781
|
+
context 'definining a variable argument' do
|
782
|
+
context 'where spaces do not follow commas' do
|
783
|
+
let(:scss) { <<-SCSS }
|
784
|
+
@mixin mixin($arg,$args...) {
|
785
|
+
}
|
786
|
+
SCSS
|
787
|
+
|
788
|
+
it { should_not report_lint }
|
789
|
+
end
|
790
|
+
|
791
|
+
context 'where spaces follow commas' do
|
792
|
+
let(:scss) { <<-SCSS }
|
793
|
+
@mixin mixin($arg, $args...) {
|
794
|
+
}
|
795
|
+
SCSS
|
796
|
+
|
797
|
+
it { should report_lint count: 1 }
|
798
|
+
end
|
799
|
+
|
800
|
+
context 'where spaces surround commas' do
|
801
|
+
let(:scss) { <<-SCSS }
|
802
|
+
@mixin mixin($arg , $args...) {
|
803
|
+
}
|
804
|
+
SCSS
|
805
|
+
|
806
|
+
it { should report_lint count: 1 }
|
807
|
+
end
|
808
|
+
|
809
|
+
context 'where commas are followed by a newline' do
|
810
|
+
let(:scss) { <<-SCSS }
|
74
811
|
@mixin mixin($arg,
|
75
812
|
$args...) {
|
76
813
|
}
|
77
|
-
|
814
|
+
SCSS
|
78
815
|
|
79
|
-
|
816
|
+
it { should_not report_lint }
|
817
|
+
end
|
80
818
|
end
|
81
819
|
end
|
82
|
-
end
|
83
820
|
|
84
|
-
|
85
|
-
|
86
|
-
|
821
|
+
context 'in a mixin inclusion' do
|
822
|
+
context 'where spaces do not follow commas' do
|
823
|
+
let(:scss) { <<-SCSS }
|
87
824
|
p {
|
88
825
|
@include mixin(1,2,3,$args...,$kwarg1: 4,$kwarg2: 5,$kwargs...);
|
89
826
|
}
|
90
|
-
|
827
|
+
SCSS
|
91
828
|
|
92
|
-
|
93
|
-
|
829
|
+
it { should_not report_lint }
|
830
|
+
end
|
94
831
|
|
95
|
-
|
96
|
-
|
832
|
+
context 'where spaces follow commas' do
|
833
|
+
let(:scss) { <<-SCSS }
|
97
834
|
p {
|
98
835
|
@include mixin(1, 2, 3, $args..., $kwarg1: 4, $kwarg2: 5, $kwargs...);
|
99
836
|
}
|
100
|
-
|
837
|
+
SCSS
|
101
838
|
|
102
|
-
|
103
|
-
|
839
|
+
it { should report_lint count: 6 }
|
840
|
+
end
|
104
841
|
|
105
|
-
|
106
|
-
|
842
|
+
context 'where spaces surround commas' do
|
843
|
+
let(:scss) { <<-SCSS }
|
107
844
|
p {
|
108
845
|
@include mixin(1 , 2 , 3 , $args... , $kwarg1: 4 , $kwarg2: 5 , $kwargs...);
|
109
846
|
}
|
110
|
-
|
847
|
+
SCSS
|
111
848
|
|
112
|
-
|
113
|
-
|
849
|
+
it { should report_lint count: 6 }
|
850
|
+
end
|
114
851
|
|
115
|
-
|
116
|
-
|
852
|
+
context 'where commas are followed by a newline' do
|
853
|
+
let(:scss) { <<-SCSS }
|
117
854
|
p {
|
118
855
|
@include mixin(1,
|
119
856
|
2,
|
@@ -123,125 +860,125 @@ describe SCSSLint::Linter::SpaceAfterComma do
|
|
123
860
|
$kwarg2: 5,
|
124
861
|
$kwargs...);
|
125
862
|
}
|
126
|
-
|
863
|
+
SCSS
|
127
864
|
|
128
|
-
|
865
|
+
it { should_not report_lint }
|
866
|
+
end
|
129
867
|
end
|
130
|
-
end
|
131
868
|
|
132
|
-
|
133
|
-
|
134
|
-
|
869
|
+
context 'in a function declaration' do
|
870
|
+
context 'where spaces do not follow commas' do
|
871
|
+
let(:scss) { <<-SCSS }
|
135
872
|
@function func($arg1,$arg2,$kwarg1: 'default',$kwarg2: 'default') {
|
136
873
|
}
|
137
|
-
|
874
|
+
SCSS
|
138
875
|
|
139
|
-
|
140
|
-
|
876
|
+
it { should_not report_lint }
|
877
|
+
end
|
141
878
|
|
142
|
-
|
143
|
-
|
879
|
+
context 'where spaces follow commas' do
|
880
|
+
let(:scss) { <<-SCSS }
|
144
881
|
@function func($arg1, $arg2, $kwarg1: 'default', $kwarg2: 'default') {
|
145
882
|
}
|
146
|
-
|
883
|
+
SCSS
|
147
884
|
|
148
|
-
|
149
|
-
|
885
|
+
it { should report_lint count: 3 }
|
886
|
+
end
|
150
887
|
|
151
|
-
|
152
|
-
|
888
|
+
context 'where spaces surround commas' do
|
889
|
+
let(:scss) { <<-SCSS }
|
153
890
|
@function func($arg1 , $arg2 , $kwarg1: 'default' , $kwarg2: 'default') {
|
154
891
|
}
|
155
|
-
|
892
|
+
SCSS
|
156
893
|
|
157
|
-
|
158
|
-
|
894
|
+
it { should report_lint count: 3 }
|
895
|
+
end
|
159
896
|
|
160
|
-
|
161
|
-
|
897
|
+
context 'where commas are followed by a newline' do
|
898
|
+
let(:scss) { <<-SCSS }
|
162
899
|
@function func($arg1,
|
163
900
|
$arg2,
|
164
901
|
$kwarg1: 'default',
|
165
902
|
$kwarg2: 'default') {
|
166
903
|
}
|
167
|
-
|
904
|
+
SCSS
|
168
905
|
|
169
|
-
|
170
|
-
|
906
|
+
it { should_not report_lint }
|
907
|
+
end
|
171
908
|
|
172
|
-
|
173
|
-
|
174
|
-
|
909
|
+
context 'definining a variable argument' do
|
910
|
+
context 'where spaces do not follow commas' do
|
911
|
+
let(:scss) { <<-SCSS }
|
175
912
|
@function func($arg,$args...) {
|
176
913
|
}
|
177
|
-
|
914
|
+
SCSS
|
178
915
|
|
179
|
-
|
180
|
-
|
916
|
+
it { should_not report_lint }
|
917
|
+
end
|
181
918
|
|
182
|
-
|
183
|
-
|
919
|
+
context 'where spaces follow commas' do
|
920
|
+
let(:scss) { <<-SCSS }
|
184
921
|
@function func($arg, $args...) {
|
185
922
|
}
|
186
|
-
|
923
|
+
SCSS
|
187
924
|
|
188
|
-
|
189
|
-
|
925
|
+
it { should report_lint count: 1 }
|
926
|
+
end
|
190
927
|
|
191
|
-
|
192
|
-
|
928
|
+
context 'where spaces surround commas' do
|
929
|
+
let(:scss) { <<-SCSS }
|
193
930
|
@function func($arg , $args...) {
|
194
931
|
}
|
195
|
-
|
932
|
+
SCSS
|
196
933
|
|
197
|
-
|
198
|
-
|
934
|
+
it { should report_lint count: 1 }
|
935
|
+
end
|
199
936
|
|
200
|
-
|
201
|
-
|
937
|
+
context 'where commas are followed by a newline' do
|
938
|
+
let(:scss) { <<-SCSS }
|
202
939
|
@function func($arg,
|
203
940
|
$args...) {
|
204
941
|
}
|
205
|
-
|
942
|
+
SCSS
|
206
943
|
|
207
|
-
|
944
|
+
it { should_not report_lint }
|
945
|
+
end
|
208
946
|
end
|
209
947
|
end
|
210
|
-
end
|
211
948
|
|
212
|
-
|
213
|
-
|
214
|
-
|
949
|
+
context 'in a function invocation' do
|
950
|
+
context 'where spaces do not follow commas' do
|
951
|
+
let(:scss) { <<-SCSS }
|
215
952
|
p {
|
216
953
|
margin: func(1,2,3,$args...,$kwarg1: 4,$kwarg2: 5,$kwargs...);
|
217
954
|
}
|
218
|
-
|
955
|
+
SCSS
|
219
956
|
|
220
|
-
|
221
|
-
|
957
|
+
it { should_not report_lint }
|
958
|
+
end
|
222
959
|
|
223
|
-
|
224
|
-
|
960
|
+
context 'where spaces follow commas' do
|
961
|
+
let(:scss) { <<-SCSS }
|
225
962
|
p {
|
226
963
|
margin: func(1, 2, 3, $args..., $kwarg1: 4, $kwarg2: 5, $kwargs...);
|
227
964
|
}
|
228
|
-
|
965
|
+
SCSS
|
229
966
|
|
230
|
-
|
231
|
-
|
967
|
+
it { should report_lint count: 6 }
|
968
|
+
end
|
232
969
|
|
233
|
-
|
234
|
-
|
970
|
+
context 'where spaces surround commas' do
|
971
|
+
let(:scss) { <<-SCSS }
|
235
972
|
p {
|
236
973
|
margin: func(1 , 2 , 3 , $args... , $kwarg1: 4 , $kwarg2: 5 , $kwargs...);
|
237
974
|
}
|
238
|
-
|
975
|
+
SCSS
|
239
976
|
|
240
|
-
|
241
|
-
|
977
|
+
it { should report_lint count: 6 }
|
978
|
+
end
|
242
979
|
|
243
|
-
|
244
|
-
|
980
|
+
context 'where commas are followed by a newline' do
|
981
|
+
let(:scss) { <<-SCSS }
|
245
982
|
p {
|
246
983
|
margin: func(1,
|
247
984
|
2,
|
@@ -251,71 +988,71 @@ describe SCSSLint::Linter::SpaceAfterComma do
|
|
251
988
|
$kwarg2: 5,
|
252
989
|
$kwargs...);
|
253
990
|
}
|
254
|
-
|
991
|
+
SCSS
|
255
992
|
|
256
|
-
|
993
|
+
it { should_not report_lint }
|
994
|
+
end
|
257
995
|
end
|
258
|
-
end
|
259
996
|
|
260
|
-
|
261
|
-
|
262
|
-
|
997
|
+
context 'in a comma-separated literal list' do
|
998
|
+
context 'where spaces do not follow commas' do
|
999
|
+
let(:scss) { <<-SCSS }
|
263
1000
|
p {
|
264
1001
|
property: $a,$b,$c,$d;
|
265
1002
|
}
|
266
|
-
|
1003
|
+
SCSS
|
267
1004
|
|
268
|
-
|
269
|
-
|
1005
|
+
it { should_not report_lint }
|
1006
|
+
end
|
270
1007
|
|
271
|
-
|
272
|
-
|
1008
|
+
context 'where spaces follow commas' do
|
1009
|
+
let(:scss) { <<-SCSS }
|
273
1010
|
p {
|
274
1011
|
property: $a, $b, $c, $d;
|
275
1012
|
}
|
276
|
-
|
1013
|
+
SCSS
|
277
1014
|
|
278
|
-
|
279
|
-
|
1015
|
+
it { should report_lint count: 3 }
|
1016
|
+
end
|
280
1017
|
|
281
|
-
|
282
|
-
|
1018
|
+
context 'where spaces surround commas' do
|
1019
|
+
let(:scss) { <<-SCSS }
|
283
1020
|
p {
|
284
1021
|
property: $a , $b , $c , $d;
|
285
1022
|
}
|
286
|
-
|
1023
|
+
SCSS
|
287
1024
|
|
288
|
-
|
289
|
-
|
1025
|
+
it { should report_lint count: 3 }
|
1026
|
+
end
|
290
1027
|
|
291
|
-
|
292
|
-
|
1028
|
+
context 'where commas are followed by a newline' do
|
1029
|
+
let(:scss) { <<-SCSS }
|
293
1030
|
p {
|
294
1031
|
property: $a,
|
295
1032
|
$b,
|
296
1033
|
$c,
|
297
1034
|
$d;
|
298
1035
|
}
|
299
|
-
|
1036
|
+
SCSS
|
300
1037
|
|
301
|
-
|
302
|
-
|
1038
|
+
it { should_not report_lint }
|
1039
|
+
end
|
303
1040
|
|
304
|
-
|
305
|
-
|
1041
|
+
context 'when commas are followed by a space and a newline' do
|
1042
|
+
let(:scss) { <<-SCSS }
|
306
1043
|
p {
|
307
1044
|
property: $a,\s
|
308
1045
|
$b;
|
309
1046
|
}
|
310
|
-
|
1047
|
+
SCSS
|
311
1048
|
|
312
|
-
|
1049
|
+
it { should_not report_lint }
|
1050
|
+
end
|
313
1051
|
end
|
314
|
-
end
|
315
1052
|
|
316
|
-
|
317
|
-
|
318
|
-
|
1053
|
+
context 'when declaring list variables' do
|
1054
|
+
context 'and one argument does not have a trailing comma' do
|
1055
|
+
let(:scss) { <<-SCSS }
|
319
1056
|
$z-list: (
|
320
1057
|
(
|
321
1058
|
name1
|
@@ -324,9 +1061,10 @@ describe SCSSLint::Linter::SpaceAfterComma do
|
|
324
1061
|
name2,
|
325
1062
|
)
|
326
1063
|
);
|
327
|
-
|
1064
|
+
SCSS
|
328
1065
|
|
329
|
-
|
1066
|
+
it { should_not report_lint }
|
1067
|
+
end
|
330
1068
|
end
|
331
1069
|
end
|
332
1070
|
end
|