scss_lint 0.38.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.
Files changed (157) hide show
  1. checksums.yaml +7 -0
  2. data/bin/scss-lint +6 -0
  3. data/config/default.yml +205 -0
  4. data/data/prefixed-identifiers/base.txt +107 -0
  5. data/data/prefixed-identifiers/bourbon.txt +71 -0
  6. data/data/properties.txt +477 -0
  7. data/data/property-sort-orders/concentric.txt +134 -0
  8. data/data/property-sort-orders/recess.txt +149 -0
  9. data/data/property-sort-orders/smacss.txt +137 -0
  10. data/lib/scss_lint.rb +31 -0
  11. data/lib/scss_lint/cli.rb +215 -0
  12. data/lib/scss_lint/config.rb +251 -0
  13. data/lib/scss_lint/constants.rb +8 -0
  14. data/lib/scss_lint/control_comment_processor.rb +126 -0
  15. data/lib/scss_lint/engine.rb +56 -0
  16. data/lib/scss_lint/exceptions.rb +21 -0
  17. data/lib/scss_lint/file_finder.rb +68 -0
  18. data/lib/scss_lint/lint.rb +24 -0
  19. data/lib/scss_lint/linter.rb +161 -0
  20. data/lib/scss_lint/linter/bang_format.rb +52 -0
  21. data/lib/scss_lint/linter/border_zero.rb +39 -0
  22. data/lib/scss_lint/linter/color_keyword.rb +32 -0
  23. data/lib/scss_lint/linter/color_variable.rb +60 -0
  24. data/lib/scss_lint/linter/comment.rb +21 -0
  25. data/lib/scss_lint/linter/compass.rb +7 -0
  26. data/lib/scss_lint/linter/compass/property_with_mixin.rb +47 -0
  27. data/lib/scss_lint/linter/debug_statement.rb +10 -0
  28. data/lib/scss_lint/linter/declaration_order.rb +71 -0
  29. data/lib/scss_lint/linter/duplicate_property.rb +58 -0
  30. data/lib/scss_lint/linter/else_placement.rb +48 -0
  31. data/lib/scss_lint/linter/empty_line_between_blocks.rb +85 -0
  32. data/lib/scss_lint/linter/empty_rule.rb +11 -0
  33. data/lib/scss_lint/linter/final_newline.rb +20 -0
  34. data/lib/scss_lint/linter/hex_length.rb +56 -0
  35. data/lib/scss_lint/linter/hex_notation.rb +38 -0
  36. data/lib/scss_lint/linter/hex_validation.rb +23 -0
  37. data/lib/scss_lint/linter/id_selector.rb +10 -0
  38. data/lib/scss_lint/linter/import_path.rb +62 -0
  39. data/lib/scss_lint/linter/important_rule.rb +12 -0
  40. data/lib/scss_lint/linter/indentation.rb +197 -0
  41. data/lib/scss_lint/linter/leading_zero.rb +49 -0
  42. data/lib/scss_lint/linter/mergeable_selector.rb +60 -0
  43. data/lib/scss_lint/linter/name_format.rb +117 -0
  44. data/lib/scss_lint/linter/nesting_depth.rb +24 -0
  45. data/lib/scss_lint/linter/placeholder_in_extend.rb +22 -0
  46. data/lib/scss_lint/linter/property_count.rb +44 -0
  47. data/lib/scss_lint/linter/property_sort_order.rb +198 -0
  48. data/lib/scss_lint/linter/property_spelling.rb +49 -0
  49. data/lib/scss_lint/linter/property_units.rb +59 -0
  50. data/lib/scss_lint/linter/qualifying_element.rb +42 -0
  51. data/lib/scss_lint/linter/selector_depth.rb +64 -0
  52. data/lib/scss_lint/linter/selector_format.rb +102 -0
  53. data/lib/scss_lint/linter/shorthand.rb +139 -0
  54. data/lib/scss_lint/linter/single_line_per_property.rb +59 -0
  55. data/lib/scss_lint/linter/single_line_per_selector.rb +35 -0
  56. data/lib/scss_lint/linter/space_after_comma.rb +110 -0
  57. data/lib/scss_lint/linter/space_after_property_colon.rb +92 -0
  58. data/lib/scss_lint/linter/space_after_property_name.rb +27 -0
  59. data/lib/scss_lint/linter/space_before_brace.rb +72 -0
  60. data/lib/scss_lint/linter/space_between_parens.rb +35 -0
  61. data/lib/scss_lint/linter/string_quotes.rb +94 -0
  62. data/lib/scss_lint/linter/trailing_semicolon.rb +67 -0
  63. data/lib/scss_lint/linter/trailing_zero.rb +41 -0
  64. data/lib/scss_lint/linter/unnecessary_mantissa.rb +42 -0
  65. data/lib/scss_lint/linter/unnecessary_parent_reference.rb +49 -0
  66. data/lib/scss_lint/linter/url_format.rb +56 -0
  67. data/lib/scss_lint/linter/url_quotes.rb +27 -0
  68. data/lib/scss_lint/linter/variable_for_property.rb +30 -0
  69. data/lib/scss_lint/linter/vendor_prefix.rb +64 -0
  70. data/lib/scss_lint/linter/zero_unit.rb +39 -0
  71. data/lib/scss_lint/linter_registry.rb +26 -0
  72. data/lib/scss_lint/location.rb +38 -0
  73. data/lib/scss_lint/options.rb +109 -0
  74. data/lib/scss_lint/rake_task.rb +106 -0
  75. data/lib/scss_lint/reporter.rb +18 -0
  76. data/lib/scss_lint/reporter/config_reporter.rb +26 -0
  77. data/lib/scss_lint/reporter/default_reporter.rb +27 -0
  78. data/lib/scss_lint/reporter/files_reporter.rb +8 -0
  79. data/lib/scss_lint/reporter/json_reporter.rb +30 -0
  80. data/lib/scss_lint/reporter/xml_reporter.rb +33 -0
  81. data/lib/scss_lint/runner.rb +51 -0
  82. data/lib/scss_lint/sass/script.rb +78 -0
  83. data/lib/scss_lint/sass/tree.rb +168 -0
  84. data/lib/scss_lint/selector_visitor.rb +34 -0
  85. data/lib/scss_lint/utils.rb +112 -0
  86. data/lib/scss_lint/version.rb +4 -0
  87. data/spec/scss_lint/cli_spec.rb +177 -0
  88. data/spec/scss_lint/config_spec.rb +253 -0
  89. data/spec/scss_lint/engine_spec.rb +24 -0
  90. data/spec/scss_lint/file_finder_spec.rb +134 -0
  91. data/spec/scss_lint/linter/bang_format_spec.rb +121 -0
  92. data/spec/scss_lint/linter/border_zero_spec.rb +118 -0
  93. data/spec/scss_lint/linter/color_keyword_spec.rb +83 -0
  94. data/spec/scss_lint/linter/color_variable_spec.rb +155 -0
  95. data/spec/scss_lint/linter/comment_spec.rb +79 -0
  96. data/spec/scss_lint/linter/compass/property_with_mixin_spec.rb +55 -0
  97. data/spec/scss_lint/linter/debug_statement_spec.rb +21 -0
  98. data/spec/scss_lint/linter/declaration_order_spec.rb +575 -0
  99. data/spec/scss_lint/linter/duplicate_property_spec.rb +189 -0
  100. data/spec/scss_lint/linter/else_placement_spec.rb +106 -0
  101. data/spec/scss_lint/linter/empty_line_between_blocks_spec.rb +276 -0
  102. data/spec/scss_lint/linter/empty_rule_spec.rb +27 -0
  103. data/spec/scss_lint/linter/final_newline_spec.rb +49 -0
  104. data/spec/scss_lint/linter/hex_length_spec.rb +104 -0
  105. data/spec/scss_lint/linter/hex_notation_spec.rb +104 -0
  106. data/spec/scss_lint/linter/hex_validation_spec.rb +40 -0
  107. data/spec/scss_lint/linter/id_selector_spec.rb +62 -0
  108. data/spec/scss_lint/linter/import_path_spec.rb +300 -0
  109. data/spec/scss_lint/linter/important_rule_spec.rb +43 -0
  110. data/spec/scss_lint/linter/indentation_spec.rb +347 -0
  111. data/spec/scss_lint/linter/leading_zero_spec.rb +233 -0
  112. data/spec/scss_lint/linter/mergeable_selector_spec.rb +283 -0
  113. data/spec/scss_lint/linter/name_format_spec.rb +282 -0
  114. data/spec/scss_lint/linter/nesting_depth_spec.rb +114 -0
  115. data/spec/scss_lint/linter/placeholder_in_extend_spec.rb +63 -0
  116. data/spec/scss_lint/linter/property_count_spec.rb +104 -0
  117. data/spec/scss_lint/linter/property_sort_order_spec.rb +482 -0
  118. data/spec/scss_lint/linter/property_spelling_spec.rb +84 -0
  119. data/spec/scss_lint/linter/property_units_spec.rb +229 -0
  120. data/spec/scss_lint/linter/qualifying_element_spec.rb +125 -0
  121. data/spec/scss_lint/linter/selector_depth_spec.rb +159 -0
  122. data/spec/scss_lint/linter/selector_format_spec.rb +632 -0
  123. data/spec/scss_lint/linter/shorthand_spec.rb +198 -0
  124. data/spec/scss_lint/linter/single_line_per_property_spec.rb +73 -0
  125. data/spec/scss_lint/linter/single_line_per_selector_spec.rb +130 -0
  126. data/spec/scss_lint/linter/space_after_comma_spec.rb +332 -0
  127. data/spec/scss_lint/linter/space_after_property_colon_spec.rb +373 -0
  128. data/spec/scss_lint/linter/space_after_property_name_spec.rb +37 -0
  129. data/spec/scss_lint/linter/space_before_brace_spec.rb +829 -0
  130. data/spec/scss_lint/linter/space_between_parens_spec.rb +263 -0
  131. data/spec/scss_lint/linter/string_quotes_spec.rb +335 -0
  132. data/spec/scss_lint/linter/trailing_semicolon_spec.rb +304 -0
  133. data/spec/scss_lint/linter/trailing_zero_spec.rb +176 -0
  134. data/spec/scss_lint/linter/unnecessary_mantissa_spec.rb +67 -0
  135. data/spec/scss_lint/linter/unnecessary_parent_reference_spec.rb +98 -0
  136. data/spec/scss_lint/linter/url_format_spec.rb +55 -0
  137. data/spec/scss_lint/linter/url_quotes_spec.rb +73 -0
  138. data/spec/scss_lint/linter/variable_for_property_spec.rb +145 -0
  139. data/spec/scss_lint/linter/vendor_prefix_spec.rb +371 -0
  140. data/spec/scss_lint/linter/zero_unit_spec.rb +113 -0
  141. data/spec/scss_lint/linter_registry_spec.rb +50 -0
  142. data/spec/scss_lint/linter_spec.rb +292 -0
  143. data/spec/scss_lint/location_spec.rb +42 -0
  144. data/spec/scss_lint/options_spec.rb +34 -0
  145. data/spec/scss_lint/rake_task_spec.rb +43 -0
  146. data/spec/scss_lint/reporter/config_reporter_spec.rb +42 -0
  147. data/spec/scss_lint/reporter/default_reporter_spec.rb +73 -0
  148. data/spec/scss_lint/reporter/files_reporter_spec.rb +38 -0
  149. data/spec/scss_lint/reporter/json_reporter_spec.rb +96 -0
  150. data/spec/scss_lint/reporter/xml_reporter_spec.rb +103 -0
  151. data/spec/scss_lint/reporter_spec.rb +11 -0
  152. data/spec/scss_lint/runner_spec.rb +123 -0
  153. data/spec/scss_lint/selector_visitor_spec.rb +264 -0
  154. data/spec/spec_helper.rb +34 -0
  155. data/spec/support/isolated_environment.rb +25 -0
  156. data/spec/support/matchers/report_lint.rb +48 -0
  157. metadata +328 -0
