scss-lint 0.29.0 → 0.30.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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +31 -1
  3. data/data/prefixed-identifiers/base.txt +107 -0
  4. data/data/prefixed-identifiers/bourbon.txt +71 -0
  5. data/lib/scss_lint/cli.rb +34 -7
  6. data/lib/scss_lint/config.rb +12 -1
  7. data/lib/scss_lint/engine.rb +3 -1
  8. data/lib/scss_lint/linter/bang_format.rb +40 -0
  9. data/lib/scss_lint/linter/declaration_order.rb +35 -14
  10. data/lib/scss_lint/linter/import_path.rb +62 -0
  11. data/lib/scss_lint/linter/name_format.rb +1 -1
  12. data/lib/scss_lint/linter/nesting_depth.rb +24 -0
  13. data/lib/scss_lint/linter/property_sort_order.rb +4 -11
  14. data/lib/scss_lint/linter/property_spelling.rb +25 -8
  15. data/lib/scss_lint/linter/qualifying_element.rb +42 -0
  16. data/lib/scss_lint/linter/selector_format.rb +23 -11
  17. data/lib/scss_lint/linter/space_after_property_colon.rb +4 -4
  18. data/lib/scss_lint/linter/space_after_property_name.rb +16 -1
  19. data/lib/scss_lint/linter/space_before_brace.rb +36 -9
  20. data/lib/scss_lint/linter/trailing_semicolon.rb +6 -2
  21. data/lib/scss_lint/linter/vendor_prefixes.rb +64 -0
  22. data/lib/scss_lint/rake_task.rb +1 -0
  23. data/lib/scss_lint/runner.rb +2 -1
  24. data/lib/scss_lint/sass/script.rb +10 -0
  25. data/lib/scss_lint/version.rb +1 -1
  26. data/spec/scss_lint/cli_spec.rb +45 -2
  27. data/spec/scss_lint/linter/bang_format_spec.rb +79 -0
  28. data/spec/scss_lint/linter/declaration_order_spec.rb +466 -0
  29. data/spec/scss_lint/linter/import_path_spec.rb +300 -0
  30. data/spec/scss_lint/linter/nesting_depth_spec.rb +114 -0
  31. data/spec/scss_lint/linter/property_spelling_spec.rb +27 -0
  32. data/spec/scss_lint/linter/qualifying_element_spec.rb +125 -0
  33. data/spec/scss_lint/linter/selector_format_spec.rb +329 -0
  34. data/spec/scss_lint/linter/space_after_property_colon_spec.rb +14 -0
  35. data/spec/scss_lint/linter/space_after_property_name_spec.rb +14 -0
  36. data/spec/scss_lint/linter/space_before_brace_spec.rb +401 -17
  37. data/spec/scss_lint/linter/trailing_semicolon_spec.rb +47 -0
  38. data/spec/scss_lint/linter/vendor_prefixes_spec.rb +350 -0
  39. metadata +19 -2
@@ -269,4 +269,333 @@ describe SCSSLint::Linter::SelectorFormat do
269
269
  it { should_not report_lint }
270
270
  end
271
271
  end
