scss-lint-bliss 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. data/bin/scss-lint +6 -0
  2. data/config/default.yml +220 -0
  3. data/data/prefixed-identifiers/base.txt +107 -0
  4. data/data/prefixed-identifiers/bourbon.txt +71 -0
  5. data/data/properties.txt +477 -0
  6. data/data/property-sort-orders/concentric.txt +134 -0
  7. data/data/property-sort-orders/recess.txt +149 -0
  8. data/data/property-sort-orders/smacss.txt +137 -0
  9. data/lib/scss_lint.rb +31 -0
  10. data/lib/scss_lint/cli.rb +215 -0
  11. data/lib/scss_lint/config.rb +251 -0
  12. data/lib/scss_lint/constants.rb +8 -0
  13. data/lib/scss_lint/control_comment_processor.rb +126 -0
  14. data/lib/scss_lint/engine.rb +56 -0
  15. data/lib/scss_lint/exceptions.rb +21 -0
  16. data/lib/scss_lint/file_finder.rb +68 -0
  17. data/lib/scss_lint/lint.rb +24 -0
  18. data/lib/scss_lint/linter.rb +161 -0
  19. data/lib/scss_lint/linter/bang_format.rb +52 -0
  20. data/lib/scss_lint/linter/bliss.rb +8 -0
  21. data/lib/scss_lint/linter/bliss/module.rb +101 -0
  22. data/lib/scss_lint/linter/border_zero.rb +39 -0
  23. data/lib/scss_lint/linter/color_keyword.rb +32 -0
  24. data/lib/scss_lint/linter/color_variable.rb +49 -0
  25. data/lib/scss_lint/linter/comment.rb +21 -0
  26. data/lib/scss_lint/linter/compass.rb +7 -0
  27. data/lib/scss_lint/linter/compass/property_with_mixin.rb +47 -0
  28. data/lib/scss_lint/linter/debug_statement.rb +10 -0
  29. data/lib/scss_lint/linter/declaration_order.rb +71 -0
  30. data/lib/scss_lint/linter/duplicate_property.rb +58 -0
  31. data/lib/scss_lint/linter/else_placement.rb +48 -0
  32. data/lib/scss_lint/linter/empty_line_between_blocks.rb +85 -0
  33. data/lib/scss_lint/linter/empty_rule.rb +11 -0
  34. data/lib/scss_lint/linter/final_newline.rb +20 -0
  35. data/lib/scss_lint/linter/hex_length.rb +56 -0
  36. data/lib/scss_lint/linter/hex_notation.rb +38 -0
  37. data/lib/scss_lint/linter/hex_validation.rb +23 -0
  38. data/lib/scss_lint/linter/id_selector.rb +10 -0
  39. data/lib/scss_lint/linter/import_path.rb +62 -0
  40. data/lib/scss_lint/linter/important_rule.rb +12 -0
  41. data/lib/scss_lint/linter/indentation.rb +197 -0
  42. data/lib/scss_lint/linter/leading_zero.rb +49 -0
  43. data/lib/scss_lint/linter/mergeable_selector.rb +60 -0
  44. data/lib/scss_lint/linter/name_format.rb +117 -0
  45. data/lib/scss_lint/linter/nesting_depth.rb +24 -0
  46. data/lib/scss_lint/linter/placeholder_in_extend.rb +22 -0
  47. data/lib/scss_lint/linter/property_count.rb +44 -0
  48. data/lib/scss_lint/linter/property_sort_order.rb +189 -0
  49. data/lib/scss_lint/linter/property_spelling.rb +49 -0
  50. data/lib/scss_lint/linter/property_units.rb +59 -0
  51. data/lib/scss_lint/linter/qualifying_element.rb +42 -0
  52. data/lib/scss_lint/linter/selector_depth.rb +64 -0
  53. data/lib/scss_lint/linter/selector_format.rb +102 -0
  54. data/lib/scss_lint/linter/shorthand.rb +139 -0
  55. data/lib/scss_lint/linter/single_line_per_property.rb +59 -0
  56. data/lib/scss_lint/linter/single_line_per_selector.rb +35 -0
  57. data/lib/scss_lint/linter/space_after_comma.rb +110 -0
  58. data/lib/scss_lint/linter/space_after_property_colon.rb +84 -0
  59. data/lib/scss_lint/linter/space_after_property_name.rb +27 -0
  60. data/lib/scss_lint/linter/space_before_brace.rb +72 -0
  61. data/lib/scss_lint/linter/space_between_parens.rb +35 -0
  62. data/lib/scss_lint/linter/string_quotes.rb +94 -0
  63. data/lib/scss_lint/linter/trailing_semicolon.rb +67 -0
  64. data/lib/scss_lint/linter/trailing_zero.rb +41 -0
  65. data/lib/scss_lint/linter/unnecessary_mantissa.rb +42 -0
  66. data/lib/scss_lint/linter/unnecessary_parent_reference.rb +49 -0
  67. data/lib/scss_lint/linter/url_format.rb +56 -0
  68. data/lib/scss_lint/linter/url_quotes.rb +27 -0
  69. data/lib/scss_lint/linter/variable_for_property.rb +30 -0
  70. data/lib/scss_lint/linter/vendor_prefix.rb +64 -0
  71. data/lib/scss_lint/linter/zero_unit.rb +39 -0
  72. data/lib/scss_lint/linter_registry.rb +26 -0
  73. data/lib/scss_lint/location.rb +38 -0
  74. data/lib/scss_lint/options.rb +109 -0
  75. data/lib/scss_lint/rake_task.rb +106 -0
  76. data/lib/scss_lint/reporter.rb +18 -0
  77. data/lib/scss_lint/reporter/config_reporter.rb +26 -0
  78. data/lib/scss_lint/reporter/default_reporter.rb +27 -0
  79. data/lib/scss_lint/reporter/files_reporter.rb +8 -0
  80. data/lib/scss_lint/reporter/json_reporter.rb +30 -0
  81. data/lib/scss_lint/reporter/xml_reporter.rb +33 -0
  82. data/lib/scss_lint/runner.rb +51 -0
  83. data/lib/scss_lint/sass/script.rb +78 -0
  84. data/lib/scss_lint/sass/tree.rb +168 -0
  85. data/lib/scss_lint/selector_visitor.rb +34 -0
  86. data/lib/scss_lint/utils.rb +112 -0
  87. data/lib/scss_lint/version.rb +4 -0
  88. data/spec/scss_lint/cli_spec.rb +177 -0
  89. data/spec/scss_lint/config_spec.rb +253 -0
  90. data/spec/scss_lint/engine_spec.rb +24 -0
  91. data/spec/scss_lint/file_finder_spec.rb +134 -0
  92. data/spec/scss_lint/linter/bang_format_spec.rb +121 -0
  93. data/spec/scss_lint/linter/bliss/module_spec.rb +254 -0
  94. data/spec/scss_lint/linter/border_zero_spec.rb +118 -0
  95. data/spec/scss_lint/linter/color_keyword_spec.rb +83 -0
  96. data/spec/scss_lint/linter/color_variable_spec.rb +145 -0
  97. data/spec/scss_lint/linter/comment_spec.rb +79 -0
  98. data/spec/scss_lint/linter/compass/property_with_mixin_spec.rb +55 -0
  99. data/spec/scss_lint/linter/debug_statement_spec.rb +21 -0
  100. data/spec/scss_lint/linter/declaration_order_spec.rb +575 -0
  101. data/spec/scss_lint/linter/duplicate_property_spec.rb +189 -0
  102. data/spec/scss_lint/linter/else_placement_spec.rb +106 -0
  103. data/spec/scss_lint/linter/empty_line_between_blocks_spec.rb +276 -0
  104. data/spec/scss_lint/linter/empty_rule_spec.rb +27 -0
  105. data/spec/scss_lint/linter/final_newline_spec.rb +49 -0
  106. data/spec/scss_lint/linter/hex_length_spec.rb +104 -0
  107. data/spec/scss_lint/linter/hex_notation_spec.rb +104 -0
  108. data/spec/scss_lint/linter/hex_validation_spec.rb +40 -0
  109. data/spec/scss_lint/linter/id_selector_spec.rb +62 -0
  110. data/spec/scss_lint/linter/import_path_spec.rb +300 -0
  111. data/spec/scss_lint/linter/important_rule_spec.rb +43 -0
  112. data/spec/scss_lint/linter/indentation_spec.rb +347 -0
  113. data/spec/scss_lint/linter/leading_zero_spec.rb +233 -0
  114. data/spec/scss_lint/linter/mergeable_selector_spec.rb +283 -0
  115. data/spec/scss_lint/linter/name_format_spec.rb +282 -0
  116. data/spec/scss_lint/linter/nesting_depth_spec.rb +114 -0
  117. data/spec/scss_lint/linter/placeholder_in_extend_spec.rb +63 -0
  118. data/spec/scss_lint/linter/property_count_spec.rb +104 -0
  119. data/spec/scss_lint/linter/property_sort_order_spec.rb +426 -0
  120. data/spec/scss_lint/linter/property_spelling_spec.rb +84 -0
  121. data/spec/scss_lint/linter/property_units_spec.rb +229 -0
  122. data/spec/scss_lint/linter/qualifying_element_spec.rb +125 -0
  123. data/spec/scss_lint/linter/selector_depth_spec.rb +159 -0
  124. data/spec/scss_lint/linter/selector_format_spec.rb +632 -0
  125. data/spec/scss_lint/linter/shorthand_spec.rb +198 -0
  126. data/spec/scss_lint/linter/single_line_per_property_spec.rb +73 -0
  127. data/spec/scss_lint/linter/single_line_per_selector_spec.rb +130 -0
  128. data/spec/scss_lint/linter/space_after_comma_spec.rb +332 -0
  129. data/spec/scss_lint/linter/space_after_property_colon_spec.rb +264 -0
  130. data/spec/scss_lint/linter/space_after_property_name_spec.rb +37 -0
  131. data/spec/scss_lint/linter/space_before_brace_spec.rb +829 -0
  132. data/spec/scss_lint/linter/space_between_parens_spec.rb +263 -0
  133. data/spec/scss_lint/linter/string_quotes_spec.rb +335 -0
  134. data/spec/scss_lint/linter/trailing_semicolon_spec.rb +304 -0
  135. data/spec/scss_lint/linter/trailing_zero_spec.rb +176 -0
  136. data/spec/scss_lint/linter/unnecessary_mantissa_spec.rb +67 -0
  137. data/spec/scss_lint/linter/unnecessary_parent_reference_spec.rb +98 -0
  138. data/spec/scss_lint/linter/url_format_spec.rb +55 -0
  139. data/spec/scss_lint/linter/url_quotes_spec.rb +73 -0
  140. data/spec/scss_lint/linter/variable_for_property_spec.rb +145 -0
  141. data/spec/scss_lint/linter/vendor_prefix_spec.rb +371 -0
  142. data/spec/scss_lint/linter/zero_unit_spec.rb +113 -0
  143. data/spec/scss_lint/linter_registry_spec.rb +50 -0
  144. data/spec/scss_lint/linter_spec.rb +292 -0
  145. data/spec/scss_lint/location_spec.rb +42 -0
  146. data/spec/scss_lint/options_spec.rb +34 -0
  147. data/spec/scss_lint/rake_task_spec.rb +43 -0
  148. data/spec/scss_lint/reporter/config_reporter_spec.rb +42 -0
  149. data/spec/scss_lint/reporter/default_reporter_spec.rb +73 -0
  150. data/spec/scss_lint/reporter/files_reporter_spec.rb +38 -0
  151. data/spec/scss_lint/reporter/json_reporter_spec.rb +96 -0
  152. data/spec/scss_lint/reporter/xml_reporter_spec.rb +103 -0
  153. data/spec/scss_lint/reporter_spec.rb +11 -0
  154. data/spec/scss_lint/runner_spec.rb +123 -0
  155. data/spec/scss_lint/selector_visitor_spec.rb +264 -0
  156. data/spec/spec_helper.rb +34 -0
  157. data/spec/support/isolated_environment.rb +25 -0
  158. data/spec/support/matchers/report_lint.rb +48 -0
  159. metadata +342 -0
