scss-lint 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/default.yml +19 -1
- data/data/properties.txt +4 -0
- data/lib/scss_lint.rb +1 -0
- data/lib/scss_lint/cli.rb +4 -42
- data/lib/scss_lint/config.rb +1 -45
- data/lib/scss_lint/control_comment_processor.rb +47 -15
- data/lib/scss_lint/file_finder.rb +57 -0
- data/lib/scss_lint/linter/bang_format.rb +1 -1
- data/lib/scss_lint/linter/border_zero.rb +25 -9
- data/lib/scss_lint/linter/color_keyword.rb +3 -13
- data/lib/scss_lint/linter/color_variable.rb +36 -0
- data/lib/scss_lint/linter/declaration_order.rb +2 -2
- data/lib/scss_lint/linter/important_rule.rb +12 -0
- data/lib/scss_lint/linter/indentation.rb +7 -1
- data/lib/scss_lint/linter/property_count.rb +44 -0
- data/lib/scss_lint/linter/property_sort_order.rb +73 -19
- data/lib/scss_lint/linter/string_quotes.rb +9 -0
- data/lib/scss_lint/linter/variable_for_property.rb +20 -0
- data/lib/scss_lint/linter/vendor_prefixes.rb +3 -3
- data/lib/scss_lint/runner.rb +5 -7
- data/lib/scss_lint/utils.rb +34 -0
- data/lib/scss_lint/version.rb +1 -1
- data/spec/scss_lint/cli_spec.rb +1 -1
- data/spec/scss_lint/config_spec.rb +4 -203
- data/spec/scss_lint/engine_spec.rb +4 -4
- data/spec/scss_lint/file_finder_spec.rb +110 -0
- data/spec/scss_lint/linter/bang_format_spec.rb +28 -18
- data/spec/scss_lint/linter/border_zero_spec.rb +50 -16
- data/spec/scss_lint/linter/color_keyword_spec.rb +16 -16
- data/spec/scss_lint/linter/color_variable_spec.rb +102 -0
- data/spec/scss_lint/linter/comment_spec.rb +9 -9
- data/spec/scss_lint/linter/compass/property_with_mixin_spec.rb +10 -10
- data/spec/scss_lint/linter/debug_statement_spec.rb +4 -4
- data/spec/scss_lint/linter/declaration_order_spec.rb +80 -80
- data/spec/scss_lint/linter/duplicate_property_spec.rb +30 -30
- data/spec/scss_lint/linter/else_placement_spec.rb +16 -16
- data/spec/scss_lint/linter/empty_line_between_blocks_spec.rb +38 -38
- data/spec/scss_lint/linter/empty_rule_spec.rb +4 -4
- data/spec/scss_lint/linter/final_newline_spec.rb +6 -6
- data/spec/scss_lint/linter/hex_length_spec.rb +16 -16
- data/spec/scss_lint/linter/hex_notation_spec.rb +16 -16
- data/spec/scss_lint/linter/hex_validation_spec.rb +6 -6
- data/spec/scss_lint/linter/id_selector_spec.rb +10 -10
- data/spec/scss_lint/linter/import_path_spec.rb +45 -45
- data/spec/scss_lint/linter/important_rule_spec.rb +43 -0
- data/spec/scss_lint/linter/indentation_spec.rb +103 -43
- data/spec/scss_lint/linter/leading_zero_spec.rb +45 -45
- data/spec/scss_lint/linter/mergeable_selector_spec.rb +32 -32
- data/spec/scss_lint/linter/name_format_spec.rb +75 -41
- data/spec/scss_lint/linter/nesting_depth_spec.rb +14 -14
- data/spec/scss_lint/linter/placeholder_in_extend_spec.rb +12 -12
- data/spec/scss_lint/linter/property_count_spec.rb +104 -0
- data/spec/scss_lint/linter/property_sort_order_spec.rb +138 -48
- data/spec/scss_lint/linter/property_spelling_spec.rb +14 -14
- data/spec/scss_lint/linter/qualifying_element_spec.rb +26 -26
- data/spec/scss_lint/linter/selector_depth_spec.rb +26 -26
- data/spec/scss_lint/linter/selector_format_spec.rb +114 -114
- data/spec/scss_lint/linter/shorthand_spec.rb +32 -32
- data/spec/scss_lint/linter/single_line_per_property_spec.rb +10 -10
- data/spec/scss_lint/linter/single_line_per_selector_spec.rb +24 -24
- data/spec/scss_lint/linter/space_after_comma_spec.rb +60 -60
- data/spec/scss_lint/linter/space_after_property_colon_spec.rb +44 -44
- data/spec/scss_lint/linter/space_after_property_name_spec.rb +6 -6
- data/spec/scss_lint/linter/space_before_brace_spec.rb +119 -119
- data/spec/scss_lint/linter/space_between_parens_spec.rb +48 -48
- data/spec/scss_lint/linter/string_quotes_spec.rb +74 -62
- data/spec/scss_lint/linter/trailing_semicolon_spec.rb +53 -54
- data/spec/scss_lint/linter/trailing_zero_spec.rb +34 -34
- data/spec/scss_lint/linter/unnecessary_mantissa_spec.rb +10 -10
- data/spec/scss_lint/linter/unnecessary_parent_reference_spec.rb +18 -18
- data/spec/scss_lint/linter/url_format_spec.rb +4 -4
- data/spec/scss_lint/linter/url_quotes_spec.rb +14 -14
- data/spec/scss_lint/linter/variable_for_property_spec.rb +115 -0
- data/spec/scss_lint/linter/vendor_prefixes_spec.rb +66 -56
- data/spec/scss_lint/linter/zero_unit_spec.rb +22 -22
- data/spec/scss_lint/linter_spec.rb +72 -28
- data/spec/scss_lint/runner_spec.rb +0 -1
- data/spec/scss_lint/selector_visitor_spec.rb +23 -23
- data/spec/spec_helper.rb +2 -2
- metadata +27 -12
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::ImportantRule do
|
4
|
+
context 'when !important is not used' do
|
5
|
+
let(:scss) { <<-SCSS }
|
6
|
+
p {
|
7
|
+
color: #000;
|
8
|
+
}
|
9
|
+
SCSS
|
10
|
+
|
11
|
+
it { should_not report_lint }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when !important is used' do
|
15
|
+
let(:scss) { <<-SCSS }
|
16
|
+
p {
|
17
|
+
color: #000 !important;
|
18
|
+
}
|
19
|
+
SCSS
|
20
|
+
|
21
|
+
it { should report_lint line: 2 }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when !important is used in property containing Sass script' do
|
25
|
+
let(:scss) { <<-SCSS }
|
26
|
+
p {
|
27
|
+
color: \#{$my-var} !important;
|
28
|
+
}
|
29
|
+
SCSS
|
30
|
+
|
31
|
+
it { should report_lint line: 2 }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when property contains a list literal with an empty list' do
|
35
|
+
let(:scss) { <<-SCSS }
|
36
|
+
p {
|
37
|
+
content: 0 ();
|
38
|
+
}
|
39
|
+
SCSS
|
40
|
+
|
41
|
+
it { should_not report_lint }
|
42
|
+
end
|
43
|
+
end
|
@@ -2,33 +2,33 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SCSSLint::Linter::Indentation do
|
4
4
|
context 'when a line at the root level is indented' do
|
5
|
-
let(:
|
5
|
+
let(:scss) { <<-SCSS }
|
6
6
|
$var: 5px;
|
7
7
|
$other: 10px;
|
8
|
-
|
8
|
+
SCSS
|
9
9
|
|
10
10
|
it { should_not report_lint line: 1 }
|
11
11
|
it { should report_lint line: 2 }
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'when a line in a rule set is properly indented' do
|
15
|
-
let(:
|
15
|
+
let(:scss) { <<-SCSS }
|
16
16
|
p {
|
17
17
|
margin: 0;
|
18
18
|
}
|
19
|
-
|
19
|
+
SCSS
|
20
20
|
|
21
21
|
it { should_not report_lint }
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'when lines in a rule set are not properly indented' do
|
25
|
-
let(:
|
25
|
+
let(:scss) { <<-SCSS }
|
26
26
|
p {
|
27
27
|
margin: 0;
|
28
28
|
padding: 1em;
|
29
29
|
opacity: 0.5;
|
30
30
|
}
|
31
|
-
|
31
|
+
SCSS
|
32
32
|
|
33
33
|
it { should report_lint line: 2 }
|
34
34
|
it { should_not report_lint line: 3 }
|
@@ -36,13 +36,13 @@ describe SCSSLint::Linter::Indentation do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
context 'when selector of a nested rule set is not properly indented' do
|
39
|
-
let(:
|
39
|
+
let(:scss) { <<-SCSS }
|
40
40
|
p {
|
41
41
|
em {
|
42
42
|
font-style: italic;
|
43
43
|
}
|
44
44
|
}
|
45
|
-
|
45
|
+
SCSS
|
46
46
|
|
47
47
|
it { should report_lint line: 2 }
|
48
48
|
it { should_not report_lint line: 3 }
|
@@ -50,7 +50,7 @@ describe SCSSLint::Linter::Indentation do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
context 'when multi-line selector of a nested rule set is not properly indented' do
|
53
|
-
let(:
|
53
|
+
let(:scss) { <<-SCSS }
|
54
54
|
p {
|
55
55
|
b,
|
56
56
|
em,
|
@@ -58,7 +58,7 @@ describe SCSSLint::Linter::Indentation do
|
|
58
58
|
font-style: italic;
|
59
59
|
}
|
60
60
|
}
|
61
|
-
|
61
|
+
SCSS
|
62
62
|
|
63
63
|
it { should report_lint line: 2 }
|
64
64
|
it { should_not report_lint line: 3 }
|
@@ -67,28 +67,28 @@ describe SCSSLint::Linter::Indentation do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
context 'when a property is on the same line as its rule selector' do
|
70
|
-
let(:
|
70
|
+
let(:scss) { 'h1 { margin: 5px; }' }
|
71
71
|
it { should_not report_lint }
|
72
72
|
end
|
73
73
|
|
74
74
|
context 'when an argument list spans multiple lines' do
|
75
|
-
let(:
|
75
|
+
let(:scss) { <<-SCSS }
|
76
76
|
@include mixin(one,
|
77
77
|
two,
|
78
78
|
three);
|
79
|
-
|
79
|
+
SCSS
|
80
80
|
|
81
81
|
it { should_not report_lint }
|
82
82
|
end
|
83
83
|
|
84
84
|
context 'when an argument list of an improperly indented script spans multiple lines' do
|
85
|
-
let(:
|
85
|
+
let(:scss) { <<-SCSS }
|
86
86
|
p {
|
87
87
|
@include mixin(one,
|
88
88
|
two,
|
89
89
|
three);
|
90
90
|
}
|
91
|
-
|
91
|
+
SCSS
|
92
92
|
|
93
93
|
it { should report_lint line: 2 }
|
94
94
|
it { should_not report_lint line: 3 }
|
@@ -96,59 +96,59 @@ describe SCSSLint::Linter::Indentation do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
context 'when an if statement is incorrectly indented' do
|
99
|
-
let(:
|
99
|
+
let(:scss) { <<-SCSS }
|
100
100
|
$condition: true;
|
101
101
|
@if $condition {
|
102
102
|
padding: 0;
|
103
103
|
}
|
104
|
-
|
104
|
+
SCSS
|
105
105
|
|
106
106
|
it { should report_lint line: 2 }
|
107
107
|
end
|
108
108
|
|
109
109
|
context 'when an if statement is accompanied by a correctly indented else statement' do
|
110
|
-
let(:
|
110
|
+
let(:scss) { <<-SCSS }
|
111
111
|
@if $condition {
|
112
112
|
padding: 0;
|
113
113
|
} @else {
|
114
114
|
margin: 0;
|
115
115
|
}
|
116
|
-
|
116
|
+
SCSS
|
117
117
|
|
118
118
|
it { should_not report_lint }
|
119
119
|
end
|
120
120
|
|
121
121
|
context 'when @at-root directive contains correctly indented children' do
|
122
|
-
let(:
|
122
|
+
let(:scss) { <<-SCSS }
|
123
123
|
.block {
|
124
124
|
@at-root {
|
125
125
|
.something {}
|
126
126
|
}
|
127
127
|
}
|
128
|
-
|
128
|
+
SCSS
|
129
129
|
|
130
130
|
it { should_not report_lint }
|
131
131
|
end
|
132
132
|
|
133
133
|
context 'when @at-root directive with an inline selector contains correctly indented children' do
|
134
|
-
let(:
|
134
|
+
let(:scss) { <<-SCSS }
|
135
135
|
.block {
|
136
136
|
@at-root .something {
|
137
137
|
.something-else {}
|
138
138
|
}
|
139
139
|
}
|
140
|
-
|
140
|
+
SCSS
|
141
141
|
|
142
142
|
it { should_not report_lint }
|
143
143
|
end
|
144
144
|
|
145
145
|
context 'when @at-root directive with no inline selector contains comment' do
|
146
|
-
let(:
|
146
|
+
let(:scss) { <<-SCSS }
|
147
147
|
@at-root {
|
148
148
|
// A comment that causes a crash
|
149
149
|
.something-else {}
|
150
150
|
}
|
151
|
-
|
151
|
+
SCSS
|
152
152
|
|
153
153
|
it { should_not report_lint }
|
154
154
|
end
|
@@ -156,63 +156,63 @@ describe SCSSLint::Linter::Indentation do
|
|
156
156
|
context 'when the indentation width has been explicitly set' do
|
157
157
|
let(:linter_config) { { 'width' => 3 } }
|
158
158
|
|
159
|
-
let(:
|
159
|
+
let(:scss) { <<-SCSS }
|
160
160
|
p {
|
161
161
|
margin: 0;
|
162
162
|
padding: 5px;
|
163
163
|
}
|
164
|
-
|
164
|
+
SCSS
|
165
165
|
|
166
166
|
it { should report_lint line: 2 }
|
167
167
|
it { should_not report_lint line: 3 }
|
168
168
|
end
|
169
169
|
|
170
170
|
context 'when there are selectors across multiple lines' do
|
171
|
-
let(:
|
171
|
+
let(:scss) { <<-SCSS }
|
172
172
|
.class1,
|
173
173
|
.class2 {
|
174
174
|
margin: 0;
|
175
175
|
padding: 5px;
|
176
176
|
}
|
177
|
-
|
177
|
+
SCSS
|
178
178
|
|
179
179
|
it { should_not report_lint }
|
180
180
|
end
|
181
181
|
|
182
182
|
context 'when there are selectors across multiple lines with a single line block' do
|
183
|
-
let(:
|
183
|
+
let(:scss) { <<-SCSS }
|
184
184
|
.class1,
|
185
185
|
.class2 { margin: 0; }
|
186
|
-
|
186
|
+
SCSS
|
187
187
|
|
188
188
|
it { should_not report_lint }
|
189
189
|
end
|
190
190
|
|
191
191
|
context 'when a comment node precedes a node' do
|
192
|
-
let(:
|
192
|
+
let(:scss) { <<-SCSS }
|
193
193
|
// A comment
|
194
194
|
$var: 1;
|
195
|
-
|
195
|
+
SCSS
|
196
196
|
|
197
197
|
it { should_not report_lint }
|
198
198
|
end
|
199
199
|
|
200
200
|
context 'when a line is indented with tabs' do
|
201
|
-
let(:
|
201
|
+
let(:scss) { <<-SCSS }
|
202
202
|
p {
|
203
203
|
\tmargin: 0;
|
204
204
|
}
|
205
|
-
|
205
|
+
SCSS
|
206
206
|
|
207
207
|
it { should report_lint line: 2 }
|
208
208
|
end
|
209
209
|
|
210
210
|
context 'when a line contains a mix of tabs and spaces' do
|
211
|
-
let(:
|
211
|
+
let(:scss) { <<-SCSS }
|
212
212
|
p {
|
213
213
|
\tmargin: 0;
|
214
214
|
}
|
215
|
-
|
215
|
+
SCSS
|
216
216
|
|
217
217
|
it { should report_lint line: 2 }
|
218
218
|
end
|
@@ -221,31 +221,91 @@ describe SCSSLint::Linter::Indentation do
|
|
221
221
|
let(:linter_config) { { 'character' => 'tab', 'width' => 1 } }
|
222
222
|
|
223
223
|
context 'and the line is indented correctly' do
|
224
|
-
let(:
|
224
|
+
let(:scss) { <<-SCSS }
|
225
225
|
p {
|
226
226
|
\tmargin: 0;
|
227
227
|
}
|
228
|
-
|
228
|
+
SCSS
|
229
229
|
|
230
230
|
it { should_not report_lint }
|
231
231
|
end
|
232
232
|
|
233
233
|
context 'and the line is incorrectly indented' do
|
234
|
-
let(:
|
234
|
+
let(:scss) { <<-SCSS }
|
235
235
|
p {
|
236
236
|
\t\tmargin: 0;
|
237
237
|
}
|
238
|
-
|
238
|
+
SCSS
|
239
239
|
|
240
240
|
it { should report_lint line: 2 }
|
241
241
|
end
|
242
242
|
|
243
243
|
context 'and the line is indented with spaces' do
|
244
|
-
let(:
|
244
|
+
let(:scss) { <<-SCSS }
|
245
245
|
p {
|
246
246
|
margin: 0;
|
247
247
|
}
|
248
|
-
|
248
|
+
SCSS
|
249
|
+
|
250
|
+
it { should report_lint line: 2 }
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
context 'when indentation in non-nested code is allowed' do
|
255
|
+
let(:linter_config) do
|
256
|
+
{ 'allow_non_nested_indentation' => true,
|
257
|
+
'character' => 'space',
|
258
|
+
'width' => 2,
|
259
|
+
}
|
260
|
+
end
|
261
|
+
|
262
|
+
context 'and non-nested code is indented' do
|
263
|
+
let(:scss) { <<-SCSS }
|
264
|
+
.component {}
|
265
|
+
.component__image {}
|
266
|
+
.component__text {}
|
267
|
+
.component-subblock {}
|
268
|
+
.component-subblock__text {}
|
269
|
+
.component-category {}
|
270
|
+
.component-other {}
|
271
|
+
SCSS
|
272
|
+
|
273
|
+
it { should_not report_lint }
|
274
|
+
end
|
275
|
+
|
276
|
+
context 'and nested code is indented too much' do
|
277
|
+
let(:scss) { <<-SCSS }
|
278
|
+
.component {
|
279
|
+
.component__image {}
|
280
|
+
.component__text {}
|
281
|
+
.component-subblock {}
|
282
|
+
}
|
283
|
+
SCSS
|
284
|
+
|
285
|
+
it { should_not report_lint line: 2 }
|
286
|
+
it { should_not report_lint line: 3 }
|
287
|
+
it { should report_lint line: 4 }
|
288
|
+
end
|
289
|
+
|
290
|
+
context 'and nested code is indented too little' do
|
291
|
+
let(:scss) { <<-SCSS }
|
292
|
+
.component {
|
293
|
+
.component__image {}
|
294
|
+
.component__text {}
|
295
|
+
.component-subblock {}
|
296
|
+
}
|
297
|
+
SCSS
|
298
|
+
|
299
|
+
it { should_not report_lint line: 2 }
|
300
|
+
it { should_not report_lint line: 3 }
|
301
|
+
it { should report_lint line: 4 }
|
302
|
+
end
|
303
|
+
|
304
|
+
context 'and a non-nested non-ruleset is incorrectly indented' do
|
305
|
+
let(:scss) { <<-SCSS }
|
306
|
+
p {}
|
307
|
+
$var: one;
|
308
|
+
SCSS
|
249
309
|
|
250
310
|
it { should report_lint line: 2 }
|
251
311
|
end
|
@@ -2,177 +2,177 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SCSSLint::Linter::LeadingZero do
|
4
4
|
context 'when no values exist' do
|
5
|
-
let(:
|
5
|
+
let(:scss) { <<-SCSS }
|
6
6
|
p {
|
7
7
|
}
|
8
|
-
|
8
|
+
SCSS
|
9
9
|
|
10
10
|
it { should_not report_lint }
|
11
11
|
end
|
12
12
|
|
13
13
|
context 'when a zero exists' do
|
14
|
-
let(:
|
14
|
+
let(:scss) { <<-SCSS }
|
15
15
|
p {
|
16
16
|
margin: 0;
|
17
17
|
}
|
18
|
-
|
18
|
+
SCSS
|
19
19
|
|
20
20
|
it { should_not report_lint }
|
21
21
|
end
|
22
22
|
|
23
23
|
context 'when an integer value exists' do
|
24
|
-
let(:
|
24
|
+
let(:scss) { <<-SCSS }
|
25
25
|
p {
|
26
26
|
line-height: 2;
|
27
27
|
}
|
28
|
-
|
28
|
+
SCSS
|
29
29
|
|
30
30
|
it { should_not report_lint }
|
31
31
|
end
|
32
32
|
|
33
33
|
context 'when an integer value with units exists' do
|
34
|
-
let(:
|
34
|
+
let(:scss) { <<-SCSS }
|
35
35
|
p {
|
36
36
|
margin: 5px;
|
37
37
|
}
|
38
|
-
|
38
|
+
SCSS
|
39
39
|
|
40
40
|
it { should_not report_lint }
|
41
41
|
end
|
42
42
|
|
43
43
|
context 'when a unitless fractional value with no leading zero exists' do
|
44
|
-
let(:
|
44
|
+
let(:scss) { <<-SCSS }
|
45
45
|
p {
|
46
46
|
line-height: .5;
|
47
47
|
}
|
48
|
-
|
48
|
+
SCSS
|
49
49
|
|
50
50
|
it { should_not report_lint }
|
51
51
|
end
|
52
52
|
|
53
53
|
context 'when a negative unitless fractional value with no leading zero exists' do
|
54
|
-
let(:
|
54
|
+
let(:scss) { <<-SCSS }
|
55
55
|
p {
|
56
56
|
line-height: -.5;
|
57
57
|
}
|
58
|
-
|
58
|
+
SCSS
|
59
59
|
|
60
60
|
it { should_not report_lint }
|
61
61
|
end
|
62
62
|
|
63
63
|
context 'when a fractional value with units and no leading zero exists' do
|
64
|
-
let(:
|
64
|
+
let(:scss) { <<-SCSS }
|
65
65
|
p {
|
66
66
|
margin: .5em;
|
67
67
|
}
|
68
|
-
|
68
|
+
SCSS
|
69
69
|
|
70
70
|
it { should_not report_lint }
|
71
71
|
end
|
72
72
|
|
73
73
|
context 'when a negative fractional value with units and no leading zero exists' do
|
74
|
-
let(:
|
74
|
+
let(:scss) { <<-SCSS }
|
75
75
|
p {
|
76
76
|
margin: -.5em;
|
77
77
|
}
|
78
|
-
|
78
|
+
SCSS
|
79
79
|
|
80
80
|
it { should_not report_lint }
|
81
81
|
end
|
82
82
|
|
83
83
|
context 'when a fractional value with a leading zero exists' do
|
84
|
-
let(:
|
84
|
+
let(:scss) { <<-SCSS }
|
85
85
|
p {
|
86
86
|
line-height: 0.5;
|
87
87
|
}
|
88
|
-
|
88
|
+
SCSS
|
89
89
|
|
90
90
|
it { should report_lint line: 2 }
|
91
91
|
end
|
92
92
|
|
93
93
|
context 'when a fractional value with units and a leading zero exists' do
|
94
|
-
let(:
|
94
|
+
let(:scss) { <<-SCSS }
|
95
95
|
p {
|
96
96
|
margin: 0.5em;
|
97
97
|
}
|
98
|
-
|
98
|
+
SCSS
|
99
99
|
|
100
100
|
it { should report_lint line: 2 }
|
101
101
|
end
|
102
102
|
|
103
103
|
context 'when a negative fractional value with units and a leading zero exists' do
|
104
|
-
let(:
|
104
|
+
let(:scss) { <<-SCSS }
|
105
105
|
p {
|
106
106
|
margin: -0.5em;
|
107
107
|
}
|
108
|
-
|
108
|
+
SCSS
|
109
109
|
|
110
110
|
it { should report_lint line: 2 }
|
111
111
|
end
|
112
112
|
|
113
113
|
context 'when a fractional value with a mantissa ending in zero exists' do
|
114
|
-
let(:
|
114
|
+
let(:scss) { <<-SCSS }
|
115
115
|
p {
|
116
116
|
line-height: 10.5;
|
117
117
|
}
|
118
|
-
|
118
|
+
SCSS
|
119
119
|
|
120
120
|
it { should_not report_lint }
|
121
121
|
end
|
122
122
|
|
123
123
|
context 'when multiple fractional values with leading zeros exist' do
|
124
|
-
let(:
|
124
|
+
let(:scss) { <<-SCSS }
|
125
125
|
p {
|
126
126
|
margin: 0.5em 0.5 0.1px 0.9pt;
|
127
127
|
}
|
128
|
-
|
128
|
+
SCSS
|
129
129
|
|
130
130
|
it { should report_lint count: 4, line: 2 }
|
131
131
|
end
|
132
132
|
|
133
133
|
context 'when leading zeros appear in function arguments' do
|
134
|
-
let(:
|
134
|
+
let(:scss) { <<-SCSS }
|
135
135
|
p {
|
136
136
|
margin: some-function(0.5em, 0.4 0.3 .2);
|
137
137
|
}
|
138
|
-
|
138
|
+
SCSS
|
139
139
|
|
140
140
|
it { should report_lint count: 3, line: 2 }
|
141
141
|
end
|
142
142
|
|
143
143
|
context 'when leading zeros appear in mixin arguments' do
|
144
|
-
let(:
|
144
|
+
let(:scss) { <<-SCSS }
|
145
145
|
p {
|
146
146
|
@include some-mixin(0.5em, 0.4 0.3 .2);
|
147
147
|
}
|
148
|
-
|
148
|
+
SCSS
|
149
149
|
|
150
150
|
it { should report_lint count: 3, line: 2 }
|
151
151
|
end
|
152
152
|
|
153
153
|
context 'when leading zeros appear in variable declarations' do
|
154
|
-
let(:
|
154
|
+
let(:scss) { '$some-var: 0.5em;' }
|
155
155
|
|
156
156
|
it { should report_lint line: 1 }
|
157
157
|
end
|
158
158
|
|
159
159
|
context 'when leading zeros appear in named arguments' do
|
160
|
-
let(:
|
160
|
+
let(:scss) { <<-SCSS }
|
161
161
|
p {
|
162
162
|
@include line-clamp($line-height: 0.9, $line-count: 2);
|
163
163
|
}
|
164
|
-
|
164
|
+
SCSS
|
165
165
|
|
166
166
|
it { should report_lint line: 2 }
|
167
167
|
end
|
168
168
|
|
169
169
|
context 'when leading zeros appear in parameter defaults' do
|
170
|
-
let(:
|
170
|
+
let(:scss) { <<-SCSS }
|
171
171
|
@mixin my-mixin($bad-value: 0.5, $good-value: .9, $string-value: "0.9") {
|
172
172
|
margin: $some-value;
|
173
173
|
padding: $some-other-value;
|
174
174
|
}
|
175
|
-
|
175
|
+
SCSS
|
176
176
|
|
177
177
|
it { should report_lint count: 1, line: 1 }
|
178
178
|
end
|
@@ -181,51 +181,51 @@ describe SCSSLint::Linter::LeadingZero do
|
|
181
181
|
let(:linter_config) { { 'style' => 'include_zero' } }
|
182
182
|
|
183
183
|
context 'when a zero exists' do
|
184
|
-
let(:
|
184
|
+
let(:scss) { <<-SCSS }
|
185
185
|
p {
|
186
186
|
margin: 0;
|
187
187
|
}
|
188
|
-
|
188
|
+
SCSS
|
189
189
|
|
190
190
|
it { should_not report_lint }
|
191
191
|
end
|
192
192
|
|
193
193
|
context 'when a non-zero integer value exists' do
|
194
|
-
let(:
|
194
|
+
let(:scss) { <<-SCSS }
|
195
195
|
p {
|
196
196
|
line-height: 2;
|
197
197
|
}
|
198
|
-
|
198
|
+
SCSS
|
199
199
|
|
200
200
|
it { should_not report_lint }
|
201
201
|
end
|
202
202
|
|
203
203
|
context 'when a fractional value with no leading zero exists' do
|
204
|
-
let(:
|
204
|
+
let(:scss) { <<-SCSS }
|
205
205
|
p {
|
206
206
|
padding: .5em;
|
207
207
|
}
|
208
|
-
|
208
|
+
SCSS
|
209
209
|
|
210
210
|
it { should report_lint line: 2 }
|
211
211
|
end
|
212
212
|
|
213
213
|
context 'when a fractional value with leading zero exists' do
|
214
|
-
let(:
|
214
|
+
let(:scss) { <<-SCSS }
|
215
215
|
p {
|
216
216
|
padding: 0.5em;
|
217
217
|
}
|
218
|
-
|
218
|
+
SCSS
|
219
219
|
|
220
220
|
it { should_not report_lint }
|
221
221
|
end
|
222
222
|
|
223
223
|
context 'when a fractional value with a mantissa ending in zero exists' do
|
224
|
-
let(:
|
224
|
+
let(:scss) { <<-SCSS }
|
225
225
|
p {
|
226
226
|
padding: 10.5em;
|
227
227
|
}
|
228
|
-
|
228
|
+
SCSS
|
229
229
|
|
230
230
|
it { should_not report_lint }
|
231
231
|
end
|