@@ -0,0 +1,373 @@
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(:scss) { <<-SCSS }
11
+ p {
12
+ margin:0;
13
+ }
14
+ SCSS
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(:scss) { <<-SCSS }
21
+ p {
22
+ color:#eee
23
+ }
24
+ SCSS
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(:scss) { <<-SCSS }
31
+ p {
32
+ margin: 0;
33
+ }
34
+ SCSS
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(:scss) { <<-SCSS }
41
+ p {
42
+ margin : bold;
43
+ }
44
+ SCSS
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(:scss) { <<-SCSS }
51
+ p {
52
+ margin: bold;
53
+ }
54
+ SCSS
55
+
56
+ it { should report_lint line: 2 }
57
+ end
58
+
59
+ context 'when interpolation within single quotes is followed by inline property' do
60
+ context 'and property name is followed by a space' do
61
+ let(:scss) { "[class~='\#{$test}'] { width: 100%; }" }
62
+
63
+ it { should_not report_lint }
64
+ end
65
+
66
+ context 'and property name is not followed by a space' do
67
+ let(:scss) { "[class~='\#{$test}'] { width:100%; }" }
68
+
69
+ it { should report_lint }
70
+ end
71
+ end
72
+
73
+ context 'when there are nested properties with incorrect spacing' do
74
+ let(:scss) { <<-SCSS }
75
+ .class {
76
+ font: {
77
+ weight :bold;
78
+ }
79
+ }
80
+ SCSS
81
+
82
+ it { should report_lint line: 3 }
83
+ end
84
+
85
+ context 'when the colon after a property is followed by a space and a newline' do
86
+ let(:scss) { <<-SCSS }
87
+ p {
88
+ margin:\s
89
+ 0;
90
+ }
91
+ SCSS
92
+
93
+ it { should report_lint line: 2 }
94
+ end
95
+
96
+ context 'when the colon after a property is followed by a tab' do
97
+ let(:scss) { <<-SCSS }
98
+ p {
99
+ margin:\t0;
100
+ }
101
+ SCSS
102
+
103
+ it { should report_lint line: 2 }
104
+ end
105
+ end
106
+
107
+ context 'when no spaces are allowed' do
108
+ let(:style) { 'no_space' }
109
+
110
+ context 'when the colon after a property is not followed by space' do
111
+ let(:scss) { <<-SCSS }
112
+ p {
113
+ margin:0;
114
+ }
115
+ SCSS
116
+
117
+ it { should_not report_lint }
118
+ end
119
+
120
+ context 'when colon after property is not followed by space and the semicolon is missing' do
121
+ let(:scss) { <<-SCSS }
122
+ p {
123
+ color:#eee
124
+ }
125
+ SCSS
126
+
127
+ it { should_not report_lint }
128
+ end
129
+
130
+ context 'when the colon after a property is followed by a space' do
131
+ let(:scss) { <<-SCSS }
132
+ p {
133
+ margin: 0;
134
+ }
135
+ SCSS
136
+
137
+ it { should report_lint line: 2 }
138
+ end
139
+
140
+ context 'when the colon after a property is surrounded by spaces' do
141
+ let(:scss) { <<-SCSS }
142
+ p {
143
+ margin : bold;
144
+ }
145
+ SCSS
146
+
147
+ it { should report_lint line: 2 }
148
+ end
149
+
150
+ context 'when the colon after a property is followed by multiple spaces' do
151
+ let(:scss) { <<-SCSS }
152
+ p {
153
+ margin: bold;
154
+ }
155
+ SCSS
156
+
157
+ it { should report_lint line: 2 }
158
+ end
159
+
160
+ context 'when the colon after a property is followed by a newline' do
161
+ let(:scss) { <<-SCSS }
162
+ p {
163
+ margin:
164
+ 0;
165
+ }
166
+ SCSS
167
+
168
+ it { should report_lint line: 2 }
169
+ end
170
+
171
+ context 'when the colon after a property is followed by a tab' do
172
+ let(:scss) { <<-SCSS }
173
+ p {
174
+ margin:\t0;
175
+ }
176
+ SCSS
177
+
178
+ it { should report_lint line: 2 }
179
+ end
180
+ end
181
+
182
+ context 'when at least one space is preferred' do
183
+ let(:style) { 'at_least_one_space' }
184
+
185
+ context 'when the colon after a property is not followed by space' do
186
+ let(:scss) { <<-SCSS }
187
+ p {
188
+ margin:0;
189
+ }
190
+ SCSS
191
+
192
+ it { should report_lint line: 2 }
193
+ end
194
+
195
+ context 'when colon after property is not followed by space and the semicolon is missing' do
196
+ let(:scss) { <<-SCSS }
197
+ p {
198
+ color:#eee
199
+ }
200
+ SCSS
201
+
202
+ it { should report_lint line: 2 }
203
+ end
204
+
205
+ context 'when the colon after a property is followed by a space' do
206
+ let(:scss) { <<-SCSS }
207
+ p {
208
+ margin: 0;
209
+ }
210
+ SCSS
211
+
212
+ it { should_not report_lint }
213
+ end
214
+
215
+ context 'when the colon after a property is surrounded by spaces' do
216
+ let(:scss) { <<-SCSS }
217
+ p {
218
+ margin : bold;
219
+ }
220
+ SCSS
221
+
222
+ it { should_not report_lint }
223
+ end
224
+
225
+ context 'when the colon after a property is followed by multiple spaces' do
226
+ let(:scss) { <<-SCSS }
227
+ p {
228
+ margin: bold;
229
+ }
230
+ SCSS
231
+
232
+ it { should_not report_lint }
233
+ end
234
+
235
+ context 'when the colon after a property is followed by multiple spaces and a tab' do
236
+ let(:scss) { <<-SCSS }
237
+ p {
238
+ margin: \tbold;
239
+ }
240
+ SCSS
241
+
242
+ it { should report_lint line: 2 }
243
+ end
244
+ end
245
+
246
+ context 'when one space or newline is preferred' do
247
+ let(:style) { 'one_space_or_newline' }
248
+
249
+ context 'when the colon after a property is not followed by space' do
250
+ let(:scss) { <<-SCSS }
251
+ p {
252
+ margin:0;
253
+ }
254
+ SCSS
255
+
256
+ it { should report_lint line: 2 }
257
+ end
258
+
259
+ context 'when the colon after a property is followed by a space' do
260
+ let(:scss) { <<-SCSS }
261
+ p {
262
+ margin: 0;
263
+ }
264
+ SCSS
265
+
266
+ it { should_not report_lint }
267
+ end
268
+
269
+ context 'when the colon after a property is followed by a newline and spaces' do
270
+ let(:scss) { <<-SCSS }
271
+ p {
272
+ background-image:
273
+ url(https://something.crazy.long/with/paths?and=queries)
274
+ }
275
+ SCSS
276
+
277
+ it { should_not report_lint }
278
+ end
279
+
280
+ context 'when the colon after a property is followed by a newline and no spaces' do
281
+ let(:scss) { <<-SCSS }
282
+ p {
283
+ background-image:
284
+ url(https://something.crazy.long/with/paths?and=queries)
285
+ }
286
+ SCSS
287
+
288
+ it { should_not report_lint }
289
+ end
290
+
291
+ context 'when the colon after a property is followed by a space and then a newline' do
292
+ let(:scss) { <<-SCSS }
293
+ p {
294
+ background-image:\s
295
+ url(https://something.crazy.long/with/paths?and=queries)
296
+ }
297
+ SCSS
298
+
299
+ it { should report_lint line: 2 }
300
+ end
301
+ end
302
+
303
+ context 'when aligned property values are preferred' do
304
+ let(:style) { 'aligned' }
305
+
306
+ context 'when the colon after a single property is not followed by space' do
307
+ let(:scss) { <<-SCSS }
308
+ p {
309
+ margin:0;
310
+ }
311
+ SCSS
312
+
313
+ it { should_not report_lint }
314
+ end
315
+
316
+ context 'when the colon after a single property is followed by a space' do
317
+ let(:scss) { <<-SCSS }
318
+ p {
319
+ margin: 0;
320
+ }
321
+ SCSS
322
+
323
+ it { should_not report_lint }
324
+ end
325
+
326
+ context 'when properties are not aligned' do
327
+ let(:scss) { <<-SCSS }
328
+ p {
329
+ content: 'hello';
330
+ margin: 0;
331
+ padding: 0;
332
+ }
333
+ SCSS
334
+
335
+ it { should report_lint line: 2 }
336
+ end
337
+
338
+ context 'when properties aligned but the names are not' do
339
+ let(:scss) { <<-SCSS }
340
+ p {
341
+ content: 'hello';
342
+ margin: 0;
343
+ padding: 0;
344
+ }
345
+ SCSS
346
+
347
+ it { should_not report_lint }
348
+ end
349
+
350
+ context 'when properties aligned but the names with spaces are not' do
351
+ let(:scss) { <<-SCSS }
352
+ p {
353
+ content : 'hello';
354
+ margin : 0;
355
+ padding : 0;
356
+ }
357
+ SCSS
358
+
359
+ it { should_not report_lint }
360
+ end
361
+
362
+ context 'when properties are aligned' do
363
+ let(:scss) { <<-SCSS }
364
+ p {
365
+ margin: 0;
366
+ padding: 0;
367
+ }
368
+ SCSS
369
+
370
+ it { should_not report_lint }
371
+ end
372
+ end
373
+ end
@@ -0,0 +1,37 @@
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(:scss) { <<-SCSS }
6
+ p {
7
+ margin : 0;
8
+ }
9
+ SCSS
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(:scss) { <<-SCSS }
16
+ p {
17
+ margin: 0;
18
+ }
19
+ SCSS
20
+
21
+ it { should_not report_lint }
22
+ end
23
+
24
+ context 'when interpolation within single quotes is followed by inline property' do
25
+ context 'and property name is followed by a space' do
26
+ let(:scss) { "[class~='\#{$test}'] { width: 100%; }" }
27
+
28
+ it { should_not report_lint }
29
+ end
30
+
31
+ context 'and property name is not followed by a space' do
32
+ let(:scss) { "[class~='\#{$test}'] { width : 100%; }" }
33
+
34
+ it { should report_lint }
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,829 @@
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(:scss) { <<-SCSS }
7
+ .parent {
8
+ @at-root .child {
9
+ }
10
+ }
11
+ SCSS
12
+
13
+ it { should_not report_lint }
14
+
15
+ context 'and the `style` option is set to `new_line`' do
16
+ let(:linter_config) { { 'style' => 'new_line' } }
17
+
18
+ it { should report_lint line: 1 }
19
+ it { should report_lint line: 2 }
20
+ end
21
+ end
22
+
23
+ context 'when brace is preceded by multiple spaces' do
24
+ let(:scss) { <<-SCSS }
25
+ .parent {
26
+ @at-root .child {
27
+ }
28
+ }
29
+ SCSS
30
+
31
+ it { should report_lint line: 2 }
32
+ end
33
+
34
+ context 'when brace is not preceded by a space' do
35
+ let(:scss) { <<-SCSS }
36
+ .parent {
37
+ @at-root .child{
38
+ }
39
+ }
40
+ SCSS
41
+
42
+ it { should report_lint line: 2 }
43
+ end
44
+
45
+ context 'when brace is preceded by a new line' do
46
+ let(:scss) { <<-SCSS }
47
+ .parent
48
+ {
49
+ @at-root .child
50
+ {
51
+ }
52
+ }
53
+ SCSS
54
+
55
+ it { should report_lint line: 2 }
56
+ it { should report_lint line: 4 }
57
+
58
+ context 'and the `style` option is `new_line`' do
59
+ let(:linter_config) { { 'style' => 'new_line' } }
60
+
61
+ it { should_not report_lint }
62
+ end
63
+ end
64
+ end
65
+
66
+ context 'with an @each block' do
67
+ context 'when brace is preceded by a space' do
68
+ let(:scss) { <<-SCSS }
69
+ @each $item in $list {
70
+ }
71
+ SCSS
72
+
73
+ it { should_not report_lint }
74
+
75
+ context 'and the `style` option is set to `new_line`' do
76
+ let(:linter_config) { { 'style' => 'new_line' } }
77
+
78
+ it { should report_lint line: 1 }
79
+ end
80
+ end
81
+
82
+ context 'when brace is preceded by multiple spaces' do
83
+ let(:scss) { <<-SCSS }
84
+ @each $item in $list {
85
+ }
86
+ SCSS
87
+
88
+ it { should report_lint line: 1 }
89
+ end
90
+
91
+ context 'when brace is not preceded by a space' do
92
+ let(:scss) { <<-SCSS }
93
+ @each $item in $list{
94
+ }
95
+ SCSS
96
+
97
+ it { should report_lint line: 1 }
98
+ end
99
+
100
+ context 'when brace is preceded by a new line' do
101
+ let(:scss) { <<-SCSS }
102
+ @each $item in $list
103
+ {
104
+ }
105
+ SCSS
106
+
107
+ it { should report_lint line: 2 }
108
+
109
+ context 'and the `style` option is `new_line`' do
110
+ let(:linter_config) { { 'style' => 'new_line' } }
111
+
112
+ it { should_not report_lint }
113
+ end
114
+ end
115
+ end
116
+
117
+ context 'with a @for block' do
118
+ context 'when brace is preceded by a space' do
119
+ let(:scss) { <<-SCSS }
120
+ @for $i from $start to $end {
121
+ }
122
+ SCSS
123
+
124
+ it { should_not report_lint }
125
+
126
+ context 'and the `style` option is set to `new_line`' do
127
+ let(:linter_config) { { 'style' => 'new_line' } }
128
+
129
+ it { should report_lint line: 1 }
130
+ end
131
+ end
132
+
133
+ context 'when brace is preceded by multiple spaces' do
134
+ let(:scss) { <<-SCSS }
135
+ @for $i from $start to $end {
136
+ }
137
+ SCSS
138
+
139
+ it { should report_lint line: 1 }
140
+ end
141
+
142
+ context 'when brace is not preceded by a space' do
143
+ let(:scss) { <<-SCSS }
144
+ @for $i from $start to $end{
145
+ }
146
+ SCSS
147
+
148
+ it { should report_lint line: 1 }
149
+ end
150
+
151
+ context 'when brace is preceded by a new line' do
152
+ let(:scss) { <<-SCSS }
153
+ @for $i from $start to $end
154
+ {
155
+ }
156
+ SCSS
157
+
158
+ it { should report_lint line: 2 }
159
+
160
+ context 'and the `style` option is `new_line`' do
161
+ let(:linter_config) { { 'style' => 'new_line' } }
162
+
163
+ it { should_not report_lint }
164
+ end
165
+ end
166
+ end
167
+
168
+ context 'with a @while block' do
169
+ context 'when brace is preceded by a space' do
170
+ let(:scss) { <<-SCSS }
171
+ @while $condition {
172
+ }
173
+ SCSS
174
+
175
+ it { should_not report_lint }
176
+
177
+ context 'and the `style` option is set to `new_line`' do
178
+ let(:linter_config) { { 'style' => 'new_line' } }
179
+
180
+ it { should report_lint line: 1 }
181
+ end
182
+ end
183
+
184
+ context 'when brace is preceded by multiple spaces' do
185
+ let(:scss) { <<-SCSS }
186
+ @while $condition {
187
+ }
188
+ SCSS
189
+
190
+ it { should report_lint line: 1 }
191
+ end
192
+
193
+ context 'when brace is not preceded by a space' do
194
+ let(:scss) { <<-SCSS }
195
+ @while $condition{
196
+ }
197
+ SCSS
198
+
199
+ it { should report_lint line: 1 }
200
+ end
201
+
202
+ context 'when brace is preceded by a new line' do
203
+ let(:scss) { <<-SCSS }
204
+ @while $condition
205
+ {
206
+ }
207
+ SCSS
208
+
209
+ it { should report_lint line: 2 }
210
+
211
+ context 'and the `style` option is `new_line`' do
212
+ let(:linter_config) { { 'style' => 'new_line' } }
213
+
214
+ it { should_not report_lint }
215
+ end
216
+ end
217
+ end
218
+
219
+ context 'with a rule selector' do
220
+ context 'when brace is preceded by a space' do
221
+ let(:scss) { <<-SCSS }
222
+ p {
223
+ }
224
+ SCSS
225
+
226
+ it { should_not report_lint }
227
+
228
+ context 'and the `style` option is set to `new_line`' do
229
+ let(:linter_config) { { 'style' => 'new_line' } }
230
+
231
+ it { should report_lint line: 1 }
232
+ end
233
+ end
234
+
235
+ context 'when brace is preceded by multiple spaces' do
236
+ let(:scss) { <<-SCSS }
237
+ p {
238
+ }
239
+ SCSS
240
+
241
+ it { should report_lint line: 1 }
242
+ end
243
+
244
+ context 'when brace is not preceded by a space' do
245
+ let(:scss) { <<-SCSS }
246
+ p{
247
+ }
248
+ SCSS
249
+
250
+ it { should report_lint line: 1 }
251
+ end
252
+
253
+ context 'when brace is in a single line rule set' do
254
+ let(:scss) { <<-SCSS }
255
+ .single-line-selector{color: #f00;}
256
+ SCSS
257
+
258
+ it { should report_lint line: 1 }
259
+ end
260
+
261
+ context 'when brace is following a multi-selector rule set' do
262
+ let(:scss) { <<-SCSS }
263
+ .selector1,
264
+ .selector2,
265
+ .selector3{
266
+ }
267
+ SCSS
268
+
269
+ it { should report_lint line: 3 }
270
+ end
271
+
272
+ context 'when brace is preceded by a new line' do
273
+ let(:scss) { <<-SCSS }
274
+ p
275
+ {
276
+ }
277
+ SCSS
278
+
279
+ it { should report_lint line: 2 }
280
+
281
+ context 'and the `style` option is `new_line`' do
282
+ let(:linter_config) { { 'style' => 'new_line' } }
283
+
284
+ it { should_not report_lint }
285
+ end
286
+ end
287
+ end
288
+
289
+ context 'with a function declaration' do
290
+ context 'with arguments' do
291
+ context 'when brace is preceded by a space' do
292
+ let(:scss) { <<-SCSS }
293
+ @function func($arg, $arg2) {
294
+ }
295
+ SCSS
296
+
297
+ it { should_not report_lint }
298
+
299
+ context 'and the `style` option is set to `new_line`' do
300
+ let(:linter_config) { { 'style' => 'new_line' } }
301
+
302
+ it { should report_lint line: 1 }
303
+ end
304
+ end
305
+
306
+ context 'when brace is preceded by multiple spaces' do
307
+ let(:scss) { <<-SCSS }
308
+ @function func($arg, $arg2) {
309
+ }
310
+ SCSS
311
+
312
+ it { should report_lint line: 1 }
313
+ end
314
+
315
+ context 'when brace is not preceded by a space' do
316
+ let(:scss) { <<-SCSS }
317
+ @function func($arg, $arg2){
318
+ }
319
+ SCSS
320
+
321
+ it { should report_lint line: 1 }
322
+ end
323
+
324
+ context 'when brace is preceded by a new line' do
325
+ let(:scss) { <<-SCSS }
326
+ @function func($arg, $arg2)
327
+ {
328
+ }
329
+ SCSS
330
+
331
+ it { should report_lint line: 2 }
332
+
333
+ context 'and the `style` option is `new_line`' do
334
+ let(:linter_config) { { 'style' => 'new_line' } }
335
+
336
+ it { should_not report_lint }
337
+ end
338
+ end
339
+ end
340
+
341
+ context 'without arguments' do
342
+ context 'when brace is preceded by a space' do
343
+ let(:scss) { <<-SCSS }
344
+ @function func() {
345
+ }
346
+ SCSS
347
+
348
+ it { should_not report_lint }
349
+
350
+ context 'and the `style` option is set to `new_line`' do
351
+ let(:linter_config) { { 'style' => 'new_line' } }
352
+
353
+ it { should report_lint line: 1 }
354
+ end
355
+ end
356
+
357
+ context 'when brace is preceded by multiple spaces' do
358
+ let(:scss) { <<-SCSS }
359
+ @function func() {
360
+ }
361
+ SCSS
362
+
363
+ it { should report_lint line: 1 }
364
+ end
365
+
366
+ context 'when brace is not preceded by a space' do
367
+ let(:scss) { <<-SCSS }
368
+ @function func(){
369
+ }
370
+ SCSS
371
+
372
+ it { should report_lint line: 1 }
373
+ end
374
+
375
+ context 'when brace is preceded by a new line' do
376
+ let(:scss) { <<-SCSS }
377
+ @function func()
378
+ {
379
+ }
380
+ SCSS
381
+
382
+ it { should report_lint line: 2 }
383
+
384
+ context 'and the `style` option is `new_line`' do
385
+ let(:linter_config) { { 'style' => 'new_line' } }
386
+
387
+ it { should_not report_lint }
388
+ end
389
+ end
390
+ end
391
+ end
392
+
393
+ context 'with a mixin declaration' do
394
+ context 'with arguments' do
395
+ context 'when brace is preceded by a space' do
396
+ let(:scss) { <<-SCSS }
397
+ @mixin mixin($arg, $arg2) {
398
+ }
399
+ SCSS
400
+
401
+ it { should_not report_lint }
402
+
403
+ context 'and the `style` option is set to `new_line`' do
404
+ let(:linter_config) { { 'style' => 'new_line' } }
405
+
406
+ it { should report_lint line: 1 }
407
+ end
408
+ end
409
+
410
+ context 'when brace is preceded by multiple spaces' do
411
+ let(:scss) { <<-SCSS }
412
+ @mixin mixin($arg, $arg2) {
413
+ }
414
+ SCSS
415
+
416
+ it { should report_lint line: 1 }
417
+ end
418
+
419
+ context 'when brace is not preceded by a space' do
420
+ let(:scss) { <<-SCSS }
421
+ @mixin mixin($arg, $arg2){
422
+ }
423
+ SCSS
424
+
425
+ it { should report_lint line: 1 }
426
+ end
427
+
428
+ context 'when brace is preceded by a new line' do
429
+ let(:scss) { <<-SCSS }
430
+ @mixin mixin($arg, $arg2)
431
+ {
432
+ }
433
+ SCSS
434
+
435
+ it { should report_lint line: 2 }
436
+
437
+ context 'and the `style` option is `new_line`' do
438
+ let(:linter_config) { { 'style' => 'new_line' } }
439
+
440
+ it { should_not report_lint }
441
+ end
442
+ end
443
+ end
444
+
445
+ context 'without arguments' do
446
+ context 'when brace is preceded by a space' do
447
+ let(:scss) { <<-SCSS }
448
+ @mixin mixin {
449
+ }
450
+ SCSS
451
+
452
+ it { should_not report_lint }
453
+
454
+ context 'and the `style` option is set to `new_line`' do
455
+ let(:linter_config) { { 'style' => 'new_line' } }
456
+
457
+ it { should report_lint line: 1 }
458
+ end
459
+ end
460
+
461
+ context 'when brace is preceded by multiple spaces' do
462
+ let(:scss) { <<-SCSS }
463
+ @mixin mixin {
464
+ }
465
+ SCSS
466
+
467
+ it { should report_lint line: 1 }
468
+ end
469
+
470
+ context 'when brace is not preceded by a space' do
471
+ let(:scss) { <<-SCSS }
472
+ @mixin mixin{
473
+ }
474
+ SCSS
475
+
476
+ it { should report_lint line: 1 }
477
+ end
478
+
479
+ context 'when brace is preceded by a new line' do
480
+ let(:scss) { <<-SCSS }
481
+ @mixin mixin
482
+ {
483
+ }
484
+ SCSS
485
+
486
+ it { should report_lint line: 2 }
487
+
488
+ context 'and the `style` option is `new_line`' do
489
+ let(:linter_config) { { 'style' => 'new_line' } }
490
+
491
+ it { should_not report_lint }
492
+ end
493
+ end
494
+ end
495
+ end
496
+
497
+ context 'with a mixin include with braces' do
498
+ context 'with arguments' do
499
+ context 'when brace is preceded by a space' do
500
+ let(:scss) { <<-SCSS }
501
+ @include mixin(arg, arg2) {
502
+ }
503
+ SCSS
504
+
505
+ it { should_not report_lint }
506
+
507
+ context 'and the `style` option is set to `new_line`' do
508
+ let(:linter_config) { { 'style' => 'new_line' } }
509
+
510
+ it { should report_lint line: 1 }
511
+ end
512
+ end
513
+
514
+ context 'when brace is preceded by multiple spaces' do
515
+ let(:scss) { <<-SCSS }
516
+ @include mixin(arg, arg2) {
517
+ }
518
+ SCSS
519
+
520
+ it { should report_lint line: 1 }
521
+ end
522
+
523
+ context 'when brace is not preceded by a space' do
524
+ let(:scss) { <<-SCSS }
525
+ @include mixin(arg, arg2){
526
+ }
527
+ SCSS
528
+
529
+ it { should report_lint line: 1 }
530
+ end
531
+
532
+ context 'when brace is preceded by a new line' do
533
+ let(:scss) { <<-SCSS }
534
+ @include mixin(arg, arg2)
535
+ {
536
+ }
537
+ SCSS
538
+
539
+ it { should report_lint line: 2 }
540
+
541
+ context 'and the `style` option is `new_line`' do
542
+ let(:linter_config) { { 'style' => 'new_line' } }
543
+
544
+ it { should_not report_lint }
545
+ end
546
+ end
547
+ end
548
+
549
+ context 'without arguments' do
550
+ context 'when brace is preceded by a space' do
551
+ let(:scss) { <<-SCSS }
552
+ @include mixin {
553
+ }
554
+ SCSS
555
+
556
+ it { should_not report_lint }
557
+
558
+ context 'and the `style` option is set to `new_line`' do
559
+ let(:linter_config) { { 'style' => 'new_line' } }
560
+
561
+ it { should report_lint line: 1 }
562
+ end
563
+ end
564
+
565
+ context 'when brace is preceded by multiple spaces' do
566
+ let(:scss) { <<-SCSS }
567
+ @include mixin {
568
+ }
569
+ SCSS
570
+
571
+ it { should report_lint line: 1 }
572
+ end
573
+
574
+ context 'when brace is not preceded by a space' do
575
+ let(:scss) { <<-SCSS }
576
+ @include mixin{
577
+ }
578
+ SCSS
579
+
580
+ it { should report_lint line: 1 }
581
+ end
582
+
583
+ context 'when brace is preceded by a new line' do
584
+ let(:scss) { <<-SCSS }
585
+ @include mixin
586
+ {
587
+ }
588
+ SCSS
589
+
590
+ it { should report_lint line: 2 }
591
+
592
+ context 'and the `style` option is `new_line`' do
593
+ let(:linter_config) { { 'style' => 'new_line' } }
594
+
595
+ it { should_not report_lint }
596
+ end
597
+ end
598
+ end
599
+ end
600
+
601
+ context 'with a mixin include with no braces' do
602
+ context 'with arguments' do
603
+ let(:scss) { <<-SCSS }
604
+ @include mixin(arg, arg2);
605
+ SCSS
606
+
607
+ it { should_not report_lint }
608
+
609
+ context 'and the `style` option is set to `new_line`' do
610
+ let(:linter_config) { { 'style' => 'new_line' } }
611
+
612
+ it { should_not report_lint }
613
+ end
614
+ end
615
+
616
+ context 'without arguments' do
617
+ let(:scss) { <<-SCSS }
618
+ @include mixin;
619
+ SCSS
620
+
621
+ it { should_not report_lint }
622
+
623
+ context 'and the `style` option is set to `new_line`' do
624
+ let(:linter_config) { { 'style' => 'new_line' } }
625
+
626
+ it { should_not report_lint }
627
+ end
628
+ end
629
+ end
630
+
631
+ context 'when curly brace appears in a string' do
632
+ context 'and the `style` option is `space`' do
633
+ let(:scss) { <<-SCSS }
634
+ a {
635
+ content: "{";
636
+ }
637
+ SCSS
638
+
639
+ it { should_not report_lint }
640
+ end
641
+
642
+ context 'and the `style` option is `new_line`' do
643
+ let(:linter_config) { { 'style' => 'new_line' } }
644
+
645
+ let(:scss) { <<-SCSS }
646
+ a
647
+ {
648
+ content: "{";
649
+ }
650
+ SCSS
651
+
652
+ it { should_not report_lint }
653
+ end
654
+ end
655
+
656
+ context 'when using #{} interpolation' do
657
+ context 'and the `style` option is `space`' do
658
+ let(:scss) { <<-SCSS }
659
+ @mixin test-mixin($class, $prop, $pixels) {
660
+ .\#{$class} {
661
+ \#{$prop}: \#{$pixels}px;
662
+ }
663
+ }
664
+ SCSS
665
+
666
+ it { should_not report_lint }
667
+ end
668
+
669
+ context 'and the `style` option is `new_line`' do
670
+ let(:linter_config) { { 'style' => 'new_line' } }
671
+
672
+ let(:scss) { <<-SCSS }
673
+ @mixin test-mixin($class, $prop, $pixels)
674
+ {
675
+ .\#{$class}
676
+ {
677
+ \#{$prop}: \#{$pixels}px;
678
+ }
679
+ }
680
+ SCSS
681
+
682
+ it { should_not report_lint }
683
+ end
684
+ end
685
+
686
+ context 'when using braces in comments' do
687
+ let(:scss) { '// ({x})' }
688
+
689
+ it { should_not report_lint }
690
+
691
+ context 'and the `style` option is set to `new_line`' do
692
+ let(:linter_config) { { 'style' => 'new_line' } }
693
+
694
+ it { should_not report_lint }
695
+ end
696
+ end
697
+
698
+ context 'when blocks occupy a single line' do
699
+ let(:linter_config) do
700
+ {
701
+ 'allow_single_line_padding' => allow_single_line_padding,
702
+ 'style' => style
703
+ }
704
+ end
705
+
706
+ let(:scss) { <<-SCSS }
707
+ p{ }
708
+ p { }
709
+ p { &:before { } }
710
+ p { &:before{ } }
711
+ SCSS
712
+
713
+ context 'and the `allow_single_line_padding` option is true' do
714
+ let(:allow_single_line_padding) { true }
715
+ let(:style) { 'space' }
716
+
717
+ it { should report_lint line: 1 }
718
+ it { should_not report_lint line: 2 }
719
+ it { should_not report_lint line: 3 }
720
+ it { should report_lint line: 4 }
721
+
722
+ context 'and the `style` option is `new_line`' do
723
+ let(:style) { 'new_line' }
724
+
725
+ it { should report_lint line: 1 }
726
+ it { should_not report_lint line: 2 }
727
+ it { should_not report_lint line: 3 }
728
+ it { should report_lint line: 4 }
729
+ end
730
+ end
731
+
732
+ context 'and the `allow_single_line_padding` option is false' do
733
+ let(:allow_single_line_padding) { false }
734
+ let(:style) { 'space' }
735
+
736
+ it { should report_lint line: 1 }
737
+ it { should_not report_lint line: 2 }
738
+ it { should report_lint line: 3 }
739
+ it { should report_lint line: 4 }
740
+
741
+ context 'and the `style` option is `new_line`' do
742
+ let(:style) { 'new_line' }
743
+
744
+ it { should report_lint line: 1 }
745
+ it { should report_lint line: 2 }
746
+ it { should report_lint line: 3 }
747
+ it { should report_lint line: 4 }
748
+ end
749
+ end
750
+ end
751
+
752
+ context 'when curly brace is in single quotes' do
753
+ let(:scss) { <<-SCSS }
754
+ @if $token == '{' {
755
+ }
756
+ SCSS
757
+
758
+ it { should_not report_lint }
759
+
760
+ context 'and the `style` option is `new_line`' do
761
+ let(:linter_config) { { 'style' => 'new_line' } }
762
+
763
+ let(:scss) { <<-SCSS }
764
+ @if $token == '{'
765
+ {
766
+ }
767
+ SCSS
768
+
769
+ it { should_not report_lint }
770
+ end
771
+ end
772
+
773
+ context 'when curly brace is on own line' do
774
+ let(:scss) { <<-SCSS }
775
+ .class
776
+ {
777
+ }
778
+ SCSS
779
+
780
+ it { should report_lint line: 2 }
781
+
782
+ context 'and the `style` option is `new_line`' do
783
+ let(:linter_config) { { 'style' => 'new_line' } }
784
+
785
+ it { should_not report_lint }
786
+ end
787
+ end
788
+
789
+ context 'when the `style` option is `new_line`' do
790
+ let(:linter_config) { { 'style' => 'new_line' } }
791
+
792
+ context 'and the curly brace is preceded by a space' do
793
+ let(:scss) { <<-SCSS }
794
+ .class {
795
+ }
796
+ SCSS
797
+
798
+ it { should report_lint line: 1 }
799
+ end
800
+
801
+ context 'and the curly brace is preceded by multiple spaces' do
802
+ let(:scss) { <<-SCSS }
803
+ .class {
804
+ }
805
+ SCSS
806
+
807
+ it { should report_lint line: 1 }
808
+ end
809
+
810
+ context 'and there are multiple levels of nesting' do
811
+ let(:scss) { <<-SCSS }
812
+ ul
813
+ {
814
+ li
815
+ {
816
+ span
817
+ {
818
+ a
819
+ {
820
+ }
821
+ }
822
+ }
823
+ }
824
+ SCSS
825
+
826
+ it { should_not report_lint }
827
+ end
828
+ end
829
+ end