@@ -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
@@ -0,0 +1,347 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::Indentation do
4
+ context 'when a line at the root level is indented' do
5
+ let(:scss) { <<-SCSS }
6
+ $var: 5px;
7
+ $other: 10px;
8
+ SCSS
9
+
10
+ it { should_not report_lint line: 1 }
11
+ it { should report_lint line: 2 }
12
+ end
13
+
14
+ context 'when a line in a rule set is properly indented' do
15
+ let(:scss) { <<-SCSS }
16
+ p {
17
+ margin: 0;
18
+ }
19
+ SCSS
20
+
21
+ it { should_not report_lint }
22
+ end
23
+
24
+ context 'when lines in a rule set are not properly indented' do
25
+ let(:scss) { <<-SCSS }
26
+ p {
27
+ margin: 0;
28
+ padding: 1em;
29
+ opacity: 0.5;
30
+ }
31
+ SCSS
32
+
33
+ it { should report_lint line: 2 }
34
+ it { should_not report_lint line: 3 }
35
+ it { should report_lint line: 4 }
36
+ end
37
+
38
+ context 'when selector of a nested rule set is not properly indented' do
39
+ let(:scss) { <<-SCSS }
40
+ p {
41
+ em {
42
+ font-style: italic;
43
+ }
44
+ }
45
+ SCSS
46
+
47
+ it { should report_lint line: 2 }
48
+ it { should_not report_lint line: 3 }
49
+ it { should_not report_lint line: 4 }
50
+ end
51
+
52
+ context 'when multi-line selector of a nested rule set is not properly indented' do
53
+ let(:scss) { <<-SCSS }
54
+ p {
55
+ b,
56
+ em,
57
+ i {
58
+ font-style: italic;
59
+ }
60
+ }
61
+ SCSS
62
+
63
+ it { should report_lint line: 2 }
64
+ it { should_not report_lint line: 3 }
65
+ it { should_not report_lint line: 4 }
66
+ it { should_not report_lint line: 5 }
67
+ end
68
+
69
+ context 'when a property is on the same line as its rule selector' do
70
+ let(:scss) { 'h1 { margin: 5px; }' }
71
+ it { should_not report_lint }
72
+ end
73
+
74
+ context 'when an argument list spans multiple lines' do
75
+ let(:scss) { <<-SCSS }
76
+ @include mixin(one,
77
+ two,
78
+ three);
79
+ SCSS
80
+
81
+ it { should_not report_lint }
82
+ end
83
+
84
+ context 'when an argument list of an improperly indented script spans multiple lines' do
85
+ let(:scss) { <<-SCSS }
86
+ p {
87
+ @include mixin(one,
88
+ two,
89
+ three);
90
+ }
91
+ SCSS
92
+
93
+ it { should report_lint line: 2 }
94
+ it { should_not report_lint line: 3 }
95
+ it { should_not report_lint line: 4 }
96
+ end
97
+
98
+ context 'when an if statement is incorrectly indented' do
99
+ let(:scss) { <<-SCSS }
100
+ $condition: true;
101
+ @if $condition {
102
+ padding: 0;
103
+ }
104
+ SCSS
105
+
106
+ it { should report_lint line: 2 }
107
+ end
108
+
109
+ context 'when an if statement is accompanied by a correctly indented else statement' do
110
+ let(:scss) { <<-SCSS }
111
+ @if $condition {
112
+ padding: 0;
113
+ } @else {
114
+ margin: 0;
115
+ }
116
+ SCSS
117
+
118
+ it { should_not report_lint }
119
+ end
120
+
121
+ context 'when @at-root directive contains correctly indented children' do
122
+ let(:scss) { <<-SCSS }
123
+ .block {
124
+ @at-root {
125
+ .something {}
126
+ }
127
+ }
128
+ SCSS
129
+
130
+ it { should_not report_lint }
131
+ end
132
+
133
+ context 'when @at-root directive with an inline selector contains correctly indented children' do
134
+ let(:scss) { <<-SCSS }
135
+ .block {
136
+ @at-root .something {
137
+ .something-else {}
138
+ }
139
+ }
140
+ SCSS
141
+
142
+ it { should_not report_lint }
143
+ end
144
+
145
+ context 'when @at-root directive with no inline selector contains comment' do
146
+ let(:scss) { <<-SCSS }
147
+ @at-root {
148
+ // A comment that causes a crash
149
+ .something-else {}
150
+ }
151
+ SCSS
152
+
153
+ it { should_not report_lint }
154
+ end
155
+
156
+ context 'when the indentation width has been explicitly set' do
157
+ let(:linter_config) { { 'width' => 3 } }
158
+
159
+ let(:scss) { <<-SCSS }
160
+ p {
161
+ margin: 0;
162
+ padding: 5px;
163
+ }
164
+ SCSS
165
+
166
+ it { should report_lint line: 2 }
167
+ it { should_not report_lint line: 3 }
168
+ end
169
+
170
+ context 'when there are selectors across multiple lines' do
171
+ let(:scss) { <<-SCSS }
172
+ .class1,
173
+ .class2 {
174
+ margin: 0;
175
+ padding: 5px;
176
+ }
177
+ SCSS
178
+
179
+ it { should_not report_lint }
180
+ end
181
+
182
+ context 'when there are selectors across multiple lines with a single line block' do
183
+ let(:scss) { <<-SCSS }
184
+ .class1,
185
+ .class2 { margin: 0; }
186
+ SCSS
187
+
188
+ it { should_not report_lint }
189
+ end
190
+
191
+ context 'when a comment node precedes a node' do
192
+ let(:scss) { <<-SCSS }
193
+ // A comment
194
+ $var: 1;
195
+ SCSS
196
+
197
+ it { should_not report_lint }
198
+ end
199
+
200
+ context 'when a line is indented with tabs' do
201
+ let(:scss) { <<-SCSS }
202
+ p {
203
+ \tmargin: 0;
204
+ }
205
+ SCSS
206
+
207
+ it { should report_lint line: 2 }
208
+ end
209
+
210
+ context 'when a line contains a mix of tabs and spaces' do
211
+ let(:scss) { <<-SCSS }
212
+ p {
213
+ \tmargin: 0;
214
+ }
215
+ SCSS
216
+
217
+ it { should report_lint line: 2 }
218
+ end
219
+
220
+ context 'when tabs are preferred' do
221
+ let(:linter_config) { { 'character' => 'tab', 'width' => 1 } }
222
+
223
+ context 'and the line is indented correctly' do
224
+ let(:scss) { <<-SCSS }
225
+ p {
226
+ \tmargin: 0;
227
+ }
228
+ SCSS
229
+
230
+ it { should_not report_lint }
231
+ end
232
+
233
+ context 'and the line is incorrectly indented' do
234
+ let(:scss) { <<-SCSS }
235
+ p {
236
+ \t\tmargin: 0;
237
+ }
238
+ SCSS
239
+
240
+ it { should report_lint line: 2 }
241
+ end
242
+
243
+ context 'and the line is indented with spaces' do
244
+ let(:scss) { <<-SCSS }
245
+ p {
246
+ margin: 0;
247
+ }
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
309
+
310
+ it { should report_lint line: 2 }
311
+ end
312
+
313
+ context 'and a nested non-ruleset is correctly indented' do
314
+ let(:scss) { <<-SCSS }
315
+ .one {
316
+ color: #000;
317
+ }
318
+ .two {
319
+ margin: 0;
320
+ }
321
+ SCSS
322
+
323
+ it { should_not report_lint }
324
+ end
325
+
326
+ context 'and a nested non-ruleset is incorrectly indented' do
327
+ let(:scss) { <<-SCSS }
328
+ .one {
329
+ color: #000;
330
+ }
331
+ .two {
332
+ margin: 0;
333
+ }
334
+ SCSS
335
+
336
+ it { should report_lint line: 5 }
337
+ end
338
+
339
+ context 'and a non-nested non-ruleset is correctly indented' do
340
+ let(:scss) { <<-SCSS }
341
+ $var: 1
342
+ SCSS
343
+
344
+ it { should_not report_lint }
345
+ end
346
+ end
347
+ end
@@ -0,0 +1,233 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::LeadingZero do
4
+ context 'when no values exist' do
5
+ let(:scss) { <<-SCSS }
6
+ p {
7
+ }
8
+ SCSS
9
+
10
+ it { should_not report_lint }
11
+ end
12
+
13
+ context 'when a zero exists' do
14
+ let(:scss) { <<-SCSS }
15
+ p {
16
+ margin: 0;
17
+ }
18
+ SCSS
19
+
20
+ it { should_not report_lint }
21
+ end
22
+
23
+ context 'when an integer value exists' do
24
+ let(:scss) { <<-SCSS }
25
+ p {
26
+ line-height: 2;
27
+ }
28
+ SCSS
29
+
30
+ it { should_not report_lint }
31
+ end
32
+
33
+ context 'when an integer value with units exists' do
34
+ let(:scss) { <<-SCSS }
35
+ p {
36
+ margin: 5px;
37
+ }
38
+ SCSS
39
+
40
+ it { should_not report_lint }
41
+ end
42
+
43
+ context 'when a unitless fractional value with no leading zero exists' do
44
+ let(:scss) { <<-SCSS }
45
+ p {
46
+ line-height: .5;
47
+ }
48
+ SCSS
49
+
50
+ it { should_not report_lint }
51
+ end
52
+
53
+ context 'when a negative unitless fractional value with no leading zero exists' do
54
+ let(:scss) { <<-SCSS }
55
+ p {
56
+ line-height: -.5;
57
+ }
58
+ SCSS
59
+
60
+ it { should_not report_lint }
61
+ end
62
+
63
+ context 'when a fractional value with units and no leading zero exists' do
64
+ let(:scss) { <<-SCSS }
65
+ p {
66
+ margin: .5em;
67
+ }
68
+ SCSS
69
+
70
+ it { should_not report_lint }
71
+ end
72
+
73
+ context 'when a negative fractional value with units and no leading zero exists' do
74
+ let(:scss) { <<-SCSS }
75
+ p {
76
+ margin: -.5em;
77
+ }
78
+ SCSS
79
+
80
+ it { should_not report_lint }
81
+ end
82
+
83
+ context 'when a fractional value with a leading zero exists' do
84
+ let(:scss) { <<-SCSS }
85
+ p {
86
+ line-height: 0.5;
87
+ }
88
+ SCSS
89
+
90
+ it { should report_lint line: 2 }
91
+ end
92
+
93
+ context 'when a fractional value with units and a leading zero exists' do
94
+ let(:scss) { <<-SCSS }
95
+ p {
96
+ margin: 0.5em;
97
+ }
98
+ SCSS
99
+
100
+ it { should report_lint line: 2 }
101
+ end
102
+
103
+ context 'when a negative fractional value with units and a leading zero exists' do
104
+ let(:scss) { <<-SCSS }
105
+ p {
106
+ margin: -0.5em;
107
+ }
108
+ SCSS
109
+
110
+ it { should report_lint line: 2 }
111
+ end
112
+
113
+ context 'when a fractional value with a mantissa ending in zero exists' do
114
+ let(:scss) { <<-SCSS }
115
+ p {
116
+ line-height: 10.5;
117
+ }
118
+ SCSS
119
+
120
+ it { should_not report_lint }
121
+ end
122
+
123
+ context 'when multiple fractional values with leading zeros exist' do
124
+ let(:scss) { <<-SCSS }
125
+ p {
126
+ margin: 0.5em 0.5 0.1px 0.9pt;
127
+ }
128
+ SCSS
129
+
130
+ it { should report_lint count: 4, line: 2 }
131
+ end
132
+
133
+ context 'when leading zeros appear in function arguments' do
134
+ let(:scss) { <<-SCSS }
135
+ p {
136
+ margin: some-function(0.5em, 0.4 0.3 .2);
137
+ }
138
+ SCSS
139
+
140
+ it { should report_lint count: 3, line: 2 }
141
+ end
142
+
143
+ context 'when leading zeros appear in mixin arguments' do
144
+ let(:scss) { <<-SCSS }
145
+ p {
146
+ @include some-mixin(0.5em, 0.4 0.3 .2);
147
+ }
148
+ SCSS
149
+
150
+ it { should report_lint count: 3, line: 2 }
151
+ end
152
+
153
+ context 'when leading zeros appear in variable declarations' do
154
+ let(:scss) { '$some-var: 0.5em;' }
155
+
156
+ it { should report_lint line: 1 }
157
+ end
158
+
159
+ context 'when leading zeros appear in named arguments' do
160
+ let(:scss) { <<-SCSS }
161
+ p {
162
+ @include line-clamp($line-height: 0.9, $line-count: 2);
163
+ }
164
+ SCSS
165
+
166
+ it { should report_lint line: 2 }
167
+ end
168
+
169
+ context 'when leading zeros appear in parameter defaults' do
170
+ let(:scss) { <<-SCSS }
171
+ @mixin my-mixin($bad-value: 0.5, $good-value: .9, $string-value: "0.9") {
172
+ margin: $some-value;
173
+ padding: $some-other-value;
174
+ }
175
+ SCSS
176
+
177
+ it { should report_lint count: 1, line: 1 }
178
+ end
179
+
180
+ context 'when leading zeros are preferred' do
181
+ let(:linter_config) { { 'style' => 'include_zero' } }
182
+
183
+ context 'when a zero exists' do
184
+ let(:scss) { <<-SCSS }
185
+ p {
186
+ margin: 0;
187
+ }
188
+ SCSS
189
+
190
+ it { should_not report_lint }
191
+ end
192
+
193
+ context 'when a non-zero integer value exists' do
194
+ let(:scss) { <<-SCSS }
195
+ p {
196
+ line-height: 2;
197
+ }
198
+ SCSS
199
+
200
+ it { should_not report_lint }
201
+ end
202
+
203
+ context 'when a fractional value with no leading zero exists' do
204
+ let(:scss) { <<-SCSS }
205
+ p {
206
+ padding: .5em;
207
+ }
208
+ SCSS
209
+
210
+ it { should report_lint line: 2 }
211
+ end
212
+
213
+ context 'when a fractional value with leading zero exists' do
214
+ let(:scss) { <<-SCSS }
215
+ p {
216
+ padding: 0.5em;
217
+ }
218
+ SCSS
219
+
220
+ it { should_not report_lint }
221
+ end
222
+
223
+ context 'when a fractional value with a mantissa ending in zero exists' do
224
+ let(:scss) { <<-SCSS }
225
+ p {
226
+ padding: 10.5em;
227
+ }
228
+ SCSS
229
+
230
+ it { should_not report_lint }
231
+ end
232
+ end
233
+ end