272
+
273
+ context 'when using a unique `id_convention`' do
274
+ let(:linter_config) { { 'id_convention' => 'snake_case' } }
275
+
276
+ context 'and actual id is correct' do
277
+ let(:css) { <<-CSS }
278
+ .hyphenated-lowercase {}
279
+ #snake_case {}
280
+ CSS
281
+
282
+ it { should_not report_lint }
283
+ end
284
+
285
+ context 'and actual id is incorrect' do
286
+ let(:css) { <<-CSS }
287
+ .hyphenated-lowercase {}
288
+ #hyphenated-lowercase {}
289
+ CSS
290
+
291
+ it { should report_lint line: 2 }
292
+ end
293
+
294
+ context 'and something else uses the `id_convention`' do
295
+ let(:css) { <<-CSS }
296
+ .snake_case {}
297
+ #hyphenated-lowercase {}
298
+ CSS
299
+
300
+ it { should report_lint line: 1 }
301
+ end
302
+ end
303
+
304
+ context 'when using a unique `class_convention`' do
305
+ let(:linter_config) { { 'class_convention' => 'camel_case' } }
306
+
307
+ context 'and actual class is correct' do
308
+ let(:css) { <<-CSS }
309
+ .camelCase {}
310
+ #hyphenated-lowercase {}
311
+ CSS
312
+
313
+ it { should_not report_lint }
314
+ end
315
+
316
+ context 'and actual class is incorrect' do
317
+ let(:css) { <<-CSS }
318
+ .hyphenated-lowercase {}
319
+ #hyphenated-lowercase {}
320
+ CSS
321
+
322
+ it { should report_lint line: 1 }
323
+ end
324
+
325
+ context 'and something else uses the `class_convention`' do
326
+ let(:css) { <<-CSS }
327
+ .hyphenated-lowercase {}
328
+ #camelCase {}
329
+ CSS
330
+
331
+ it { should report_lint line: 2 }
332
+ end
333
+ end
334
+
335
+ context 'when using a unique `placeholder_convention`' do
336
+ let(:linter_config) { { 'placeholder_convention' => 'snake_case' } }
337
+
338
+ context 'and actual placeholder is correct' do
339
+ let(:css) { <<-CSS }
340
+ .hyphenated-lowercase {}
341
+ %snake_case {}
342
+ CSS
343
+
344
+ it { should_not report_lint }
345
+ end
346
+
347
+ context 'and actual placeholder is incorrect' do
348
+ let(:css) { <<-CSS }
349
+ .hyphenated-lowercase {}
350
+ %hyphenated-lowercase {}
351
+ CSS
352
+
353
+ it { should report_lint line: 2 }
354
+ end
355
+
356
+ context 'and something else uses the `placeholder_convention`' do
357
+ let(:css) { <<-CSS }
358
+ .snake_case {}
359
+ %snake_case {}
360
+ CSS
361
+
362
+ it { should report_lint line: 1 }
363
+ end
364
+ end
365
+
366
+ context 'when using a unique `element_convention`' do
367
+ let(:linter_config) do
368
+ {
369
+ 'convention' => 'camel_case',
370
+ 'element_convention' => 'hyphenated-lowercase'
371
+ }
372
+ end
373
+
374
+ context 'and actual element is correct' do
375
+ let(:css) { <<-CSS }
376
+ hyphenated-lowercase {}
377
+ #camelCase {}
378
+ CSS
379
+
380
+ it { should_not report_lint }
381
+ end
382
+
383
+ context 'and actual element is incorrect' do
384
+ let(:css) { <<-CSS }
385
+ camelCase {}
386
+ #camelCase {}
387
+ CSS
388
+
389
+ it { should report_lint line: 1 }
390
+ end
391
+
392
+ context 'and something else uses the `element_convention`' do
393
+ let(:css) { <<-CSS }
394
+ hyphenated-lowercase {}
395
+ #hyphenated-lowercase {}
396
+ CSS
397
+
398
+ it { should report_lint line: 2 }
399
+ end
400
+ end
401
+
402
+ context 'when using a unique `pseudo_convention`' do
403
+ let(:linter_config) do
404
+ {
405
+ 'convention' => 'camel_case',
406
+ 'pseudo_convention' => 'hyphenated-lowercase'
407
+ }
408
+ end
409
+
410
+ context 'and actual pseudo is correct' do
411
+ let(:css) { <<-CSS }
412
+ :hyphenated-lowercase {}
413
+ #camelCase {}
414
+ CSS
415
+
416
+ it { should_not report_lint }
417
+ end
418
+
419
+ context 'and actual pseudo is incorrect' do
420
+ let(:css) { <<-CSS }
421
+ :camelCase {}
422
+ #camelCase {}
423
+ CSS
424
+
425
+ it { should report_lint line: 1 }
426
+ end
427
+
428
+ context 'and something else uses the `pseudo_convention`' do
429
+ let(:css) { <<-CSS }
430
+ :hyphenated-lowercase {}
431
+ #hyphenated-lowercase {}
432
+ CSS
433
+
434
+ it { should report_lint line: 2 }
435
+ end
436
+ end
437
+
438
+ context 'when using a unique `attribute_convention`' do
439
+ let(:linter_config) do
440
+ {
441
+ 'convention' => 'camel_case',
442
+ 'attribute_convention' => 'hyphenated-lowercase'
443
+ }
444
+ end
445
+
446
+ context 'and actual attribute is correct' do
447
+ let(:css) { <<-CSS }
448
+ [hyphenated-lowercase] {}
449
+ #camelCase {}
450
+ CSS
451
+
452
+ it { should_not report_lint }
453
+ end
454
+
455
+ context 'and actual attribute is incorrect' do
456
+ let(:css) { <<-CSS }
457
+ [camelCase] {}
458
+ #camelCase {}
459
+ CSS
460
+
461
+ it { should report_lint line: 1 }
462
+ end
463
+
464
+ context 'and something else uses the `attribute_convention`' do
465
+ let(:css) { <<-CSS }
466
+ [hyphenated-lowercase] {}
467
+ #hyphenated-lowercase {}
468
+ CSS
469
+
470
+ it { should report_lint line: 2 }
471
+ end
472
+ end
473
+
474
+ context 'when using a blend of unique conventions' do
475
+ let(:linter_config) do
476
+ {
477
+ 'convention' => 'camel_case',
478
+ 'element_convention' => 'hyphenated-lowercase',
479
+ 'attribute_convention' => 'snake_case',
480
+ 'class_convention' => /[a-z]+\-\-[a-z]+/
481
+ }
482
+ end
483
+
484
+ context 'and everything is correct' do
485
+ let(:css) { <<-CSS }
486
+ #camelCase {}
487
+ hyphenated-lowercase {}
488
+ [snake_case] {}
489
+ .foo--bar {}
490
+ CSS
491
+
492
+ it { should_not report_lint }
493
+ end
494
+
495
+ context 'some things are not correct' do
496
+ let(:css) { <<-CSS }
497
+ #camelCase {}
498
+ camelCase {}
499
+ [snake_case] {}
500
+ .fooBar {}
501
+ CSS
502
+
503
+ it { should report_lint line: 2 }
504
+ it { should report_lint line: 4 }
505
+ end
506
+
507
+ context 'other things are not correct' do
508
+ let(:css) { <<-CSS }
509
+ #snake_case {}
510
+ hyphenated-lowercase {}
511
+ [camelCase] {}
512
+ .foo--bar {}
513
+ CSS
514
+
515
+ it { should report_lint line: 1 }
516
+ it { should report_lint line: 3 }
517
+ end
518
+ end
519
+
520
+ context 'when the BEM convention is specified' do
521
+ let(:linter_config) { { 'convention' => 'BEM' } }
522
+
523
+ context 'when a name contains no underscores or hyphens' do
524
+ let(:css) { '.block {}' }
525
+
526
+ it { should_not report_lint }
527
+ end
528
+
529
+ context 'when a name contains single hyphen' do
530
+ let(:css) { '.b-block {}' }
531
+
532
+ it { should_not report_lint }
533
+ end
534
+
535
+ context 'when a name contains multiple hyphens' do
536
+ let(:css) { '.b-block-name {}' }
537
+
538
+ it { should_not report_lint }
539
+ end
540
+
541
+ context 'when a name contains multiple hyphens in a row' do
542
+ let(:css) { '.b-block--modifier {}' }
543
+
544
+ it { should report_lint }
545
+ end
546
+
547
+ context 'when a name contains a single underscore' do
548
+ let(:css) { '.block_modifier {}' }
549
+
550
+ it { should report_lint }
551
+ end
552
+
553
+ context 'when a block has name-value modifier' do
554
+ let(:css) { '.block_modifier_value {}' }
555
+
556
+ it { should_not report_lint }
557
+ end
558
+
559
+ context 'when a block has name-value modifier with lots of hyphens' do
560
+ let(:css) { '.b-block-name_modifier-name-here_value-name-here {}' }
561
+
562
+ it { should_not report_lint }
563
+ end
564
+
565
+ context 'when a name has double underscores' do
566
+ let(:css) { '.b-block__element {}' }
567
+
568
+ it { should_not report_lint }
569
+ end
570
+
571
+ context 'when element goes after block with modifier' do
572
+ let(:css) { '.block_modifier_value__element {}' }
573
+
574
+ it { should report_lint }
575
+ end
576
+
577
+ context 'when element has modifier' do
578
+ let(:css) { '.block__element_modifier_value {}' }
579
+
580
+ it { should_not report_lint }
581
+ end
582
+
583
+ context 'when element has not paired modifier' do
584
+ let(:css) { '.block__element_modifier {}' }
585
+
586
+ it { should report_lint }
587
+ end
588
+
589
+ context 'when element has hypenated modifier' do
590
+ let(:css) { '.block__element--modifier {}' }
591
+
592
+ it { should report_lint }
593
+ end
594
+
595
+ context 'when element has hypenated paired modifier' do
596
+ let(:css) { '.block__element--modifier_value {}' }
597
+
598
+ it { should report_lint }
599
+ end
600
+ end
272
601
  end
