scss_lint 0.38.0

Sign up to get free protection for your applications and to get access to all the features.
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,189 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::DuplicateProperty do
4
+ context 'when rule set is empty' do
5
+ let(:scss) { <<-SCSS }
6
+ p {
7
+ }
8
+ SCSS
9
+
10
+ it { should_not report_lint }
11
+ end
12
+
13
+ context 'when rule set contains no duplicates' do
14
+ let(:scss) { <<-SCSS }
15
+ p {
16
+ margin: 0;
17
+ padding: 0;
18
+ }
19
+ SCSS
20
+
21
+ it { should_not report_lint }
22
+ end
23
+
24
+ context 'when rule set contains duplicates' do
25
+ let(:scss) { <<-SCSS }
26
+ p {
27
+ margin: 0;
28
+ padding: 0;
29
+ margin: 1em;
30
+ }
31
+ SCSS
32
+
33
+ it { should report_lint line: 4 }
34
+ end
35
+
36
+ context 'when rule set contains duplicates but only on vendor-prefixed property values' do
37
+ let(:scss) { <<-SCSS }
38
+ p {
39
+ background: -moz-linear-gradient(center top , #fff, #000);
40
+ background: -ms-linear-gradient(center top , #fff, #000);
41
+ background: -o-linear-gradient(center top , #fff, #000);
42
+ background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#000));
43
+ background: linear-gradient(center top , #fff, #000);
44
+ margin: 1em;
45
+ }
46
+ SCSS
47
+
48
+ it { should_not report_lint }
49
+ end
50
+
51
+ context 'when placeholder contains duplicates but only on vendor-prefixed values' do
52
+ let(:scss) { <<-SCSS }
53
+ %cursor-grabbing {
54
+ cursor: -moz-grabbing;
55
+ cursor: -webkit-grabbing;
56
+ cursor: grabbing;
57
+ }
58
+ SCSS
59
+
60
+ it { should_not report_lint }
61
+ end
62
+
63
+ context 'when placeholder contains exact duplicates besides for vendor-prefixed values' do
64
+ let(:scss) { <<-SCSS }
65
+ %cursor-grabbing {
66
+ cursor: grabbing;
67
+ cursor: grabbing;
68
+ }
69
+ SCSS
70
+
71
+ it { should report_lint line: 3 }
72
+ end
73
+
74
+ context 'when mixin contains duplicates but only on vendor-prefixed values' do
75
+ let(:scss) { <<-SCSS }
76
+ @mixin cursor-grabbing($num) {
77
+ cursor: -moz-grabbing;
78
+ cursor: -webkit-grabbing;
79
+ cursor: grabbing;
80
+ }
81
+ SCSS
82
+
83
+ it { should_not report_lint }
84
+ end
85
+
86
+ context 'when mixin contains duplicates besides for vendor-prefixed values' do
87
+ let(:scss) { <<-SCSS }
88
+ @mixin cursor-grabbing($num) {
89
+ cursor: grabbing;
90
+ cursor: grabbing;
91
+ }
92
+ SCSS
93
+
94
+ it { should report_lint line: 3 }
95
+ end
96
+
97
+ context 'when rule set contains exact duplicates besides for vendor-prefixed property values' do
98
+ let(:scss) { <<-SCSS }
99
+ p {
100
+ background: -moz-linear-gradient(center top , #fff, #000);
101
+ background: -ms-linear-gradient(center top , #fff, #000);
102
+ background: -o-linear-gradient(center top , #fff, #000);
103
+ background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#000));
104
+ background: linear-gradient(center top , #fff, #000);
105
+ background: linear-gradient(center top , #fff, #000);
106
+ margin: 1em;
107
+ }
108
+ SCSS
109
+
110
+ it { should report_lint line: 7 }
111
+ end
112
+
113
+ context 'when rule set contains non-exact duplicates besides for vendor-prefixed values' do
114
+ let(:scss) { <<-SCSS }
115
+ p {
116
+ background: -moz-linear-gradient(center top , #fff, #000);
117
+ background: -ms-linear-gradient(center top , #fff, #000);
118
+ background: -o-linear-gradient(center top , #fff, #000);
119
+ background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#000));
120
+ background: linear-gradient(center top , #fff, #000);
121
+ background: linear-gradient-b(center top , #fff, #000);
122
+ margin: 1em;
123
+ }
124
+ SCSS
125
+
126
+ it { should report_lint line: 7 }
127
+ end
128
+
129
+ context 'when rule set contains multiple duplicates' do
130
+ let(:scss) { <<-SCSS }
131
+ p {
132
+ margin: 0;
133
+ padding: 0;
134
+ margin: 1em;
135
+ margin: 2em;
136
+ }
137
+ SCSS
138
+
139
+ it { should report_lint line: 4 }
140
+ it { should report_lint line: 5 }
141
+ end
142
+
143
+ context 'when rule set contains duplicate properties with interpolation' do
144
+ let(:scss) { <<-SCSS }
145
+ p {
146
+ $direction: 'right';
147
+ margin-\#{direction}: 0;
148
+ $direction: 'left';
149
+ margin-\#{direction}: 0;
150
+ }
151
+ SCSS
152
+
153
+ it { should_not report_lint }
154
+ end
155
+
156
+ context 'when property contains a variable' do
157
+ let(:scss) { <<-SCSS }
158
+ p {
159
+ color: $some-color;
160
+ }
161
+ SCSS
162
+
163
+ it { should_not report_lint }
164
+ end
165
+
166
+ context 'when property contains a duplicate variable' do
167
+ let(:scss) { <<-SCSS }
168
+ p {
169
+ color: $some-color;
170
+ color: $some-color;
171
+ }
172
+ SCSS
173
+
174
+ it { should report_lint line: 3 }
175
+ end
176
+
177
+ context 'when property contains a duplicate value in a nested rule set' do
178
+ let(:scss) { <<-SCSS }
179
+ .outer {
180
+ .inner {
181
+ color: $some-color;
182
+ color: $some-color;
183
+ }
184
+ }
185
+ SCSS
186
+
187
+ it { should report_lint line: 4 }
188
+ end
189
+ end
@@ -0,0 +1,106 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::ElsePlacement do
4
+ context 'when @if contains no accompanying @else' do
5
+ let(:scss) { <<-SCSS }
6
+ @if $condition {
7
+ $var: 1;
8
+ }
9
+ SCSS
10
+
11
+ it { should_not report_lint }
12
+ end
13
+
14
+ context 'when @else is on different line' do
15
+ let(:scss) { <<-SCSS }
16
+ @if $condition {
17
+ $var: 1;
18
+ }
19
+ @else {
20
+ $var: 0;
21
+ }
22
+ SCSS
23
+
24
+ it { should report_lint line: 4 }
25
+ end
26
+
27
+ context 'when @else is on the same line as previous curly' do
28
+ let(:scss) { <<-SCSS }
29
+ @if $condition {
30
+ $var: 1;
31
+ } @else {
32
+ $var: 0;
33
+ }
34
+ SCSS
35
+
36
+ it { should_not report_lint }
37
+ end
38
+
39
+ context 'when `@else if` is on different line' do
40
+ let(:scss) { <<-SCSS }
41
+ @if $condition {
42
+ $var: 1;
43
+ }
44
+ @else if $other_condition {
45
+ $var: 2;
46
+ }
47
+ @else {
48
+ $var: 0;
49
+ }
50
+ SCSS
51
+
52
+ it { should report_lint line: 4 }
53
+ it { should report_lint line: 7 }
54
+ end
55
+
56
+ context 'when `@else if` is on the same line as previous curly' do
57
+ let(:scss) { <<-SCSS }
58
+ @if $condition {
59
+ $var: 1;
60
+ } @else if $other_condition {
61
+ $var: 2;
62
+ } @else {
63
+ $var: 0;
64
+ }
65
+ SCSS
66
+
67
+ it { should_not report_lint }
68
+ end
69
+
70
+ context 'when @else is on same line as @if' do
71
+ let(:scss) { <<-SCSS }
72
+ @if $condition { $var: 1; } @else { $var: 0; }
73
+ SCSS
74
+
75
+ it { should_not report_lint }
76
+ end
77
+
78
+ context 'when placement of @else on a new line is preferred' do
79
+ let(:linter_config) { { 'style' => 'new_line' } }
80
+
81
+ context 'when @else is on a new line' do
82
+ let(:scss) { <<-SCSS }
83
+ @if $condition {
84
+ $var: 1;
85
+ }
86
+ @else {
87
+ $var: 0;
88
+ }
89
+ SCSS
90
+
91
+ it { should_not report_lint }
92
+ end
93
+
94
+ context 'when @else is on the same line as previous curly brace' do
95
+ let(:scss) { <<-SCSS }
96
+ @if $condition {
97
+ $var: 1;
98
+ } @else {
99
+ $var: 0;
100
+ }
101
+ SCSS
102
+
103
+ it { should report_lint line: 3 }
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,276 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::EmptyLineBetweenBlocks do
4
+ context 'when there are multiple rule sets' do
5
+ context 'with blank lines between them' do
6
+ let(:scss) { <<-SCSS }
7
+ a {
8
+ }
9
+
10
+ b {
11
+ }
12
+
13
+ p {
14
+ }
15
+ SCSS
16
+
17
+ it { should_not report_lint }
18
+ end
19
+
20
+ context 'with no blank line between them' do
21
+ let(:scss) { <<-SCSS }
22
+ a {
23
+ }
24
+ b {
25
+ }
26
+ p {
27
+ }
28
+ SCSS
29
+
30
+ it { should report_lint line: 2 }
31
+ it { should report_lint line: 4 }
32
+ it { should_not report_lint line: 6 }
33
+ end
34
+ end
35
+
36
+ context 'when a rule set contains nested rule sets' do
37
+ context 'and the nested rule sets have no blank line between them' do
38
+ let(:scss) { <<-SCSS }
39
+ p {
40
+ a {
41
+ }
42
+ b {
43
+ }
44
+ }
45
+ SCSS
46
+
47
+ it { should report_lint line: 3 }
48
+ it { should_not report_lint line: 5 }
49
+ end
50
+
51
+ context 'and the nested rule sets have a blank line between them' do
52
+ let(:scss) { <<-SCSS }
53
+ p {
54
+ a {
55
+ }
56
+
57
+ b {
58
+ }
59
+ }
60
+ SCSS
61
+
62
+ it { should_not report_lint }
63
+ end
64
+
65
+ context 'and the nested rule set has a property preceding it' do
66
+ let(:scss) { <<-SCSS }
67
+ p {
68
+ margin: 0;
69
+ a {
70
+ }
71
+ }
72
+ SCSS
73
+
74
+ it { should report_lint line: 3 }
75
+ end
76
+
77
+ context 'and the nested rule set has a property and empty line preceding it' do
78
+ let(:scss) { <<-SCSS }
79
+ p {
80
+ margin: 0;
81
+
82
+ a {
83
+ }
84
+ }
85
+ SCSS
86
+
87
+ it { should_not report_lint }
88
+ end
89
+ end
90
+
91
+ context 'when mixins are defined' do
92
+ context 'and there is no blank line between them' do
93
+ let(:scss) { <<-SCSS }
94
+ @mixin mixin1() {
95
+ }
96
+ @mixin mixin2() {
97
+ }
98
+ SCSS
99
+
100
+ it { should report_lint line: 2 }
101
+ end
102
+
103
+ context 'and there is a blank line between them' do
104
+ let(:scss) { <<-SCSS }
105
+ @mixin mixin1() {
106
+ }
107
+
108
+ @mixin mixin2() {
109
+ }
110
+ SCSS
111
+
112
+ it { should_not report_lint }
113
+ end
114
+ end
115
+
116
+ context 'when mixins are included without content' do
117
+ let(:scss) { <<-SCSS }
118
+ p {
119
+ @include mixin1();
120
+ property: blah;
121
+ @include mixin2(4);
122
+ }
123
+ SCSS
124
+
125
+ it { should_not report_lint }
126
+ end
127
+
128
+ context 'when mixins are included with content' do
129
+ context 'and there is no blank line between them' do
130
+ let(:scss) { <<-SCSS }
131
+ @include mixin1() {
132
+ property: value;
133
+ }
134
+ @include mixin2() {
135
+ property: value;
136
+ }
137
+ SCSS
138
+
139
+ it { should report_lint line: 3 }
140
+ end
141
+
142
+ context 'and there is a blank line between them' do
143
+ let(:scss) { <<-SCSS }
144
+ @include mixin1() {
145
+ property: value;
146
+ }
147
+
148
+ @include mixin2() {
149
+ property: value;
150
+ }
151
+ SCSS
152
+
153
+ it { should_not report_lint }
154
+ end
155
+ end
156
+
157
+ context 'when functions are defined' do
158
+ context 'and there is no blank line between them' do
159
+ let(:scss) { <<-SCSS }
160
+ @function func1() {
161
+ }
162
+ @function func2() {
163
+ }
164
+ SCSS
165
+
166
+ it { should report_lint line: 2 }
167
+ end
168
+
169
+ context 'and there is a blank line between them' do
170
+ let(:scss) { <<-SCSS }
171
+ @function func1() {
172
+ }
173
+
174
+ @function func2() {
175
+ }
176
+ SCSS
177
+
178
+ it { should_not report_lint }
179
+ end
180
+ end
181
+
182
+ context 'when a rule set is preceded by a comment' do
183
+ let(:scss) { <<-SCSS }
184
+ a {
185
+ }
186
+
187
+ // This is a comment
188
+ p {
189
+ }
190
+ SCSS
191
+
192
+ it { should_not report_lint }
193
+ end
194
+
195
+ context 'when a rule set is immediately followed by a comment' do
196
+ let(:scss) { <<-SCSS }
197
+ a {
198
+ } // A comment
199
+
200
+ a {
201
+ } /* Another comment */
202
+ SCSS
203
+
204
+ it { should_not report_lint }
205
+ end
206
+
207
+ context 'when rule set is followed by a comment on the next line' do
208
+ let(:scss) { <<-SCSS }
209
+ a {
210
+ }
211
+ // A trailing comment (often a control comment)
212
+
213
+ b {
214
+ }
215
+ SCSS
216
+
217
+ it { should_not report_lint }
218
+ end
219
+
220
+ context 'when there are multiple placeholder rule sets' do
221
+ context 'with blank lines between them' do
222
+ let(:scss) { <<-SCSS }
223
+ %a {
224
+ }
225
+
226
+ %b {
227
+ }
228
+
229
+ %c {
230
+ }
231
+ SCSS
232
+
233
+ it { should_not report_lint }
234
+ end
235
+
236
+ context 'with no blank line between them' do
237
+ let(:scss) { <<-SCSS }
238
+ %a {
239
+ }
240
+ %b {
241
+ }
242
+ %c {
243
+ }
244
+ SCSS
245
+
246
+ it { should report_lint line: 2 }
247
+ it { should report_lint line: 4 }
248
+ it { should_not report_lint line: 6 }
249
+ end
250
+ end
251
+
252
+ context 'when blocks occupy a single line' do
253
+ let(:linter_config) { { 'ignore_single_line_blocks' => ignore_single_line_blocks } }
254
+
255
+ let(:scss) { <<-SCSS }
256
+ .icon-up { &:before { content: '^'; } }
257
+ .icon-right { &:before { content: '>'; } }
258
+ @include some-mixin { content: '<'; }
259
+ @include some-other-mixin { content: 'v'; }
260
+ SCSS
261
+
262
+ context 'and the `ignore_single_line_blocks` option is true' do
263
+ let(:ignore_single_line_blocks) { true }
264
+
265
+ it { should_not report_lint }
266
+ end
267
+
268
+ context 'and the `ignore_single_line_blocks` option is false' do
269
+ let(:ignore_single_line_blocks) { false }
270
+
271
+ it { should report_lint line: 1 }
272
+ it { should report_lint line: 2 }
273
+ it { should report_lint line: 3 }
274
+ end
275
+ end
276
+ end