scss-lint 0.25.1 → 0.26.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 +10 -1
- data/data/property-sort-orders/concentric.txt +99 -0
- data/lib/scss_lint.rb +1 -0
- data/lib/scss_lint/cli.rb +9 -3
- data/lib/scss_lint/exceptions.rb +4 -0
- data/lib/scss_lint/linter.rb +10 -1
- data/lib/scss_lint/linter/capitalization_in_selector.rb +14 -6
- data/lib/scss_lint/linter/compass/property_with_mixin.rb +9 -2
- data/lib/scss_lint/linter/indentation.rb +28 -6
- data/lib/scss_lint/linter/property_sort_order.rb +61 -9
- data/lib/scss_lint/linter/single_line_per_property.rb +53 -0
- data/lib/scss_lint/linter/single_line_per_selector.rb +6 -1
- data/lib/scss_lint/linter/space_after_comma.rb +27 -19
- data/lib/scss_lint/linter/space_before_brace.rb +5 -4
- data/lib/scss_lint/linter/trailing_semicolon.rb +53 -0
- data/lib/scss_lint/linter/unnecessary_parent_reference.rb +36 -0
- data/lib/scss_lint/reporter/default_reporter.rb +7 -2
- data/lib/scss_lint/reporter/xml_reporter.rb +2 -1
- data/lib/scss_lint/runner.rb +7 -3
- data/lib/scss_lint/version.rb +1 -1
- data/spec/scss_lint/cli_spec.rb +314 -0
- data/spec/scss_lint/config_spec.rb +439 -0
- data/spec/scss_lint/engine_spec.rb +24 -0
- data/spec/scss_lint/linter/border_zero_spec.rb +84 -0
- data/spec/scss_lint/linter/capitalization_in_selector_spec.rb +71 -0
- data/spec/scss_lint/linter/color_keyword_spec.rb +83 -0
- data/spec/scss_lint/linter/comment_spec.rb +55 -0
- data/spec/scss_lint/linter/compass/property_with_mixin_spec.rb +55 -0
- data/spec/scss_lint/linter/debug_statement_spec.rb +21 -0
- data/spec/scss_lint/linter/declaration_order_spec.rb +94 -0
- data/spec/scss_lint/linter/duplicate_property_spec.rb +176 -0
- data/spec/scss_lint/linter/else_placement_spec.rb +106 -0
- data/spec/scss_lint/linter/empty_line_between_blocks_spec.rb +263 -0
- data/spec/scss_lint/linter/empty_rule_spec.rb +27 -0
- data/spec/scss_lint/linter/final_newline_spec.rb +49 -0
- data/spec/scss_lint/linter/hex_length_spec.rb +104 -0
- data/spec/scss_lint/linter/hex_notation_spec.rb +104 -0
- data/spec/scss_lint/linter/hex_validation_spec.rb +36 -0
- data/spec/scss_lint/linter/id_with_extraneous_selector_spec.rb +139 -0
- data/spec/scss_lint/linter/indentation_spec.rb +242 -0
- data/spec/scss_lint/linter/leading_zero_spec.rb +233 -0
- data/spec/scss_lint/linter/mergeable_selector_spec.rb +283 -0
- data/spec/scss_lint/linter/name_format_spec.rb +206 -0
- data/spec/scss_lint/linter/placeholder_in_extend_spec.rb +63 -0
- data/spec/scss_lint/linter/property_sort_order_spec.rb +246 -0
- data/spec/scss_lint/linter/property_spelling_spec.rb +57 -0
- data/spec/scss_lint/linter/selector_depth_spec.rb +159 -0
- data/spec/scss_lint/linter/shorthand_spec.rb +172 -0
- data/spec/scss_lint/linter/single_line_per_property_spec.rb +73 -0
- data/spec/scss_lint/linter/single_line_per_selector_spec.rb +121 -0
- data/spec/scss_lint/linter/space_after_comma_spec.rb +315 -0
- data/spec/scss_lint/linter/space_after_property_colon_spec.rb +238 -0
- data/spec/scss_lint/linter/space_after_property_name_spec.rb +23 -0
- data/spec/scss_lint/linter/space_before_brace_spec.rb +447 -0
- data/spec/scss_lint/linter/space_between_parens_spec.rb +263 -0
- data/spec/scss_lint/linter/string_quotes_spec.rb +303 -0
- data/spec/scss_lint/linter/trailing_semicolon_spec.rb +188 -0
- data/spec/scss_lint/linter/unnecessary_mantissa_spec.rb +67 -0
- data/spec/scss_lint/linter/unnecessary_parent_reference_spec.rb +67 -0
- data/spec/scss_lint/linter/url_format_spec.rb +55 -0
- data/spec/scss_lint/linter/url_quotes_spec.rb +63 -0
- data/spec/scss_lint/linter/zero_unit_spec.rb +113 -0
- data/spec/scss_lint/linter_registry_spec.rb +50 -0
- data/spec/scss_lint/location_spec.rb +42 -0
- data/spec/scss_lint/reporter/config_reporter_spec.rb +42 -0
- data/spec/scss_lint/reporter/default_reporter_spec.rb +73 -0
- data/spec/scss_lint/reporter/files_reporter_spec.rb +38 -0
- data/spec/scss_lint/reporter/xml_reporter_spec.rb +103 -0
- data/spec/scss_lint/reporter_spec.rb +11 -0
- data/spec/scss_lint/runner_spec.rb +132 -0
- data/spec/scss_lint/selector_visitor_spec.rb +264 -0
- data/spec/spec_helper.rb +34 -0
- data/spec/support/isolated_environment.rb +25 -0
- data/spec/support/matchers/report_lint.rb +48 -0
- metadata +126 -8
- data/lib/scss_lint/linter/trailing_semicolon_after_property_value.rb +0 -40
@@ -0,0 +1,172 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::Shorthand do
|
4
|
+
context 'when a rule' do
|
5
|
+
context 'is empty' do
|
6
|
+
let(:css) { <<-CSS }
|
7
|
+
p {
|
8
|
+
}
|
9
|
+
CSS
|
10
|
+
|
11
|
+
it { should_not report_lint }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'contains properties with valid shorthand values' do
|
15
|
+
let(:css) { <<-CSS }
|
16
|
+
p {
|
17
|
+
border-radius: 1px 2px 1px 3px;
|
18
|
+
border-width: 1px;
|
19
|
+
color: rgba(0, 0, 0, .5);
|
20
|
+
margin: 1px 2px;
|
21
|
+
padding: 0 0 1px;
|
22
|
+
}
|
23
|
+
CSS
|
24
|
+
|
25
|
+
it { should_not report_lint }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when a property' do
|
30
|
+
context 'has a value repeated 4 times' do
|
31
|
+
let(:css) { <<-CSS }
|
32
|
+
p {
|
33
|
+
padding: 1px 1px 1px 1px;
|
34
|
+
}
|
35
|
+
CSS
|
36
|
+
|
37
|
+
it { should report_lint line: 2 }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'has a value repeated 3 times' do
|
41
|
+
let(:css) { <<-CSS }
|
42
|
+
p {
|
43
|
+
padding: 3px 3px 3px;
|
44
|
+
}
|
45
|
+
CSS
|
46
|
+
|
47
|
+
it { should report_lint line: 2 }
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'has interpolation in its name and starts with a shorthandable property' do
|
51
|
+
let(:css) { <<-CSS }
|
52
|
+
p {
|
53
|
+
border-color\#{$type}: 1px 1px;
|
54
|
+
}
|
55
|
+
CSS
|
56
|
+
|
57
|
+
it { should_not report_lint }
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'has exactly two identical values' do
|
61
|
+
let(:css) { <<-CSS }
|
62
|
+
p {
|
63
|
+
padding: 10px 10px;
|
64
|
+
}
|
65
|
+
CSS
|
66
|
+
|
67
|
+
it { should report_lint line: 2 }
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'appears to have two identical values, but cannot be shorthanded' do
|
71
|
+
let(:css) { <<-CSS }
|
72
|
+
p:before {
|
73
|
+
content: ' ';
|
74
|
+
}
|
75
|
+
CSS
|
76
|
+
|
77
|
+
it { should_not report_lint }
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'has its first two values repeated' do
|
81
|
+
let(:css) { <<-CSS }
|
82
|
+
p {
|
83
|
+
padding: 1px 2px 1px 2px;
|
84
|
+
}
|
85
|
+
CSS
|
86
|
+
|
87
|
+
it { should report_lint line: 2 }
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'has its first value repeated in the third position' do
|
91
|
+
let(:css) { <<-CSS }
|
92
|
+
p {
|
93
|
+
padding: 1px 2px 1px;
|
94
|
+
}
|
95
|
+
CSS
|
96
|
+
|
97
|
+
it { should report_lint line: 2 }
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'has its second value repeated in the fourth position' do
|
101
|
+
let(:css) { <<-CSS }
|
102
|
+
p {
|
103
|
+
padding: 1px 2px 3px 2px;
|
104
|
+
}
|
105
|
+
CSS
|
106
|
+
|
107
|
+
it { should report_lint line: 2 }
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'contains numeric values and function calls' do
|
111
|
+
let(:css) { <<-CSS }
|
112
|
+
p {
|
113
|
+
margin: 10px percentage(1 / 100);
|
114
|
+
}
|
115
|
+
CSS
|
116
|
+
|
117
|
+
it { should_not report_lint }
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'contains a list of function calls that can be shortened' do
|
121
|
+
let(:css) { <<-CSS }
|
122
|
+
p {
|
123
|
+
margin: percentage(1 / 100) percentage(1 / 100);
|
124
|
+
}
|
125
|
+
CSS
|
126
|
+
|
127
|
+
it { should report_lint line: 2 }
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'contains a list of function calls that cannot be shortened' do
|
131
|
+
let(:css) { <<-CSS }
|
132
|
+
p {
|
133
|
+
margin: percentage(1 / 100) percentage(5 / 100);
|
134
|
+
}
|
135
|
+
CSS
|
136
|
+
|
137
|
+
it { should_not report_lint }
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'contains a list of variables that can be shortened' do
|
141
|
+
let(:css) { <<-CSS }
|
142
|
+
p {
|
143
|
+
margin: $my-var 1px $my-var;
|
144
|
+
}
|
145
|
+
CSS
|
146
|
+
|
147
|
+
it { should report_lint line: 2 }
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'contains a number with no trailing semicolon' do
|
151
|
+
let(:css) { <<-CSS }
|
152
|
+
p {
|
153
|
+
margin: 4px
|
154
|
+
}
|
155
|
+
CSS
|
156
|
+
|
157
|
+
it { should_not report_lint }
|
158
|
+
end
|
159
|
+
|
160
|
+
context 'can be shortened and is followed by !important modifier' do
|
161
|
+
let(:css) { <<-CSS }
|
162
|
+
p {
|
163
|
+
padding: 1px 2px 3px 2px !important;
|
164
|
+
margin: 0 0 0 0 !important; // A comment
|
165
|
+
}
|
166
|
+
CSS
|
167
|
+
|
168
|
+
it { should report_lint line: 2 }
|
169
|
+
it { should report_lint line: 3 }
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::SingleLinePerProperty do
|
4
|
+
context 'when properties are each on their own line' do
|
5
|
+
let(:css) { <<-CSS }
|
6
|
+
p {
|
7
|
+
color: #fff;
|
8
|
+
margin: 0;
|
9
|
+
padding: 5px;
|
10
|
+
}
|
11
|
+
CSS
|
12
|
+
|
13
|
+
it { should_not report_lint }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when two properties share a line' do
|
17
|
+
let(:css) { <<-CSS }
|
18
|
+
p {
|
19
|
+
color: #fff;
|
20
|
+
margin: 0; padding: 5px;
|
21
|
+
}
|
22
|
+
CSS
|
23
|
+
|
24
|
+
it { should_not report_lint line: 2 }
|
25
|
+
it { should report_lint line: 3, count: 1 }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when multiple properties share a line' do
|
29
|
+
let(:css) { <<-CSS }
|
30
|
+
p {
|
31
|
+
color: #fff; margin: 0; padding: 5px;
|
32
|
+
}
|
33
|
+
CSS
|
34
|
+
|
35
|
+
it { should report_lint line: 2, count: 2 }
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when multiple properties share a line on a single line rule set' do
|
39
|
+
let(:css) { <<-CSS }
|
40
|
+
p { color: #fff; margin: 0; padding: 5px; }
|
41
|
+
CSS
|
42
|
+
|
43
|
+
context 'and single line rule sets are allowed' do
|
44
|
+
let(:linter_config) { { 'allow_single_line_rule_sets' => true } }
|
45
|
+
|
46
|
+
it { should_not report_lint }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'and single line rule sets are not allowed' do
|
50
|
+
let(:linter_config) { { 'allow_single_line_rule_sets' => false } }
|
51
|
+
|
52
|
+
it { should report_lint }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when a single line rule set contains a single property' do
|
57
|
+
let(:css) { <<-CSS }
|
58
|
+
p { color: #fff; }
|
59
|
+
CSS
|
60
|
+
|
61
|
+
context 'and single line rule sets are allowed' do
|
62
|
+
let(:linter_config) { { 'allow_single_line_rule_sets' => true } }
|
63
|
+
|
64
|
+
it { should_not report_lint }
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'and single line rule sets are not allowed' do
|
68
|
+
let(:linter_config) { { 'allow_single_line_rule_sets' => false } }
|
69
|
+
|
70
|
+
it { should report_lint }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::SingleLinePerSelector do
|
4
|
+
context 'when rule has one selector' do
|
5
|
+
let(:css) { <<-CSS }
|
6
|
+
p {
|
7
|
+
}
|
8
|
+
CSS
|
9
|
+
|
10
|
+
it { should_not report_lint }
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when rule has one selector on each line' do
|
14
|
+
let(:css) { <<-CSS }
|
15
|
+
p,
|
16
|
+
a {
|
17
|
+
}
|
18
|
+
CSS
|
19
|
+
|
20
|
+
it { should_not report_lint }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when rule contains multiple selectors on the same line' do
|
24
|
+
let(:css) { <<-CSS }
|
25
|
+
.first,
|
26
|
+
.second,
|
27
|
+
.third, .fourth,
|
28
|
+
.fifth {
|
29
|
+
}
|
30
|
+
CSS
|
31
|
+
|
32
|
+
it { should report_lint line: 1 }
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when commas are not at the end of the line' do
|
36
|
+
let(:css) { <<-CSS }
|
37
|
+
.foo
|
38
|
+
, .bar {
|
39
|
+
}
|
40
|
+
CSS
|
41
|
+
|
42
|
+
it { should report_lint }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when commas are on their own line' do
|
46
|
+
let(:css) { <<-CSS }
|
47
|
+
.foo
|
48
|
+
,
|
49
|
+
.bar {
|
50
|
+
}
|
51
|
+
CSS
|
52
|
+
|
53
|
+
it { should report_lint }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when nested rule contains multiple selectors on the same line' do
|
57
|
+
let(:css) { <<-CSS }
|
58
|
+
#foo {
|
59
|
+
.first,
|
60
|
+
.second,
|
61
|
+
.third, .fourth,
|
62
|
+
.fifth {
|
63
|
+
}
|
64
|
+
}
|
65
|
+
CSS
|
66
|
+
|
67
|
+
it { should report_lint line: 2 }
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'when rule contains interpolated selectors' do
|
71
|
+
let(:css) { <<-CSS }
|
72
|
+
.first,
|
73
|
+
\#{interpolated-selector}.thing,
|
74
|
+
.third {
|
75
|
+
}
|
76
|
+
CSS
|
77
|
+
|
78
|
+
it { should_not report_lint }
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'when rule contains an interpolated selector not on its own line' do
|
82
|
+
let(:css) { <<-CSS }
|
83
|
+
.first,
|
84
|
+
.second, \#{interpolated-selector}.thing,
|
85
|
+
.fourth {
|
86
|
+
}
|
87
|
+
CSS
|
88
|
+
|
89
|
+
it { should report_lint line: 1 }
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'when rule contains an inline comment' do
|
93
|
+
let(:css) { <<-CSS }
|
94
|
+
.first, /* A comment */
|
95
|
+
.second, // Another comment
|
96
|
+
.third {
|
97
|
+
}
|
98
|
+
CSS
|
99
|
+
|
100
|
+
it { should_not report_lint }
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'when interpolation contains a comma' do
|
104
|
+
let(:css) { <<-CSS }
|
105
|
+
.my-\#{function(1, 2)}-selector .nested {
|
106
|
+
}
|
107
|
+
CSS
|
108
|
+
|
109
|
+
it { should_not report_lint }
|
110
|
+
end
|
111
|
+
|
112
|
+
context 'when selector contains an interpolated string' do
|
113
|
+
let(:css) { <<-CSS }
|
114
|
+
div,
|
115
|
+
\#{$selector},
|
116
|
+
p {}
|
117
|
+
CSS
|
118
|
+
|
119
|
+
it { should_not report_lint }
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,315 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::SpaceAfterComma do
|
4
|
+
context 'in a mixin declaration' do
|
5
|
+
context 'where spaces do not follow commas' do
|
6
|
+
let(:css) { <<-CSS }
|
7
|
+
@mixin mixin($arg1,$arg2,$kwarg1: 'default',$kwarg2: 'default') {
|
8
|
+
}
|
9
|
+
CSS
|
10
|
+
|
11
|
+
it { should report_lint count: 3 }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'where spaces follow commas' do
|
15
|
+
let(:css) { <<-CSS }
|
16
|
+
@mixin mixin($arg1, $arg2, $kwarg1: 'default', $kwarg2: 'default') {
|
17
|
+
}
|
18
|
+
CSS
|
19
|
+
|
20
|
+
it { should_not report_lint }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'where spaces surround commas' do
|
24
|
+
let(:css) { <<-CSS }
|
25
|
+
@mixin mixin($arg1 , $arg2 , $kwarg1: 'default' , $kwarg2: 'default') {
|
26
|
+
}
|
27
|
+
CSS
|
28
|
+
|
29
|
+
it { should_not report_lint }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'where commas are followed by a newline' do
|
33
|
+
let(:css) { <<-CSS }
|
34
|
+
@mixin mixin($arg1,
|
35
|
+
$arg2,
|
36
|
+
$kwarg1: 'default',
|
37
|
+
$kwarg2: 'default') {
|
38
|
+
}
|
39
|
+
CSS
|
40
|
+
|
41
|
+
it { should_not report_lint }
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'definining a variable argument' do
|
45
|
+
context 'where spaces do not follow commas' do
|
46
|
+
let(:css) { <<-CSS }
|
47
|
+
@mixin mixin($arg,$args...) {
|
48
|
+
}
|
49
|
+
CSS
|
50
|
+
|
51
|
+
it { should report_lint count: 1 }
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'where spaces follow commas' do
|
55
|
+
let(:css) { <<-CSS }
|
56
|
+
@mixin mixin($arg, $args...) {
|
57
|
+
}
|
58
|
+
CSS
|
59
|
+
|
60
|
+
it { should_not report_lint }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'where spaces surround commas' do
|
64
|
+
let(:css) { <<-CSS }
|
65
|
+
@mixin mixin($arg , $args...) {
|
66
|
+
}
|
67
|
+
CSS
|
68
|
+
|
69
|
+
it { should_not report_lint }
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'where commas are followed by a newline' do
|
73
|
+
let(:css) { <<-CSS }
|
74
|
+
@mixin mixin($arg,
|
75
|
+
$args...) {
|
76
|
+
}
|
77
|
+
CSS
|
78
|
+
|
79
|
+
it { should_not report_lint }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'in a mixin inclusion' do
|
85
|
+
context 'where spaces do not follow commas' do
|
86
|
+
let(:css) { <<-CSS }
|
87
|
+
p {
|
88
|
+
@include mixin(1,2,3,$args...,$kwarg1: 4,$kwarg2: 5,$kwargs...);
|
89
|
+
}
|
90
|
+
CSS
|
91
|
+
|
92
|
+
it { should report_lint count: 6 }
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'where spaces follow commas' do
|
96
|
+
let(:css) { <<-CSS }
|
97
|
+
p {
|
98
|
+
@include mixin(1, 2, 3, $args..., $kwarg1: 4, $kwarg2: 5, $kwargs...);
|
99
|
+
}
|
100
|
+
CSS
|
101
|
+
|
102
|
+
it { should_not report_lint }
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'where spaces surround commas' do
|
106
|
+
let(:css) { <<-CSS }
|
107
|
+
p {
|
108
|
+
@include mixin(1 , 2 , 3 , $args... , $kwarg1: 4 , $kwarg2: 5 , $kwargs...);
|
109
|
+
}
|
110
|
+
CSS
|
111
|
+
|
112
|
+
it { should_not report_lint }
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'where commas are followed by a newline' do
|
116
|
+
let(:css) { <<-CSS }
|
117
|
+
p {
|
118
|
+
@include mixin(1,
|
119
|
+
2,
|
120
|
+
3,
|
121
|
+
$args...,
|
122
|
+
$kwarg1: 4,
|
123
|
+
$kwarg2: 5,
|
124
|
+
$kwargs...);
|
125
|
+
}
|
126
|
+
CSS
|
127
|
+
|
128
|
+
it { should_not report_lint }
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'in a function declaration' do
|
133
|
+
context 'where spaces do not follow commas' do
|
134
|
+
let(:css) { <<-CSS }
|
135
|
+
@function func($arg1,$arg2,$kwarg1: 'default',$kwarg2: 'default') {
|
136
|
+
}
|
137
|
+
CSS
|
138
|
+
|
139
|
+
it { should report_lint count: 3 }
|
140
|
+
end
|
141
|
+
|
142
|
+
context 'where spaces follow commas' do
|
143
|
+
let(:css) { <<-CSS }
|
144
|
+
@function func($arg1, $arg2, $kwarg1: 'default', $kwarg2: 'default') {
|
145
|
+
}
|
146
|
+
CSS
|
147
|
+
|
148
|
+
it { should_not report_lint }
|
149
|
+
end
|
150
|
+
|
151
|
+
context 'where spaces surround commas' do
|
152
|
+
let(:css) { <<-CSS }
|
153
|
+
@function func($arg1 , $arg2 , $kwarg1: 'default' , $kwarg2: 'default') {
|
154
|
+
}
|
155
|
+
CSS
|
156
|
+
|
157
|
+
it { should_not report_lint }
|
158
|
+
end
|
159
|
+
|
160
|
+
context 'where commas are followed by a newline' do
|
161
|
+
let(:css) { <<-CSS }
|
162
|
+
@function func($arg1,
|
163
|
+
$arg2,
|
164
|
+
$kwarg1: 'default',
|
165
|
+
$kwarg2: 'default') {
|
166
|
+
}
|
167
|
+
CSS
|
168
|
+
|
169
|
+
it { should_not report_lint }
|
170
|
+
end
|
171
|
+
|
172
|
+
context 'definining a variable argument' do
|
173
|
+
context 'where spaces do not follow commas' do
|
174
|
+
let(:css) { <<-CSS }
|
175
|
+
@function func($arg,$args...) {
|
176
|
+
}
|
177
|
+
CSS
|
178
|
+
|
179
|
+
it { should report_lint count: 1 }
|
180
|
+
end
|
181
|
+
|
182
|
+
context 'where spaces follow commas' do
|
183
|
+
let(:css) { <<-CSS }
|
184
|
+
@function func($arg, $args...) {
|
185
|
+
}
|
186
|
+
CSS
|
187
|
+
|
188
|
+
it { should_not report_lint }
|
189
|
+
end
|
190
|
+
|
191
|
+
context 'where spaces surround commas' do
|
192
|
+
let(:css) { <<-CSS }
|
193
|
+
@function func($arg , $args...) {
|
194
|
+
}
|
195
|
+
CSS
|
196
|
+
|
197
|
+
it { should_not report_lint }
|
198
|
+
end
|
199
|
+
|
200
|
+
context 'where commas are followed by a newline' do
|
201
|
+
let(:css) { <<-CSS }
|
202
|
+
@function func($arg,
|
203
|
+
$args...) {
|
204
|
+
}
|
205
|
+
CSS
|
206
|
+
|
207
|
+
it { should_not report_lint }
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
context 'in a function invocation' do
|
213
|
+
context 'where spaces do not follow commas' do
|
214
|
+
let(:css) { <<-CSS }
|
215
|
+
p {
|
216
|
+
margin: func(1,2,3,$args...,$kwarg1: 4,$kwarg2: 5,$kwargs...);
|
217
|
+
}
|
218
|
+
CSS
|
219
|
+
|
220
|
+
it { should report_lint count: 6 }
|
221
|
+
end
|
222
|
+
|
223
|
+
context 'where spaces follow commas' do
|
224
|
+
let(:css) { <<-CSS }
|
225
|
+
p {
|
226
|
+
margin: func(1, 2, 3, $args..., $kwarg1: 4, $kwarg2: 5, $kwargs...);
|
227
|
+
}
|
228
|
+
CSS
|
229
|
+
|
230
|
+
it { should_not report_lint }
|
231
|
+
end
|
232
|
+
|
233
|
+
context 'where spaces surround commas' do
|
234
|
+
let(:css) { <<-CSS }
|
235
|
+
p {
|
236
|
+
margin: func(1 , 2 , 3 , $args... , $kwarg1: 4 , $kwarg2: 5 , $kwargs...);
|
237
|
+
}
|
238
|
+
CSS
|
239
|
+
|
240
|
+
it { should_not report_lint }
|
241
|
+
end
|
242
|
+
|
243
|
+
context 'where commas are followed by a newline' do
|
244
|
+
let(:css) { <<-CSS }
|
245
|
+
p {
|
246
|
+
margin: func(1,
|
247
|
+
2,
|
248
|
+
3,
|
249
|
+
$args...,
|
250
|
+
$kwarg1: 4,
|
251
|
+
$kwarg2: 5,
|
252
|
+
$kwargs...);
|
253
|
+
}
|
254
|
+
CSS
|
255
|
+
|
256
|
+
it { should_not report_lint }
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
context 'in a comma-separated literal list' do
|
261
|
+
context 'where spaces do not follow commas' do
|
262
|
+
let(:css) { <<-CSS }
|
263
|
+
p {
|
264
|
+
property: $a,$b,$c,$d;
|
265
|
+
}
|
266
|
+
CSS
|
267
|
+
|
268
|
+
it { should report_lint count: 3 }
|
269
|
+
end
|
270
|
+
|
271
|
+
context 'where spaces follow commas' do
|
272
|
+
let(:css) { <<-CSS }
|
273
|
+
p {
|
274
|
+
property: $a, $b, $c, $d;
|
275
|
+
}
|
276
|
+
CSS
|
277
|
+
|
278
|
+
it { should_not report_lint }
|
279
|
+
end
|
280
|
+
|
281
|
+
context 'where spaces surround commas' do
|
282
|
+
let(:css) { <<-CSS }
|
283
|
+
p {
|
284
|
+
property: $a , $b , $c , $d;
|
285
|
+
}
|
286
|
+
CSS
|
287
|
+
|
288
|
+
it { should_not report_lint }
|
289
|
+
end
|
290
|
+
|
291
|
+
context 'where commas are followed by a newline' do
|
292
|
+
let(:css) { <<-CSS }
|
293
|
+
p {
|
294
|
+
property: $a,
|
295
|
+
$b,
|
296
|
+
$c,
|
297
|
+
$d;
|
298
|
+
}
|
299
|
+
CSS
|
300
|
+
|
301
|
+
it { should_not report_lint }
|
302
|
+
end
|
303
|
+
|
304
|
+
context 'when commas are followed by a space and a newline' do
|
305
|
+
let(:css) { <<-CSS }
|
306
|
+
p {
|
307
|
+
property: $a,\s
|
308
|
+
$b;
|
309
|
+
}
|
310
|
+
CSS
|
311
|
+
|
312
|
+
it { should_not report_lint }
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|