@@ -55,6 +55,20 @@ describe SCSSLint::Linter::SpaceAfterPropertyColon do
55
55
 
56
56
  it { should report_lint line: 2 }
57
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(:css) { "[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(:css) { "[class~='\#{$test}'] { width:100%; }" }
68
+
69
+ it { should report_lint }
70
+ end
71
+ end
58
72
  end
59
73
 
60
74
  context 'when no spaces are allowed' do
@@ -20,4 +20,18 @@ describe SCSSLint::Linter::SpaceAfterPropertyName do
20
20
 
21
21
  it { should_not report_lint }
22
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(:css) { "[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(:css) { "[class~='\#{$test}'] { width : 100%; }" }
33
+
34
+ it { should report_lint }
35
+ end
36
+ end
23
37
  end
@@ -11,6 +11,13 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
11
11
  CSS
12
12
 
13
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
14
21
  end
15
22
 
16
23
  context 'when brace is preceded by multiple spaces' do
@@ -34,6 +41,26 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
34
41
 
35
42
  it { should report_lint line: 2 }
36
43
  end
44
+
45
+ context 'when brace is preceded by a new line' do
46
+ let(:css) { <<-CSS }
47
+ .parent
48
+ {
49
+ @at-root .child
50
+ {
51
+ }
52
+ }
53
+ CSS
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
37
64
  end
38
65
 
39
66
  context 'with an @each block' do
@@ -44,6 +71,12 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
44
71
  CSS
45
72
 
46
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
47
80
  end
48
81
 
49
82
  context 'when brace is preceded by multiple spaces' do
@@ -63,6 +96,22 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
63
96
 
64
97
  it { should report_lint line: 1 }
65
98
  end
99
+
100
+ context 'when brace is preceded by a new line' do
101
+ let(:css) { <<-CSS }
102
+ @each $item in $list
103
+ {
104
+ }
105
+ CSS
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
66
115
  end
67
116
 
68
117
  context 'with a @for block' do
@@ -73,6 +122,12 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
73
122
  CSS
74
123
 
75
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
76
131
  end
77
132
 
78
133
  context 'when brace is preceded by multiple spaces' do
@@ -92,6 +147,22 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
92
147
 
93
148
  it { should report_lint line: 1 }
94
149
  end
150
+
151
+ context 'when brace is preceded by a new line' do
152
+ let(:css) { <<-CSS }
153
+ @for $i from $start to $end
154
+ {
155
+ }
156
+ CSS
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
95
166
  end
96
167
 
97
168
  context 'with a @while block' do
@@ -102,6 +173,12 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
102
173
  CSS
103
174
 
104
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
105
182
  end
106
183
 
107
184
  context 'when brace is preceded by multiple spaces' do
@@ -121,6 +198,22 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
121
198
 
122
199
  it { should report_lint line: 1 }
123
200
  end
201
+
202
+ context 'when brace is preceded by a new line' do
203
+ let(:css) { <<-CSS }
204
+ @while $condition
205
+ {
206
+ }
207
+ CSS
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
124
217
  end
125
218
 
126
219
  context 'with a rule selector' do
@@ -131,6 +224,12 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
131
224
  CSS
132
225
 
133
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
134
233
  end
135
234
 
136
235
  context 'when brace is preceded by multiple spaces' do
@@ -169,6 +268,22 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
169
268
 
170
269
  it { should report_lint line: 3 }
171
270
  end
271
+
272
+ context 'when brace is preceded by a new line' do
273
+ let(:css) { <<-CSS }
274
+ p
275
+ {
276
+ }
277
+ CSS
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
172
287
  end
173
288
 
174
289
  context 'with a function declaration' do
@@ -180,6 +295,12 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
180
295
  CSS
181
296
 
182
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
183
304
  end
184
305
 
185
306
  context 'when brace is preceded by multiple spaces' do
@@ -199,6 +320,22 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
199
320
 
200
321
  it { should report_lint line: 1 }
201
322
  end
323
+
324
+ context 'when brace is preceded by a new line' do
325
+ let(:css) { <<-CSS }
326
+ @function func($arg, $arg2)
327
+ {
328
+ }
329
+ CSS
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
202
339
  end
203
340
 
204
341
  context 'without arguments' do
@@ -209,6 +346,12 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
209
346
  CSS
210
347
 
211
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
212
355
  end
213
356
 
214
357
  context 'when brace is preceded by multiple spaces' do
@@ -228,6 +371,22 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
228
371
 
229
372
  it { should report_lint line: 1 }
230
373
  end
374
+
375
+ context 'when brace is preceded by a new line' do
376
+ let(:css) { <<-CSS }
377
+ @function func()
378
+ {
379
+ }
380
+ CSS
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
231
390
  end
232
391
  end
233
392
 
@@ -240,6 +399,12 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
240
399
  CSS
241
400
 
242
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
243
408
  end
244
409
 
245
410
  context 'when brace is preceded by multiple spaces' do
@@ -259,6 +424,22 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
259
424
 
260
425
  it { should report_lint line: 1 }
261
426
  end
427
+
428
+ context 'when brace is preceded by a new line' do
429
+ let(:css) { <<-CSS }
430
+ @mixin mixin($arg, $arg2)
431
+ {
432
+ }
433
+ CSS
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
262
443
  end
263
444
 
264
445
  context 'without arguments' do
@@ -269,6 +450,12 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
269
450
  CSS
270
451
 
271
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
272
459
  end
273
460
 
274
461
  context 'when brace is preceded by multiple spaces' do
@@ -288,6 +475,22 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
288
475
 
289
476
  it { should report_lint line: 1 }
290
477
  end
478
+
479
+ context 'when brace is preceded by a new line' do
480
+ let(:css) { <<-CSS }
481
+ @mixin mixin
482
+ {
483
+ }
484
+ CSS
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
291
494
  end
292
495
  end
293
496
 
@@ -300,6 +503,12 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
300
503
  CSS
301
504
 
302
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
303
512
  end
304
513
 
305
514
  context 'when brace is preceded by multiple spaces' do
@@ -319,6 +528,22 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
319
528
 
320
529
  it { should report_lint line: 1 }
321
530
  end
531
+
532
+ context 'when brace is preceded by a new line' do
533
+ let(:css) { <<-CSS }
534
+ @include mixin(arg, arg2)
535
+ {
536
+ }
537
+ CSS
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
322
547
  end
323
548
 
324
549
  context 'without arguments' do
@@ -329,6 +554,12 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
329
554
  CSS
330
555
 
331
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
332
563
  end
333
564
 
334
565
  context 'when brace is preceded by multiple spaces' do
@@ -348,6 +579,22 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
348
579
 
349
580
  it { should report_lint line: 1 }
350
581
  end
582
+
583
+ context 'when brace is preceded by a new line' do
584
+ let(:css) { <<-CSS }
585
+ @include mixin
586
+ {
587
+ }
588
+ CSS
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
351
598
  end
352
599
  end
353
600
 
@@ -358,6 +605,12 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
358
605
  CSS
359
606
 
360
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
361
614
  end
362
615
 
363
616
  context 'without arguments' do
@@ -366,39 +619,90 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
366
619
  CSS
367
620
 
368
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
369
628
  end
370
629
  end
371
630
 
372
631
  context 'when curly brace appears in a string' do
373
- let(:css) { <<-CSS }
374
- a {
375
- content: "{";
376
- }
377
- CSS
632
+ context 'and the `style` option is `space`' do
633
+ let(:css) { <<-CSS }
634
+ a {
635
+ content: "{";
636
+ }
637
+ CSS
378
638
 
379
- it { should_not report_lint }
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(:css) { <<-CSS }
646
+ a
647
+ {
648
+ content: "{";
649
+ }
650
+ CSS
651
+
652
+ it { should_not report_lint }
653
+ end
380
654
  end
381
655
 
382
656
  context 'when using #{} interpolation' do
383
- let(:css) { <<-CSS }
384
- @mixin test-mixin($class, $prop, $pixels) {
385
- .\#{$class} {
386
- \#{$prop}: \#{$pixels}px;
657
+
658
+ context 'and the `style` option is `space`' do
659
+ let(:css) { <<-CSS }
660
+ @mixin test-mixin($class, $prop, $pixels) {
661
+ .\#{$class} {
662
+ \#{$prop}: \#{$pixels}px;
663
+ }
387
664
  }
388
- }
389
- CSS
665
+ CSS
390
666
 
391
- it { should_not report_lint }
667
+ it { should_not report_lint }
668
+ end
669
+
670
+ context 'and the `style` option is `new_line`' do
671
+ let(:linter_config) { { 'style' => 'new_line' } }
672
+
673
+ let(:css) { <<-CSS }
674
+ @mixin test-mixin($class, $prop, $pixels)
675
+ {
676
+ .\#{$class}
677
+ {
678
+ \#{$prop}: \#{$pixels}px;
679
+ }
680
+ }
681
+ CSS
682
+
683
+ it { should_not report_lint }
684
+ end
392
685
  end
393
686
 
394
687
  context 'when using braces in comments' do
395
688
  let(:css) { '// ({x})' }
396
689
 
397
690
  it { should_not report_lint }
691
+
692
+ context 'and the `style` option is set to `new_line`' do
693
+ let(:linter_config) { { 'style' => 'new_line' } }
694
+
695
+ it { should_not report_lint }
696
+ end
398
697
  end
399
698
 
400
699
  context 'when blocks occupy a single line' do
401
- let(:linter_config) { { 'allow_single_line_padding' => allow_single_line_padding } }
700
+ let(:linter_config) do
701
+ {
702
+ 'allow_single_line_padding' => allow_single_line_padding,
703
+ 'style' => style
704
+ }
705
+ end
402
706
 
403
707
  let(:css) { <<-CSS }
404
708
  p{ }
@@ -407,22 +711,42 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
407
711
  p { &:before{ } }
408
712
  CSS
409
713
 
410
- context 'and the `allow_extra_spaces` option is true' do
714
+ context 'and the `allow_single_line_padding` option is true' do
411
715
  let(:allow_single_line_padding) { true }
716
+ let(:style) { 'space' }
412
717
 
413
718
  it { should report_lint line: 1 }
414
719
  it { should_not report_lint line: 2 }
415
720
  it { should_not report_lint line: 3 }
416
721
  it { should report_lint line: 4 }
722
+
723
+ context 'and the `style` option is `new_line`' do
724
+ let(:style) { 'new_line' }
725
+
726
+ it { should report_lint line: 1 }
727
+ it { should_not report_lint line: 2 }
728
+ it { should_not report_lint line: 3 }
729
+ it { should report_lint line: 4 }
730
+ end
417
731
  end
418
732
 
419
- context 'and the `allow_extra_spaces` option is false' do
733
+ context 'and the `allow_single_line_padding` option is false' do
420
734
  let(:allow_single_line_padding) { false }
735
+ let(:style) { 'space' }
421
736
 
422
737
  it { should report_lint line: 1 }
423
738
  it { should_not report_lint line: 2 }
424
739
  it { should report_lint line: 3 }
425
740
  it { should report_lint line: 4 }
741
+
742
+ context 'and the `style` option is `new_line`' do
743
+ let(:style) { 'new_line' }
744
+
745
+ it { should report_lint line: 1 }
746
+ it { should report_lint line: 2 }
747
+ it { should report_lint line: 3 }
748
+ it { should report_lint line: 4 }
749
+ end
426
750
  end
427
751
  end
428
752
 
@@ -433,6 +757,19 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
433
757
  CSS
434
758
 
435
759
  it { should_not report_lint }
760
+
761
+ context 'and the `style` option is `new_line`' do
762
+ let(:linter_config) { { 'style' => 'new_line' } }
763
+
764
+ let(:css) { <<-CSS }
765
+ @if $token == '{'
766
+ {
767
+ }
768
+ CSS
769
+
770
+ it { should_not report_lint }
771
+ end
772
+
436
773
  end
437
774
 
438
775
  context 'when curly brace is on own line' do
@@ -442,6 +779,53 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
442
779
  }
