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,238 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::SpaceAfterPropertyColon 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 property is not followed by space' do
|
10
|
+
let(:css) { <<-CSS }
|
11
|
+
p {
|
12
|
+
margin:0;
|
13
|
+
}
|
14
|
+
CSS
|
15
|
+
|
16
|
+
it { should report_lint line: 2 }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when colon after property is not followed by space and the semicolon is missing' do
|
20
|
+
let(:css) { <<-CSS }
|
21
|
+
p {
|
22
|
+
color:#eee
|
23
|
+
}
|
24
|
+
CSS
|
25
|
+
|
26
|
+
it { should report_lint line: 2 }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when the colon after a property is followed by a space' do
|
30
|
+
let(:css) { <<-CSS }
|
31
|
+
p {
|
32
|
+
margin: 0;
|
33
|
+
}
|
34
|
+
CSS
|
35
|
+
|
36
|
+
it { should_not report_lint }
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when the colon after a property is surrounded by spaces' do
|
40
|
+
let(:css) { <<-CSS }
|
41
|
+
p {
|
42
|
+
margin : bold;
|
43
|
+
}
|
44
|
+
CSS
|
45
|
+
|
46
|
+
it { should_not report_lint }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when the colon after a property is followed by multiple spaces' do
|
50
|
+
let(:css) { <<-CSS }
|
51
|
+
p {
|
52
|
+
margin: bold;
|
53
|
+
}
|
54
|
+
CSS
|
55
|
+
|
56
|
+
it { should report_lint line: 2 }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when no spaces are allowed' do
|
61
|
+
let(:style) { 'no_space' }
|
62
|
+
|
63
|
+
context 'when the colon after a property is not followed by space' do
|
64
|
+
let(:css) { <<-CSS }
|
65
|
+
p {
|
66
|
+
margin:0;
|
67
|
+
}
|
68
|
+
CSS
|
69
|
+
|
70
|
+
it { should_not report_lint }
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when colon after property is not followed by space and the semicolon is missing' do
|
74
|
+
let(:css) { <<-CSS }
|
75
|
+
p {
|
76
|
+
color:#eee
|
77
|
+
}
|
78
|
+
CSS
|
79
|
+
|
80
|
+
it { should_not report_lint }
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when the colon after a property is followed by a space' do
|
84
|
+
let(:css) { <<-CSS }
|
85
|
+
p {
|
86
|
+
margin: 0;
|
87
|
+
}
|
88
|
+
CSS
|
89
|
+
|
90
|
+
it { should report_lint line: 2 }
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when the colon after a property is surrounded by spaces' do
|
94
|
+
let(:css) { <<-CSS }
|
95
|
+
p {
|
96
|
+
margin : bold;
|
97
|
+
}
|
98
|
+
CSS
|
99
|
+
|
100
|
+
it { should report_lint line: 2 }
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'when the colon after a property is followed by multiple spaces' do
|
104
|
+
let(:css) { <<-CSS }
|
105
|
+
p {
|
106
|
+
margin: bold;
|
107
|
+
}
|
108
|
+
CSS
|
109
|
+
|
110
|
+
it { should report_lint line: 2 }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'when at least one space is preferred' do
|
115
|
+
let(:style) { 'at_least_one_space' }
|
116
|
+
|
117
|
+
context 'when the colon after a property is not followed by space' do
|
118
|
+
let(:css) { <<-CSS }
|
119
|
+
p {
|
120
|
+
margin:0;
|
121
|
+
}
|
122
|
+
CSS
|
123
|
+
|
124
|
+
it { should report_lint line: 2 }
|
125
|
+
end
|
126
|
+
|
127
|
+
context 'when colon after property is not followed by space and the semicolon is missing' do
|
128
|
+
let(:css) { <<-CSS }
|
129
|
+
p {
|
130
|
+
color:#eee
|
131
|
+
}
|
132
|
+
CSS
|
133
|
+
|
134
|
+
it { should report_lint line: 2 }
|
135
|
+
end
|
136
|
+
|
137
|
+
context 'when the colon after a property is followed by a space' do
|
138
|
+
let(:css) { <<-CSS }
|
139
|
+
p {
|
140
|
+
margin: 0;
|
141
|
+
}
|
142
|
+
CSS
|
143
|
+
|
144
|
+
it { should_not report_lint }
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'when the colon after a property is surrounded by spaces' do
|
148
|
+
let(:css) { <<-CSS }
|
149
|
+
p {
|
150
|
+
margin : bold;
|
151
|
+
}
|
152
|
+
CSS
|
153
|
+
|
154
|
+
it { should_not report_lint }
|
155
|
+
end
|
156
|
+
|
157
|
+
context 'when the colon after a property is followed by multiple spaces' do
|
158
|
+
let(:css) { <<-CSS }
|
159
|
+
p {
|
160
|
+
margin: bold;
|
161
|
+
}
|
162
|
+
CSS
|
163
|
+
|
164
|
+
it { should_not report_lint }
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
context 'when aligned property values are preferred' do
|
169
|
+
let(:style) { 'aligned' }
|
170
|
+
|
171
|
+
context 'when the colon after a single property is not followed by space' do
|
172
|
+
let(:css) { <<-CSS }
|
173
|
+
p {
|
174
|
+
margin:0;
|
175
|
+
}
|
176
|
+
CSS
|
177
|
+
|
178
|
+
it { should_not report_lint }
|
179
|
+
end
|
180
|
+
|
181
|
+
context 'when the colon after a single property is followed by a space' do
|
182
|
+
let(:css) { <<-CSS }
|
183
|
+
p {
|
184
|
+
margin: 0;
|
185
|
+
}
|
186
|
+
CSS
|
187
|
+
|
188
|
+
it { should_not report_lint }
|
189
|
+
end
|
190
|
+
|
191
|
+
context 'when properties are not aligned' do
|
192
|
+
let(:css) { <<-CSS }
|
193
|
+
p {
|
194
|
+
content: 'hello';
|
195
|
+
margin: 0;
|
196
|
+
padding: 0;
|
197
|
+
}
|
198
|
+
CSS
|
199
|
+
|
200
|
+
it { should report_lint line: 2 }
|
201
|
+
end
|
202
|
+
|
203
|
+
context 'when properties aligned but the names are not' do
|
204
|
+
let(:css) { <<-CSS }
|
205
|
+
p {
|
206
|
+
content: 'hello';
|
207
|
+
margin: 0;
|
208
|
+
padding: 0;
|
209
|
+
}
|
210
|
+
CSS
|
211
|
+
|
212
|
+
it { should_not report_lint }
|
213
|
+
end
|
214
|
+
|
215
|
+
context 'when properties aligned but the names with spaces are not' do
|
216
|
+
let(:css) { <<-CSS }
|
217
|
+
p {
|
218
|
+
content : 'hello';
|
219
|
+
margin : 0;
|
220
|
+
padding : 0;
|
221
|
+
}
|
222
|
+
CSS
|
223
|
+
|
224
|
+
it { should_not report_lint }
|
225
|
+
end
|
226
|
+
|
227
|
+
context 'when properties are aligned' do
|
228
|
+
let(:css) { <<-CSS }
|
229
|
+
p {
|
230
|
+
margin: 0;
|
231
|
+
padding: 0;
|
232
|
+
}
|
233
|
+
CSS
|
234
|
+
|
235
|
+
it { should_not report_lint }
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::SpaceAfterPropertyName do
|
4
|
+
context 'when a property name is followed by a space' do
|
5
|
+
let(:css) { <<-CSS }
|
6
|
+
p {
|
7
|
+
margin : 0;
|
8
|
+
}
|
9
|
+
CSS
|
10
|
+
|
11
|
+
it { should report_lint line: 2 }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when a property name is not followed by a space' do
|
15
|
+
let(:css) { <<-CSS }
|
16
|
+
p {
|
17
|
+
margin: 0;
|
18
|
+
}
|
19
|
+
CSS
|
20
|
+
|
21
|
+
it { should_not report_lint }
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,447 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::SpaceBeforeBrace do
|
4
|
+
context 'with a @at-root block' do
|
5
|
+
context 'when brace is preceded by a space' do
|
6
|
+
let(:css) { <<-CSS }
|
7
|
+
.parent {
|
8
|
+
@at-root .child {
|
9
|
+
}
|
10
|
+
}
|
11
|
+
CSS
|
12
|
+
|
13
|
+
it { should_not report_lint }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when brace is preceded by multiple spaces' do
|
17
|
+
let(:css) { <<-CSS }
|
18
|
+
.parent {
|
19
|
+
@at-root .child {
|
20
|
+
}
|
21
|
+
}
|
22
|
+
CSS
|
23
|
+
|
24
|
+
it { should report_lint line: 2 }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when brace is not preceded by a space' do
|
28
|
+
let(:css) { <<-CSS }
|
29
|
+
.parent {
|
30
|
+
@at-root .child{
|
31
|
+
}
|
32
|
+
}
|
33
|
+
CSS
|
34
|
+
|
35
|
+
it { should report_lint line: 2 }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with an @each block' do
|
40
|
+
context 'when brace is preceded by a space' do
|
41
|
+
let(:css) { <<-CSS }
|
42
|
+
@each $item in $list {
|
43
|
+
}
|
44
|
+
CSS
|
45
|
+
|
46
|
+
it { should_not report_lint }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when brace is preceded by multiple spaces' do
|
50
|
+
let(:css) { <<-CSS }
|
51
|
+
@each $item in $list {
|
52
|
+
}
|
53
|
+
CSS
|
54
|
+
|
55
|
+
it { should report_lint line: 1 }
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when brace is not preceded by a space' do
|
59
|
+
let(:css) { <<-CSS }
|
60
|
+
@each $item in $list{
|
61
|
+
}
|
62
|
+
CSS
|
63
|
+
|
64
|
+
it { should report_lint line: 1 }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'with a @for block' do
|
69
|
+
context 'when brace is preceded by a space' do
|
70
|
+
let(:css) { <<-CSS }
|
71
|
+
@for $i from $start to $end {
|
72
|
+
}
|
73
|
+
CSS
|
74
|
+
|
75
|
+
it { should_not report_lint }
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when brace is preceded by multiple spaces' do
|
79
|
+
let(:css) { <<-CSS }
|
80
|
+
@for $i from $start to $end {
|
81
|
+
}
|
82
|
+
CSS
|
83
|
+
|
84
|
+
it { should report_lint line: 1 }
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when brace is not preceded by a space' do
|
88
|
+
let(:css) { <<-CSS }
|
89
|
+
@for $i from $start to $end{
|
90
|
+
}
|
91
|
+
CSS
|
92
|
+
|
93
|
+
it { should report_lint line: 1 }
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'with a @while block' do
|
98
|
+
context 'when brace is preceded by a space' do
|
99
|
+
let(:css) { <<-CSS }
|
100
|
+
@while $condition {
|
101
|
+
}
|
102
|
+
CSS
|
103
|
+
|
104
|
+
it { should_not report_lint }
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'when brace is preceded by multiple spaces' do
|
108
|
+
let(:css) { <<-CSS }
|
109
|
+
@while $condition {
|
110
|
+
}
|
111
|
+
CSS
|
112
|
+
|
113
|
+
it { should report_lint line: 1 }
|
114
|
+
end
|
115
|
+
|
116
|
+
context 'when brace is not preceded by a space' do
|
117
|
+
let(:css) { <<-CSS }
|
118
|
+
@while $condition{
|
119
|
+
}
|
120
|
+
CSS
|
121
|
+
|
122
|
+
it { should report_lint line: 1 }
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context 'with a rule selector' do
|
127
|
+
context 'when brace is preceded by a space' do
|
128
|
+
let(:css) { <<-CSS }
|
129
|
+
p {
|
130
|
+
}
|
131
|
+
CSS
|
132
|
+
|
133
|
+
it { should_not report_lint }
|
134
|
+
end
|
135
|
+
|
136
|
+
context 'when brace is preceded by multiple spaces' do
|
137
|
+
let(:css) { <<-CSS }
|
138
|
+
p {
|
139
|
+
}
|
140
|
+
CSS
|
141
|
+
|
142
|
+
it { should report_lint line: 1 }
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'when brace is not preceded by a space' do
|
146
|
+
let(:css) { <<-CSS }
|
147
|
+
p{
|
148
|
+
}
|
149
|
+
CSS
|
150
|
+
|
151
|
+
it { should report_lint line: 1 }
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'when brace is in a single line rule set' do
|
155
|
+
let(:css) { <<-CSS }
|
156
|
+
.single-line-selector{color: #f00;}
|
157
|
+
CSS
|
158
|
+
|
159
|
+
it { should report_lint line: 1 }
|
160
|
+
end
|
161
|
+
|
162
|
+
context 'when brace is following a multi-selector rule set' do
|
163
|
+
let(:css) { <<-CSS }
|
164
|
+
.selector1,
|
165
|
+
.selector2,
|
166
|
+
.selector3{
|
167
|
+
}
|
168
|
+
CSS
|
169
|
+
|
170
|
+
it { should report_lint line: 3 }
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
context 'with a function declaration' do
|
175
|
+
context 'with arguments' do
|
176
|
+
context 'when brace is preceded by a space' do
|
177
|
+
let(:css) { <<-CSS }
|
178
|
+
@function func($arg, $arg2) {
|
179
|
+
}
|
180
|
+
CSS
|
181
|
+
|
182
|
+
it { should_not report_lint }
|
183
|
+
end
|
184
|
+
|
185
|
+
context 'when brace is preceded by multiple spaces' do
|
186
|
+
let(:css) { <<-CSS }
|
187
|
+
@function func($arg, $arg2) {
|
188
|
+
}
|
189
|
+
CSS
|
190
|
+
|
191
|
+
it { should report_lint line: 1 }
|
192
|
+
end
|
193
|
+
|
194
|
+
context 'when brace is not preceded by a space' do
|
195
|
+
let(:css) { <<-CSS }
|
196
|
+
@function func($arg, $arg2){
|
197
|
+
}
|
198
|
+
CSS
|
199
|
+
|
200
|
+
it { should report_lint line: 1 }
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
context 'without arguments' do
|
205
|
+
context 'when brace is preceded by a space' do
|
206
|
+
let(:css) { <<-CSS }
|
207
|
+
@function func() {
|
208
|
+
}
|
209
|
+
CSS
|
210
|
+
|
211
|
+
it { should_not report_lint }
|
212
|
+
end
|
213
|
+
|
214
|
+
context 'when brace is preceded by multiple spaces' do
|
215
|
+
let(:css) { <<-CSS }
|
216
|
+
@function func() {
|
217
|
+
}
|
218
|
+
CSS
|
219
|
+
|
220
|
+
it { should report_lint line: 1 }
|
221
|
+
end
|
222
|
+
|
223
|
+
context 'when brace is not preceded by a space' do
|
224
|
+
let(:css) { <<-CSS }
|
225
|
+
@function func(){
|
226
|
+
}
|
227
|
+
CSS
|
228
|
+
|
229
|
+
it { should report_lint line: 1 }
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
context 'with a mixin declaration' do
|
235
|
+
context 'with arguments' do
|
236
|
+
context 'when brace is preceded by a space' do
|
237
|
+
let(:css) { <<-CSS }
|
238
|
+
@mixin mixin($arg, $arg2) {
|
239
|
+
}
|
240
|
+
CSS
|
241
|
+
|
242
|
+
it { should_not report_lint }
|
243
|
+
end
|
244
|
+
|
245
|
+
context 'when brace is preceded by multiple spaces' do
|
246
|
+
let(:css) { <<-CSS }
|
247
|
+
@mixin mixin($arg, $arg2) {
|
248
|
+
}
|
249
|
+
CSS
|
250
|
+
|
251
|
+
it { should report_lint line: 1 }
|
252
|
+
end
|
253
|
+
|
254
|
+
context 'when brace is not preceded by a space' do
|
255
|
+
let(:css) { <<-CSS }
|
256
|
+
@mixin mixin($arg, $arg2){
|
257
|
+
}
|
258
|
+
CSS
|
259
|
+
|
260
|
+
it { should report_lint line: 1 }
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
context 'without arguments' do
|
265
|
+
context 'when brace is preceded by a space' do
|
266
|
+
let(:css) { <<-CSS }
|
267
|
+
@mixin mixin {
|
268
|
+
}
|
269
|
+
CSS
|
270
|
+
|
271
|
+
it { should_not report_lint }
|
272
|
+
end
|
273
|
+
|
274
|
+
context 'when brace is preceded by multiple spaces' do
|
275
|
+
let(:css) { <<-CSS }
|
276
|
+
@mixin mixin {
|
277
|
+
}
|
278
|
+
CSS
|
279
|
+
|
280
|
+
it { should report_lint line: 1 }
|
281
|
+
end
|
282
|
+
|
283
|
+
context 'when brace is not preceded by a space' do
|
284
|
+
let(:css) { <<-CSS }
|
285
|
+
@mixin mixin{
|
286
|
+
}
|
287
|
+
CSS
|
288
|
+
|
289
|
+
it { should report_lint line: 1 }
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
context 'with a mixin include with braces' do
|
295
|
+
context 'with arguments' do
|
296
|
+
context 'when brace is preceded by a space' do
|
297
|
+
let(:css) { <<-CSS }
|
298
|
+
@include mixin(arg, arg2) {
|
299
|
+
}
|
300
|
+
CSS
|
301
|
+
|
302
|
+
it { should_not report_lint }
|
303
|
+
end
|
304
|
+
|
305
|
+
context 'when brace is preceded by multiple spaces' do
|
306
|
+
let(:css) { <<-CSS }
|
307
|
+
@include mixin(arg, arg2) {
|
308
|
+
}
|
309
|
+
CSS
|
310
|
+
|
311
|
+
it { should report_lint line: 1 }
|
312
|
+
end
|
313
|
+
|
314
|
+
context 'when brace is not preceded by a space' do
|
315
|
+
let(:css) { <<-CSS }
|
316
|
+
@include mixin(arg, arg2){
|
317
|
+
}
|
318
|
+
CSS
|
319
|
+
|
320
|
+
it { should report_lint line: 1 }
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
context 'without arguments' do
|
325
|
+
context 'when brace is preceded by a space' do
|
326
|
+
let(:css) { <<-CSS }
|
327
|
+
@include mixin {
|
328
|
+
}
|
329
|
+
CSS
|
330
|
+
|
331
|
+
it { should_not report_lint }
|
332
|
+
end
|
333
|
+
|
334
|
+
context 'when brace is preceded by multiple spaces' do
|
335
|
+
let(:css) { <<-CSS }
|
336
|
+
@include mixin {
|
337
|
+
}
|
338
|
+
CSS
|
339
|
+
|
340
|
+
it { should report_lint line: 1 }
|
341
|
+
end
|
342
|
+
|
343
|
+
context 'when brace is not preceded by a space' do
|
344
|
+
let(:css) { <<-CSS }
|
345
|
+
@include mixin{
|
346
|
+
}
|
347
|
+
CSS
|
348
|
+
|
349
|
+
it { should report_lint line: 1 }
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
context 'with a mixin include with no braces' do
|
355
|
+
context 'with arguments' do
|
356
|
+
let(:css) { <<-CSS }
|
357
|
+
@include mixin(arg, arg2);
|
358
|
+
CSS
|
359
|
+
|
360
|
+
it { should_not report_lint }
|
361
|
+
end
|
362
|
+
|
363
|
+
context 'without arguments' do
|
364
|
+
let(:css) { <<-CSS }
|
365
|
+
@include mixin;
|
366
|
+
CSS
|
367
|
+
|
368
|
+
it { should_not report_lint }
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
context 'when curly brace appears in a string' do
|
373
|
+
let(:css) { <<-CSS }
|
374
|
+
a {
|
375
|
+
content: "{";
|
376
|
+
}
|
377
|
+
CSS
|
378
|
+
|
379
|
+
it { should_not report_lint }
|
380
|
+
end
|
381
|
+
|
382
|
+
context 'when using #{} interpolation' do
|
383
|
+
let(:css) { <<-CSS }
|
384
|
+
@mixin test-mixin($class, $prop, $pixels) {
|
385
|
+
.\#{$class} {
|
386
|
+
\#{$prop}: \#{$pixels}px;
|
387
|
+
}
|
388
|
+
}
|
389
|
+
CSS
|
390
|
+
|
391
|
+
it { should_not report_lint }
|
392
|
+
end
|
393
|
+
|
394
|
+
context 'when using braces in comments' do
|
395
|
+
let(:css) { '// ({x})' }
|
396
|
+
|
397
|
+
it { should_not report_lint }
|
398
|
+
end
|
399
|
+
|
400
|
+
context 'when blocks occupy a single line' do
|
401
|
+
let(:linter_config) { { 'allow_single_line_padding' => allow_single_line_padding } }
|
402
|
+
|
403
|
+
let(:css) { <<-CSS }
|
404
|
+
p{ }
|
405
|
+
p { }
|
406
|
+
p { &:before { } }
|
407
|
+
p { &:before{ } }
|
408
|
+
CSS
|
409
|
+
|
410
|
+
context 'and the `allow_extra_spaces` option is true' do
|
411
|
+
let(:allow_single_line_padding) { true }
|
412
|
+
|
413
|
+
it { should report_lint line: 1 }
|
414
|
+
it { should_not report_lint line: 2 }
|
415
|
+
it { should_not report_lint line: 3 }
|
416
|
+
it { should report_lint line: 4 }
|
417
|
+
end
|
418
|
+
|
419
|
+
context 'and the `allow_extra_spaces` option is false' do
|
420
|
+
let(:allow_single_line_padding) { false }
|
421
|
+
|
422
|
+
it { should report_lint line: 1 }
|
423
|
+
it { should_not report_lint line: 2 }
|
424
|
+
it { should report_lint line: 3 }
|
425
|
+
it { should report_lint line: 4 }
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
context 'when curly brace is in single quotes' do
|
430
|
+
let(:css) { <<-CSS }
|
431
|
+
@if $token == '{' {
|
432
|
+
}
|
433
|
+
CSS
|
434
|
+
|
435
|
+
it { should_not report_lint }
|
436
|
+
end
|
437
|
+
|
438
|
+
context 'when curly brace is on own line' do
|
439
|
+
let(:css) { <<-CSS }
|
440
|
+
.class
|
441
|
+
{
|
442
|
+
}
|
443
|
+
CSS
|
444
|
+
|
445
|
+
it { should_not report_lint }
|
446
|
+
end
|
447
|
+
end
|