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,84 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::PropertySpelling do
4
+ context 'with a regular property' do
5
+ let(:scss) { <<-SCSS }
6
+ p {
7
+ margin: 5px;
8
+ }
9
+ SCSS
10
+
11
+ it { should_not report_lint }
12
+ end
13
+
14
+ context 'with a property containing interpolation' do
15
+ let(:scss) { <<-SCSS }
16
+ p {
17
+ \#{$property-name}: 5px;
18
+ }
19
+ SCSS
20
+
21
+ it { should_not report_lint }
22
+ end
23
+
24
+ context 'with a non-existent property' do
25
+ let(:scss) { <<-SCSS }
26
+ p {
27
+ peanut-butter: jelly-time;
28
+ }
29
+ SCSS
30
+
31
+ it { should report_lint }
32
+ end
33
+
34
+ context 'when extra properties are specified' do
35
+ let(:linter_config) { { 'extra_properties' => ['made-up-property'] } }
36
+
37
+ context 'with a non-existent property' do
38
+ let(:scss) { <<-SCSS }
39
+ p {
40
+ peanut-butter: jelly-time;
41
+ }
42
+ SCSS
43
+
44
+ it { should report_lint }
45
+ end
46
+
47
+ context 'with a property listed as an extra property' do
48
+ let(:scss) { <<-SCSS }
49
+ p {
50
+ made-up-property: value;
51
+ }
52
+ SCSS
53
+
54
+ it { should_not report_lint }
55
+ end
56
+ end
57
+
58
+ context 'with valid nested properties' do
59
+ let(:scss) { <<-SCSS }
60
+ p {
61
+ text: {
62
+ align: center;
63
+ transform: uppercase;
64
+ }
65
+ }
66
+ SCSS
67
+
68
+ it { should_not report_lint }
69
+ end
70
+
71
+ context 'with invalid nested properties' do
72
+ let(:scss) { <<-SCSS }
73
+ p {
74
+ text: {
75
+ aligned: center;
76
+ transformed: uppercase;
77
+ }
78
+ }
79
+ SCSS
80
+
81
+ it { should report_lint line: 3 }
82
+ it { should report_lint line: 4 }
83
+ end
84
+ end
@@ -0,0 +1,229 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::PropertyUnits do
4
+ context 'when global units are set and local are not set' do
5
+ let(:linter_config) { { 'global' => ['rem'], 'properties' => {} } }
6
+
7
+ context 'when unit is allowed' do
8
+ let(:scss) { <<-SCSS }
9
+ p {
10
+ font-size: 1.54rem;
11
+ margin: 1rem;
12
+ padding: .1rem;
13
+ }
14
+ SCSS
15
+
16
+ it { should_not report_lint }
17
+ end
18
+
19
+ context 'when unit is not allowed' do
20
+ let(:scss) { <<-SCSS }
21
+ p {
22
+ font-size: 16.54px;
23
+ margin: 1px;
24
+ padding: .1px;
25
+ }
26
+ SCSS
27
+
28
+ it { should report_lint line: 2 }
29
+ it { should report_lint line: 3 }
30
+ it { should report_lint line: 4 }
31
+ end
32
+
33
+ context 'when using a shorthand property' do
34
+ context 'and the unit is allowed' do
35
+ let(:scss) { <<-SCSS }
36
+ p {
37
+ font: italic 1rem Serif;
38
+ }
39
+ SCSS
40
+
41
+ it { should_not report_lint }
42
+ end
43
+
44
+ context 'and the unit is not allowed' do
45
+ let(:scss) { <<-SCSS }
46
+ p {
47
+ font: italic 16px Serif;
48
+ }
49
+ SCSS
50
+
51
+ it { should report_lint line: 2 }
52
+ end
53
+ end
54
+ end
55
+
56
+ context 'when global and local units are set' do
57
+ let(:linter_config) { { 'global' => ['rem'], 'properties' => { 'font-size' => ['px'] } } }
58
+
59
+ context 'when unit is allowed locally not globally' do
60
+ let(:scss) { <<-SCSS }
61
+ p {
62
+ font-size: 16px;
63
+ }
64
+ SCSS
65
+
66
+ it { should_not report_lint }
67
+ end
68
+
69
+ context 'when unit is allowed globally not locally' do
70
+ let(:scss) { <<-SCSS }
71
+ p {
72
+ margin: 1rem;
73
+ }
74
+ SCSS
75
+
76
+ it { should_not report_lint }
77
+ end
78
+
79
+ context 'when unit is not allowed globally nor locally' do
80
+ let(:scss) { <<-SCSS }
81
+ p {
82
+ margin: 1vh;
83
+ }
84
+ SCSS
85
+
86
+ it { should report_lint line: 2 }
87
+ end
88
+ end
89
+
90
+ context 'when local units are set and global are not set' do
91
+ let(:linter_config) { { 'global' => [], 'properties' => { 'margin' => ['rem'] } } }
92
+
93
+ context 'when unit is allowed locally not globally' do
94
+ let(:scss) { <<-SCSS }
95
+ p {
96
+ margin: 1rem;
97
+ }
98
+ SCSS
99
+
100
+ it { should_not report_lint }
101
+ end
102
+
103
+ context 'when unit is not allowed locally nor globally' do
104
+ let(:scss) { <<-SCSS }
105
+ p {
106
+ margin: 10px;
107
+ }
108
+ SCSS
109
+
110
+ it { should report_lint line: 2 }
111
+ end
112
+ end
113
+
114
+ context 'when multiple units are set on a property' do
115
+ let(:linter_config) { { 'global' => [], 'properties' => { 'margin' => %w[rem em] } } }
116
+
117
+ context 'when one of multiple units is used' do
118
+ let(:scss) { <<-SCSS }
119
+ p {
120
+ margin: 1rem;
121
+ }
122
+ SCSS
123
+
124
+ it { should_not report_lint }
125
+ end
126
+
127
+ context 'when another of multiple units is used' do
128
+ let(:scss) { <<-SCSS }
129
+ p {
130
+ margin: 1em;
131
+ }
132
+ SCSS
133
+
134
+ it { should_not report_lint }
135
+ end
136
+
137
+ context 'when a not allowed unit is used' do
138
+ let(:scss) { <<-SCSS }
139
+ p {
140
+ margin: 10px;
141
+ }
142
+ SCSS
143
+
144
+ it { should report_lint line: 2 }
145
+ end
146
+ end
147
+
148
+ context 'when no local units are allowed' do
149
+ let(:linter_config) { { 'global' => ['px'], 'properties' => { 'line-height' => [] } } }
150
+
151
+ context 'when a disallowed unit is used' do
152
+ let(:scss) { <<-SCSS }
153
+ p {
154
+ line-height: 10px;
155
+ }
156
+ SCSS
157
+
158
+ it { should report_lint line: 2 }
159
+ end
160
+
161
+ context 'when no unit is used' do
162
+ let(:scss) { <<-SCSS }
163
+ p {
164
+ line-height: 1;
165
+ }
166
+ SCSS
167
+
168
+ it { should_not report_lint }
169
+ end
170
+ end
171
+
172
+ context 'when nested properties are used' do
173
+ let(:linter_config) { { 'global' => ['rem'], 'properties' => { 'font-size' => ['em'] } } }
174
+
175
+ context 'and an allowed unit is used' do
176
+ let(:scss) { <<-SCSS }
177
+ p {
178
+ font: {
179
+ size: 1em;
180
+ }
181
+ }
182
+ SCSS
183
+
184
+ it { should_not report_lint }
185
+ end
186
+
187
+ context 'and a disallowed unit is used' do
188
+ let(:scss) { <<-SCSS }
189
+ p {
190
+ font: {
191
+ size: 16px;
192
+ }
193
+ }
194
+ SCSS
195
+
196
+ it { should report_lint line: 3 }
197
+ end
198
+ end
199
+
200
+ context 'when property contains a function call' do
201
+ let(:scss) { <<-SCSS }
202
+ p {
203
+ color: my-special-color(5);
204
+ }
205
+ SCSS
206
+
207
+ it { should_not report_lint }
208
+ end
209
+
210
+ context 'when property contains a unicode sequence' do
211
+ let(:scss) { <<-SCSS }
212
+ p {
213
+ content: "\\25be";
214
+ }
215
+ SCSS
216
+
217
+ it { should_not report_lint }
218
+ end
219
+
220
+ context 'when property contains a string in quotes that looks like a value' do
221
+ let(:scss) { <<-SCSS }
222
+ p {
223
+ content: "This is 12px";
224
+ }
225
+ SCSS
226
+
227
+ it { should_not report_lint }
228
+ end
229
+ end
@@ -0,0 +1,125 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::QualifyingElement do
4
+ context 'when selector does not include an element' do
5
+ let(:scss) { <<-SCSS }
6
+ .foo {}
7
+ #bar {}
8
+ [foobar] {}
9
+ .foo .bar {}
10
+ #bar > .foo {}
11
+ [foobar] #bar .foo {}
12
+ SCSS
13
+
14
+ it { should_not report_lint }
15
+ end
16
+
17
+ context 'when selector includes an element' do
18
+ context 'and element does not qualify' do
19
+ let(:scss) { <<-SCSS }
20
+ ul {}
21
+ SCSS
22
+
23
+ it { should_not report_lint }
24
+ end
25
+
26
+ context 'and element qualifies class' do
27
+ let(:scss) { <<-SCSS }
28
+ ul.list {}
29
+ SCSS
30
+
31
+ it { should report_lint line: 1 }
32
+ end
33
+
34
+ context 'and element qualifies attribute' do
35
+ let(:scss) { <<-SCSS }
36
+ a[href] {}
37
+ SCSS
38
+
39
+ it { should report_lint line: 1 }
40
+ end
41
+
42
+ context 'and element qualifies id' do
43
+ let(:scss) { <<-SCSS }
44
+ ul#list {}
45
+ SCSS
46
+
47
+ it { should report_lint line: 1 }
48
+ end
49
+
50
+ context 'and selector is in a group' do
51
+ context 'and element does not qualify' do
52
+ let(:scss) { <<-SCSS }
53
+ .list li,
54
+ .item > span {}
55
+ SCSS
56
+
57
+ it { should_not report_lint }
58
+ end
59
+
60
+ context 'and element qualifies class' do
61
+ let(:scss) { <<-SCSS }
62
+ .item span,
63
+ ul > li.item {}
64
+ SCSS
65
+
66
+ it { should report_lint line: 1 }
67
+ end
68
+
69
+ context 'and element qualifies attribute' do
70
+ let(:scss) { <<-SCSS }
71
+ .item + span,
72
+ li a[href] {}
73
+ SCSS
74
+
75
+ it { should report_lint line: 1 }
76
+ end
77
+
78
+ context 'and element qualifies id' do
79
+ let(:scss) { <<-SCSS }
80
+ #foo,
81
+ li#item + li {}
82
+ SCSS
83
+
84
+ it { should report_lint line: 1 }
85
+ end
86
+ end
87
+
88
+ context 'and selector involves a combinator' do
89
+ context 'and element does not qualify' do
90
+ let(:scss) { <<-SCSS }
91
+ .list li {}
92
+ .list > li {}
93
+ .item + li {}
94
+ .item ~ li {}
95
+ SCSS
96
+
97
+ it { should_not report_lint }
98
+ end
99
+
100
+ context 'and element qualifies class' do
101
+ let(:scss) { <<-SCSS }
102
+ ul > li.item {}
103
+ SCSS
104
+
105
+ it { should report_lint line: 1 }
106
+ end
107
+
108
+ context 'and element qualifies attribute' do
109
+ let(:scss) { <<-SCSS }
110
+ li a[href] {}
111
+ SCSS
112
+
113
+ it { should report_lint line: 1 }
114
+ end
115
+
116
+ context 'and element qualifies id' do
117
+ let(:scss) { <<-SCSS }
118
+ li#item + li {}
119
+ SCSS
120
+
121
+ it { should report_lint line: 1 }
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,159 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::SelectorDepth do
4
+ context 'when sequence has a depth of one' do
5
+ let(:scss) { 'p {}' }
6
+
7
+ it { should_not report_lint }
8
+ end
9
+
10
+ context 'when sequence has a depth of three' do
11
+ let(:scss) { 'body article p {}' }
12
+
13
+ it { should_not report_lint }
14
+
15
+ context 'and contains a nested selector' do
16
+ let(:scss) { <<-SCSS }
17
+ body article p {
18
+ i {
19
+ font-style: italic;
20
+ }
21
+ }
22
+ SCSS
23
+
24
+ it { should report_lint line: 2 }
25
+ end
26
+
27
+ context 'and contains multiple nested selectors' do
28
+ let(:scss) { <<-SCSS }
29
+ body article p {
30
+ b {
31
+ font-weight: bold;
32
+ }
33
+ i {
34
+ font-style: italic;
35
+ }
36
+ }
37
+ SCSS
38
+
39
+ it { should report_lint line: 2 }
40
+ it { should report_lint line: 5 }
41
+ end
42
+ end
43
+
44
+ context 'when sequence has a depth of four' do
45
+ let(:scss) { 'body article p i {}' }
46
+
47
+ it { should report_lint line: 1 }
48
+ end
49
+
50
+ context 'when sequence is made up of adjacent sibling combinators' do
51
+ let(:scss) { '.one + .two + .three + .four {}' }
52
+
53
+ it { should_not report_lint }
54
+ end
55
+
56
+ context 'when sequence is made up of general sibling combinators' do
57
+ let(:scss) { '.one .two ~ .three ~ .four {}' }
58
+
59
+ it { should_not report_lint }
60
+ end
61
+
62
+ context 'when sequence contains interpolation' do
63
+ let(:scss) { '.one #{$interpolated-string} .two .three {}' }
64
+
65
+ it { should_not report_lint }
66
+ end
67
+
68
+ context 'when comma sequence contains no sequences exceeding depth limit' do
69
+ let(:scss) { <<-SCSS }
70
+ p,
71
+ .one .two .three,
72
+ ul > li {
73
+ }
74
+ SCSS
75
+
76
+ it { should_not report_lint }
77
+
78
+ context 'and a nested selector causes one of the sequences to exceed the limit' do
79
+ let(:scss) { <<-SCSS }
80
+ p,
81
+ .one .two .three,
82
+ ul > li {
83
+ .four {}
84
+ }
85
+ SCSS
86
+
87
+ it { should report_lint line: 4 }
88
+ end
89
+ end
90
+
91
+ context 'when comma sequence contains a sequence exceeding the depth limit' do
92
+ let(:scss) { <<-SCSS }
93
+ p,
94
+ .one .two .three .four,
95
+ ul > li {
96
+ }
97
+ SCSS
98
+
99
+ it { should report_lint line: 1 }
100
+ end
101
+
102
+ context 'when sequence contains a nested selector with a parent selector' do
103
+ context 'which does not exceed the depth limit' do
104
+ let(:scss) { <<-SCSS }
105
+ .one .two {
106
+ .three & {}
107
+ }
108
+ SCSS
109
+
110
+ it { should_not report_lint }
111
+
112
+ context 'and the parent selector is chained' do
113
+ let(:scss) { <<-SCSS }
114
+ .one .two .three {
115
+ &.chained {}
116
+ }
117
+ SCSS
118
+
119
+ it { should_not report_lint }
120
+ end
121
+ end
122
+
123
+ context 'which does exceed the depth limit' do
124
+ let(:scss) { <<-SCSS }
125
+ .one .two {
126
+ .three & & .four {}
127
+ }
128
+ SCSS
129
+
130
+ it { should report_lint line: 2 }
131
+
132
+ context 'and the parent selector is chained' do
133
+ let(:scss) { <<-SCSS }
134
+ .one .two .three > .four {
135
+ &.chained {}
136
+ }
137
+ SCSS
138
+
139
+ it { should report_lint line: 2 }
140
+ end
141
+ end
142
+ end
143
+
144
+ context 'when sequence contains a @keyframe' do
145
+ let(:scss) { <<-SCSS }
146
+ @keyframe my-keyframe {
147
+ 0% {
148
+ background: #000;
149
+ }
150
+
151
+ 50% {
152
+ background: #fff;
153
+ }
154
+ }
155
+ SCSS
156
+
157
+ it { should_not report_lint }
158
+ end
159
+ end