443
780
  CSS
444
781
 
445
- it { should_not report_lint }
782
+ it { should report_lint line: 2 }
783
+
784
+ context 'and the `style` option is `new_line`' do
785
+ let(:linter_config) { { 'style' => 'new_line' } }
786
+
787
+ it { should_not report_lint }
788
+ end
789
+ end
790
+
791
+ context 'when the `style` option is `new_line`' do
792
+ let(:linter_config) { { 'style' => 'new_line' } }
793
+
794
+ context 'and the curly brace is preceded by a space' do
795
+ let(:css) { <<-CSS }
796
+ .class {
797
+ }
798
+ CSS
799
+
800
+ it { should report_lint line: 1 }
801
+ end
802
+
803
+ context 'and the curly brace is preceded by multiple spaces' do
804
+ let(:css) { <<-CSS }
805
+ .class {
806
+ }
807
+ CSS
808
+
809
+ it { should report_lint line: 1 }
810
+ end
811
+
812
+ context 'and there are multiple levels of nesting' do
813
+ let(:css) { <<-CSS }
814
+ ul
815
+ {
816
+ li
817
+ {
818
+ span
819
+ {
820
+ a
821
+ {
822
+ }
823
+ }
824
+ }
825
+ }
826
+ CSS
827
+
828
+ it { should_not report_lint }
829
+ end
446
830
  end
447
831
  end