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,283 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::MergeableSelector do
4
+ context 'when single root' do
5
+ let(:scss) { <<-SCSS }
6
+ p {
7
+ }
8
+ SCSS
9
+
10
+ it { should_not report_lint }
11
+ end
12
+
13
+ context 'when different roots' do
14
+ let(:scss) { <<-SCSS }
15
+ p {
16
+ background: #000;
17
+ margin: 5px;
18
+ }
19
+ a {
20
+ background: #000;
21
+ margin: 5px;
22
+ }
23
+ SCSS
24
+
25
+ it { should_not report_lint }
26
+ end
27
+
28
+ context 'when different roots with matching inner rules' do
29
+ let(:scss) { <<-SCSS }
30
+ p {
31
+ background: #000;
32
+ margin: 5px;
33
+ .foo {
34
+ color: red;
35
+ }
36
+ }
37
+ a {
38
+ background: #000;
39
+ margin: 5px;
40
+ .foo {
41
+ color: red;
42
+ }
43
+ }
44
+ SCSS
45
+
46
+ it { should_not report_lint }
47
+ end
48
+
49
+ context 'when multi-selector roots and parital rule match' do
50
+ let(:scss) { <<-SCSS }
51
+ p, a {
52
+ background: #000;
53
+ margin: 5px;
54
+ .foo {
55
+ color: red;
56
+ }
57
+ }
58
+ a {
59
+ background: #000;
60
+ margin: 5px;
61
+ .foo {
62
+ color: red;
63
+ }
64
+ }
65
+ SCSS
66
+
67
+ it { should_not report_lint }
68
+ end
69
+
70
+ context 'when nested and unnested selectors match' do
71
+ let(:scss) { <<-SCSS }
72
+ a.current {
73
+ background: #000;
74
+ margin: 5px;
75
+ .foo {
76
+ color: red;
77
+ }
78
+ }
79
+ a {
80
+ &.current {
81
+ background: #000;
82
+ margin: 5px;
83
+ .foo {
84
+ color: red;
85
+ }
86
+ }
87
+ }
88
+ SCSS
89
+
90
+ context 'when force_nesting is enabled' do
91
+ let(:linter_config) { { 'force_nesting' => true } }
92
+ it { should report_lint }
93
+ end
94
+
95
+ context 'when force_nesting is disabled' do
96
+ let(:linter_config) { { 'force_nesting' => false } }
97
+ it { should_not report_lint }
98
+ end
99
+ end
100
+
101
+ context 'when same class roots' do
102
+ let(:scss) { <<-SCSS }
103
+ .warn {
104
+ font-weight: bold;
105
+ }
106
+ .warn {
107
+ color: #f00;
108
+ @extend .warn;
109
+ a {
110
+ color: #ccc;
111
+ }
112
+ }
113
+ SCSS
114
+
115
+ it { should report_lint }
116
+ end
117
+
118
+ context 'when same compond selector roots' do
119
+ let(:scss) { <<-SCSS }
120
+ .warn .alert {
121
+ font-weight: bold;
122
+ }
123
+ .warn .alert {
124
+ color: #f00;
125
+ @extend .warn;
126
+ a {
127
+ color: #ccc;
128
+ }
129
+ }
130
+ SCSS
131
+
132
+ it { should report_lint }
133
+ end
134
+
135
+ context 'when same class roots separated by another class' do
136
+ let(:scss) { <<-SCSS }
137
+ .warn {
138
+ font-weight: bold;
139
+ }
140
+ .foo {
141
+ color: red;
142
+ }
143
+ .warn {
144
+ color: #f00;
145
+ @extend .warn;
146
+ a {
147
+ color: #ccc;
148
+ }
149
+ }
150
+ SCSS
151
+
152
+ it { should report_lint }
153
+ end
154
+
155
+ context 'when rule in a mixin @include matches a root root' do
156
+ let(:scss) { <<-SCSS }
157
+ p {
158
+ font-weight: bold;
159
+ }
160
+ @include enhance(small-tablet) {
161
+ p {
162
+ font-weight: normal;
163
+ }
164
+ }
165
+ SCSS
166
+
167
+ it { should_not report_lint }
168
+ end
169
+
170
+ context 'when rule in a mixin definition matches a root rule' do
171
+ let(:scss) { <<-SCSS }
172
+ p {
173
+ font-weight: bold;
174
+ }
175
+ @mixin my-mixin {
176
+ p {
177
+ font-weight: normal;
178
+ }
179
+ }
180
+ SCSS
181
+
182
+ it { should_not report_lint }
183
+ end
184
+
185
+ context 'when rule in a media directive matches a root rule' do
186
+ let(:scss) { <<-SCSS }
187
+ p {
188
+ font-weight: bold;
189
+ }
190
+ @media only screen and (min-device-pixel-ratio: 1.5) {
191
+ p {
192
+ font-weight: normal;
193
+ }
194
+ }
195
+ SCSS
196
+
197
+ it { should_not report_lint }
198
+ end
199
+
200
+ context 'when rule in a keyframes directive matches a root rule' do
201
+ let(:scss) { <<-SCSS }
202
+ @keyframes slideouttoleft {
203
+ from {
204
+ transform: translateX(0);
205
+ }
206
+
207
+ to {
208
+ transform: translateX(-100%);
209
+ }
210
+ }
211
+
212
+ @keyframes slideouttoright {
213
+ from {
214
+ transform: translateX(0);
215
+ }
216
+
217
+ to {
218
+ transform: translateX(100%);
219
+ }
220
+ }
221
+ SCSS
222
+
223
+ it { should_not report_lint }
224
+ end
225
+
226
+ context 'when there are duplicate rules nested in a rule set' do
227
+ let(:scss) { <<-SCSS }
228
+ .foo {
229
+ .bar {
230
+ font-weight: bold;
231
+ }
232
+ .baz {
233
+ font-weight: bold;
234
+ }
235
+ .bar {
236
+ color: #ff0;
237
+ }
238
+ }
239
+ SCSS
240
+
241
+ it { should report_lint }
242
+ end
243
+
244
+ context 'when force_nesting is enabled' do
245
+ let(:linter_config) { { 'force_nesting' => true } }
246
+
247
+ context 'when one of the duplicate rules is in a comma sequence' do
248
+ let(:scss) { <<-SCSS }
249
+ .foo,
250
+ .bar {
251
+ color: #000;
252
+ }
253
+ .foo {
254
+ color: #f00;
255
+ }
256
+ SCSS
257
+
258
+ it { should_not report_lint }
259
+ end
260
+
261
+ context 'when rules start with the same prefix but are not the same' do
262
+ let(:scss) { <<-SCSS }
263
+ .foo {
264
+ color: #000;
265
+ }
266
+ .foobar {
267
+ color: #f00;
268
+ }
269
+ SCSS
270
+
271
+ it { should_not report_lint }
272
+ end
273
+
274
+ context 'when a rule contains interpolation' do
275
+ let(:scss) { <<-SCSS }
276
+ .\#{$class-name} {}
277
+ .foobar {}
278
+ SCSS
279
+
280
+ it { should_not report_lint }
281
+ end
282
+ end
283
+ end
@@ -0,0 +1,282 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::NameFormat do
4
+ shared_examples 'hyphenated_lowercase' do
5
+ context 'when no variable, functions, or mixin declarations exist' do
6
+ let(:scss) { <<-SCSS }
7
+ p {
8
+ margin: 0;
9
+ }
10
+ SCSS
11
+
12
+ it { should_not report_lint }
13
+ end
14
+
15
+ context 'when a variable name contains a hyphen' do
16
+ let(:scss) { '$content-padding: 10px;' }
17
+
18
+ it { should_not report_lint }
19
+ end
20
+
21
+ context 'when a variable name contains an underscore' do
22
+ let(:scss) { '$content_padding: 10px;' }
23
+
24
+ it { should report_lint line: 1 }
25
+ end
26
+
27
+ context 'when a variable name contains an uppercase character' do
28
+ let(:scss) { '$contentPadding: 10px;' }
29
+
30
+ it { should report_lint line: 1 }
31
+ end
32
+
33
+ context 'when a function is declared with a capital letter' do
34
+ let(:scss) { <<-SCSS }
35
+ @function badFunction() {
36
+ }
37
+ SCSS
38
+
39
+ it { should report_lint line: 1 }
40
+ end
41
+
42
+ context 'when a function is declared with an underscore' do
43
+ let(:scss) { <<-SCSS }
44
+ @function bad_function() {
45
+ }
46
+ SCSS
47
+
48
+ it { should report_lint line: 1 }
49
+ end
50
+
51
+ context 'when a mixin is declared with a capital letter' do
52
+ let(:scss) { <<-SCSS }
53
+ @mixin badMixin() {
54
+ }
55
+ SCSS
56
+
57
+ it { should report_lint line: 1 }
58
+ end
59
+
60
+ context 'when a mixin is declared with an underscore' do
61
+ let(:scss) { <<-SCSS }
62
+ @mixin bad_mixin() {
63
+ }
64
+ SCSS
65
+
66
+ it { should report_lint line: 1 }
67
+ end
68
+
69
+ context 'when no invalid usages exist' do
70
+ let(:scss) { <<-SCSS }
71
+ p {
72
+ margin: 0;
73
+ }
74
+ SCSS
75
+
76
+ it { should_not report_lint }
77
+ end
78
+
79
+ context 'when a referenced variable name has a capital letter' do
80
+ let(:scss) { <<-SCSS }
81
+ p {
82
+ margin: $badVar;
83
+ }
84
+ SCSS
85
+
86
+ it { should report_lint line: 2 }
87
+ end
88
+
89
+ context 'when a referenced variable name has an underscore' do
90
+ let(:scss) { <<-SCSS }
91
+ p {
92
+ margin: $bad_var;
93
+ }
94
+ SCSS
95
+
96
+ it { should report_lint line: 2 }
97
+ end
98
+
99
+ context 'when a referenced function name has a capital letter' do
100
+ let(:scss) { <<-SCSS }
101
+ p {
102
+ margin: badFunc();
103
+ }
104
+ SCSS
105
+
106
+ it { should report_lint line: 2 }
107
+ end
108
+
109
+ context 'when a referenced function name has an underscore' do
110
+ let(:scss) { <<-SCSS }
111
+ p {
112
+ margin: bad_func();
113
+ }
114
+ SCSS
115
+
116
+ it { should report_lint line: 2 }
117
+ end
118
+
119
+ context 'when an included mixin name has a capital letter' do
120
+ let(:scss) { '@include badMixin();' }
121
+
122
+ it { should report_lint line: 1 }
123
+ end
124
+
125
+ context 'when an included mixin name has an underscore' do
126
+ let(:scss) { '@include bad_mixin();' }
127
+
128
+ it { should report_lint line: 1 }
129
+ end
130
+
131
+ context 'when function is a transform function' do
132
+ %w[rotateX rotateY rotateZ
133
+ scaleX scaleY scaleZ
134
+ skewX skewY
135
+ translateX translateY translateZ].each do |function|
136
+ let(:scss) { <<-SCSS }
137
+ p {
138
+ transform: #{function}(2);
139
+ }
140
+ SCSS
141
+
142
+ it { should_not report_lint }
143
+ end
144
+ end
145
+
146
+ context 'when mixin is a transform function' do
147
+ let(:scss) { <<-SCSS }
148
+ p {
149
+ @include translateX(2);
150
+ }
151
+ SCSS
152
+
153
+ it { should_not report_lint }
154
+ end
155
+
156
+ context 'when a mixin contains keyword arguments with underscores' do
157
+ let(:scss) { '@include mixin($some_var: 4);' }
158
+
159
+ it { should report_lint }
160
+ end
161
+
162
+ context 'when a mixin contains keyword arguments with hyphens' do
163
+ let(:scss) { '@include mixin($some-var: 4);' }
164
+
165
+ it { should_not report_lint }
166
+ end
167
+ end
168
+
169
+ context 'when no configuration is specified' do
170
+ it_behaves_like 'hyphenated_lowercase'
171
+
172
+ context 'when a name contains a leading underscore' do
173
+ let(:scss) { <<-SCSS }
174
+ @function _private-method() {
175
+ }
176
+ SCSS
177
+
178
+ it { should_not report_lint }
179
+ end
180
+ end
181
+
182
+ context 'when leading underscores are not allowed' do
183
+ let(:linter_config) { { 'allow_leading_underscore' => false } }
184
+
185
+ it_behaves_like 'hyphenated_lowercase'
186
+
187
+ context 'when a name contains a leading underscore' do
188
+ let(:scss) { <<-SCSS }
189
+ @function _private-method() {
190
+ }
191
+ SCSS
192
+
193
+ it { should report_lint line: 1 }
194
+ end
195
+ end
196
+
197
+ context 'when the camel_case convention is specified' do
198
+ let(:linter_config) { { 'convention' => 'camel_case' } }
199
+
200
+ context 'when a name contains all lowercase letters' do
201
+ let(:scss) { '$variable: 1;' }
202
+
203
+ it { should_not report_lint }
204
+ end
205
+
206
+ context 'when a name contains all lowercase letters and underscores' do
207
+ let(:scss) { '$my_variable: 1;' }
208
+
209
+ it { should report_lint }
210
+ end
211
+
212
+ context 'when a name contains all lowercase letters and hyphens' do
213
+ let(:scss) { '$my-variable: 1;' }
214
+
215
+ it { should report_lint }
216
+ end
217
+
218
+ context 'when a name is written in camelCase' do
219
+ let(:scss) { '$myVariable: 1;' }
220
+
221
+ it { should_not report_lint }
222
+ end
223
+ end
224
+
225
+ context 'when the snake_case convention is specified' do
226
+ let(:linter_config) { { 'convention' => 'snake_case' } }
227
+
228
+ context 'when a name contains all lowercase letters' do
229
+ let(:scss) { '$variable: 1;' }
230
+
231
+ it { should_not report_lint }
232
+ end
233
+
234
+ context 'when a name contains all lowercase letters and underscores' do
235
+ let(:scss) { '$my_variable: 1;' }
236
+
237
+ it { should_not report_lint }
238
+ end
239
+
240
+ context 'when a name contains all lowercase letters and hyphens' do
241
+ let(:scss) { '$my-variable: 1;' }
242
+
243
+ it { should report_lint }
244
+ end
245
+
246
+ context 'when a name contains any uppercase letters' do
247
+ let(:scss) { '$myVariable: 1;' }
248
+
249
+ it { should report_lint }
250
+ end
251
+ end
252
+
253
+ context 'when type-specific convention is defined with a global convention' do
254
+ let(:linter_config) do
255
+ { 'convention' => 'camel_case', 'variable_convention' => 'snake_case' }
256
+ end
257
+
258
+ context 'when specific type satisfies the type-specific convention' do
259
+ let(:scss) { '$my_variable: 1;' }
260
+
261
+ it { should_not report_lint }
262
+ end
263
+
264
+ context 'when specific type does not satisfy the type-specific convention' do
265
+ let(:scss) { '$myVariable: 1;' }
266
+
267
+ it { should report_lint }
268
+ end
269
+
270
+ context 'when other type satisfies the global convention' do
271
+ let(:scss) { '@function myFunction() {}' }
272
+
273
+ it { should_not report_lint }
274
+ end
275
+
276
+ context 'when other type does not satisfy the global convention' do
277
+ let(:scss) { '@function my_function() {}' }
278
+
279
+ it { should report_lint }
280
+ end
281
+ end
282
+ end