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,198 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::Shorthand do
4
+ context 'when a rule' do
5
+ context 'is empty' do
6
+ let(:scss) { <<-SCSS }
7
+ p {
8
+ }
9
+ SCSS
10
+
11
+ it { should_not report_lint }
12
+ end
13
+
14
+ context 'contains properties with valid shorthand values' do
15
+ let(:scss) { <<-SCSS }
16
+ p {
17
+ border-radius: 1px 2px 1px 3px;
18
+ border-width: 1px;
19
+ color: rgba(0, 0, 0, .5);
20
+ margin: 1px 2px;
21
+ padding: 0 0 1px;
22
+ }
23
+ SCSS
24
+
25
+ it { should_not report_lint }
26
+ end
27
+ end
28
+
29
+ context 'when a property' do
30
+ context 'has a value repeated 4 times' do
31
+ let(:scss) { <<-SCSS }
32
+ p {
33
+ padding: 1px 1px 1px 1px;
34
+ }
35
+ SCSS
36
+
37
+ it { should report_lint line: 2 }
38
+ end
39
+
40
+ context 'has a value repeated 3 times' do
41
+ let(:scss) { <<-SCSS }
42
+ p {
43
+ padding: 3px 3px 3px;
44
+ }
45
+ SCSS
46
+
47
+ it { should report_lint line: 2 }
48
+ end
49
+
50
+ context 'has interpolation in its name and starts with a shorthandable property' do
51
+ let(:scss) { <<-SCSS }
52
+ p {
53
+ border-color\#{$type}: 1px 1px;
54
+ }
55
+ SCSS
56
+
57
+ it { should_not report_lint }
58
+ end
59
+
60
+ context 'has exactly two identical values' do
61
+ let(:scss) { <<-SCSS }
62
+ p {
63
+ padding: 10px 10px;
64
+ }
65
+ SCSS
66
+
67
+ it { should report_lint line: 2 }
68
+ end
69
+
70
+ context 'appears to have two identical values, but cannot be shorthanded' do
71
+ let(:scss) { <<-SCSS }
72
+ p:before {
73
+ content: ' ';
74
+ }
75
+ SCSS
76
+
77
+ it { should_not report_lint }
78
+ end
79
+
80
+ context 'has its first two values repeated' do
81
+ let(:scss) { <<-SCSS }
82
+ p {
83
+ padding: 1px 2px 1px 2px;
84
+ }
85
+ SCSS
86
+
87
+ it { should report_lint line: 2 }
88
+ end
89
+
90
+ context 'has its first value repeated in the third position' do
91
+ let(:scss) { <<-SCSS }
92
+ p {
93
+ padding: 1px 2px 1px;
94
+ }
95
+ SCSS
96
+
97
+ it { should report_lint line: 2 }
98
+ end
99
+
100
+ context 'has its second value repeated in the fourth position' do
101
+ let(:scss) { <<-SCSS }
102
+ p {
103
+ padding: 1px 2px 3px 2px;
104
+ }
105
+ SCSS
106
+
107
+ it { should report_lint line: 2 }
108
+ end
109
+
110
+ context 'contains numeric values and function calls' do
111
+ let(:scss) { <<-SCSS }
112
+ p {
113
+ margin: 10px percentage(1 / 100);
114
+ }
115
+ SCSS
116
+
117
+ it { should_not report_lint }
118
+ end
119
+
120
+ context 'contains a list of function calls that can be shortened' do
121
+ let(:scss) { <<-SCSS }
122
+ p {
123
+ margin: percentage(1 / 100) percentage(1 / 100);
124
+ }
125
+ SCSS
126
+
127
+ it { should report_lint line: 2 }
128
+ end
129
+
130
+ context 'contains a list of function calls that cannot be shortened' do
131
+ let(:scss) { <<-SCSS }
132
+ p {
133
+ margin: percentage(1 / 100) percentage(5 / 100);
134
+ }
135
+ SCSS
136
+
137
+ it { should_not report_lint }
138
+ end
139
+
140
+ context 'contains a list of variables that can be shortened' do
141
+ let(:scss) { <<-SCSS }
142
+ p {
143
+ margin: $my-var 1px $my-var;
144
+ }
145
+ SCSS
146
+
147
+ it { should report_lint line: 2 }
148
+ end
149
+
150
+ context 'contains a number with no trailing semicolon' do
151
+ let(:scss) { <<-SCSS }
152
+ p {
153
+ margin: 4px
154
+ }
155
+ SCSS
156
+
157
+ it { should_not report_lint }
158
+ end
159
+
160
+ context 'can be shortened and is followed by !important modifier' do
161
+ let(:scss) { <<-SCSS }
162
+ p {
163
+ padding: 1px 2px 3px 2px !important;
164
+ margin: 0 0 0 0 !important; // A comment
165
+ }
166
+ SCSS
167
+
168
+ it { should report_lint line: 2 }
169
+ it { should report_lint line: 3 }
170
+ end
171
+ end
172
+
173
+ context 'when configured with allowed_shorthands, and a rule' do
174
+ let(:linter_config) { { 'allowed_shorthands' => allowed } }
175
+
176
+ context 'can be shortened to 1, 2, or 3, but 1 is not allowed' do
177
+ let(:allowed) { [2, 3] }
178
+ let(:scss) { <<-SCSS }
179
+ p {
180
+ margin: 4px 4px 4px 4px;
181
+ }
182
+ SCSS
183
+
184
+ it { should report_lint }
185
+ end
186
+
187
+ context 'can be shortened to 1, but 1 is not allowed' do
188
+ let(:allowed) { [2, 3] }
189
+ let(:scss) { <<-SCSS }
190
+ p {
191
+ margin: 4px 4px 4px;
192
+ }
193
+ SCSS
194
+
195
+ it { should_not report_lint }
196
+ end
197
+ end
198
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::SingleLinePerProperty do
4
+ context 'when properties are each on their own line' do
5
+ let(:scss) { <<-SCSS }
6
+ p {
7
+ color: #fff;
8
+ margin: 0;
9
+ padding: 5px;
10
+ }
11
+ SCSS
12
+
13
+ it { should_not report_lint }
14
+ end
15
+
16
+ context 'when two properties share a line' do
17
+ let(:scss) { <<-SCSS }
18
+ p {
19
+ color: #fff;
20
+ margin: 0; padding: 5px;
21
+ }
22
+ SCSS
23
+
24
+ it { should_not report_lint line: 2 }
25
+ it { should report_lint line: 3, count: 1 }
26
+ end
27
+
28
+ context 'when multiple properties share a line' do
29
+ let(:scss) { <<-SCSS }
30
+ p {
31
+ color: #fff; margin: 0; padding: 5px;
32
+ }
33
+ SCSS
34
+
35
+ it { should report_lint line: 2, count: 2 }
36
+ end
37
+
38
+ context 'when multiple properties share a line on a single line rule set' do
39
+ let(:scss) { <<-SCSS }
40
+ p { color: #fff; margin: 0; padding: 5px; }
41
+ SCSS
42
+
43
+ context 'and single line rule sets are allowed' do
44
+ let(:linter_config) { { 'allow_single_line_rule_sets' => true } }
45
+
46
+ it { should_not report_lint }
47
+ end
48
+
49
+ context 'and single line rule sets are not allowed' do
50
+ let(:linter_config) { { 'allow_single_line_rule_sets' => false } }
51
+
52
+ it { should report_lint }
53
+ end
54
+ end
55
+
56
+ context 'when a single line rule set contains a single property' do
57
+ let(:scss) { <<-SCSS }
58
+ p { color: #fff; }
59
+ SCSS
60
+
61
+ context 'and single line rule sets are allowed' do
62
+ let(:linter_config) { { 'allow_single_line_rule_sets' => true } }
63
+
64
+ it { should_not report_lint }
65
+ end
66
+
67
+ context 'and single line rule sets are not allowed' do
68
+ let(:linter_config) { { 'allow_single_line_rule_sets' => false } }
69
+
70
+ it { should report_lint }
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,130 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::SingleLinePerSelector do
4
+ context 'when rule has one selector' do
5
+ let(:scss) { <<-SCSS }
6
+ p {
7
+ }
8
+ SCSS
9
+
10
+ it { should_not report_lint }
11
+ end
12
+
13
+ context 'when rule has one selector on each line' do
14
+ let(:scss) { <<-SCSS }
15
+ p,
16
+ a {
17
+ }
18
+ SCSS
19
+
20
+ it { should_not report_lint }
21
+ end
22
+
23
+ context 'when rule contains multiple selectors on the same line' do
24
+ let(:scss) { <<-SCSS }
25
+ .first,
26
+ .second,
27
+ .third, .fourth,
28
+ .fifth {
29
+ }
30
+ SCSS
31
+
32
+ it { should report_lint line: 3 }
33
+ end
34
+
35
+ context 'when commas are not at the end of the line' do
36
+ let(:scss) { <<-SCSS }
37
+ .foo
38
+ , .bar {
39
+ }
40
+ SCSS
41
+
42
+ it { should report_lint }
43
+ end
44
+
45
+ context 'when commas are on their own line' do
46
+ let(:scss) { <<-SCSS }
47
+ .foo
48
+ ,
49
+ .bar {
50
+ }
51
+ SCSS
52
+
53
+ it { should report_lint }
54
+ end
55
+
56
+ context 'when nested rule contains multiple selectors on the same line' do
57
+ let(:scss) { <<-SCSS }
58
+ #foo {
59
+ .first,
60
+ .second,
61
+ .third, .fourth,
62
+ .fifth {
63
+ }
64
+ }
65
+ SCSS
66
+
67
+ it { should report_lint line: 4 }
68
+ end
69
+
70
+ context 'when rule contains interpolated selectors' do
71
+ let(:scss) { <<-SCSS }
72
+ .first,
73
+ \#{interpolated-selector}.thing,
74
+ .third {
75
+ }
76
+ SCSS
77
+
78
+ it { should_not report_lint }
79
+ end
80
+
81
+ context 'when rule contains an interpolated selector not on its own line' do
82
+ let(:scss) { <<-SCSS }
83
+ .first,
84
+ .second, \#{$interpolated-selector}.thing,
85
+ .fourth {
86
+ }
87
+ SCSS
88
+
89
+ it { should_not report_lint }
90
+ end
91
+
92
+ context 'when rule contains an inline comment' do
93
+ let(:scss) { <<-SCSS }
94
+ .first, /* A comment */
95
+ .second, // Another comment
96
+ .third {
97
+ }
98
+ SCSS
99
+
100
+ it { should_not report_lint }
101
+ end
102
+
103
+ context 'when interpolation contains a comma' do
104
+ let(:scss) { <<-SCSS }
105
+ .my-\#{function(1, 2)}-selector .nested {
106
+ }
107
+ SCSS
108
+
109
+ it { should_not report_lint }
110
+ end
111
+
112
+ context 'when selector contains an interpolated string' do
113
+ let(:scss) { <<-SCSS }
114
+ div,
115
+ \#{$selector},
116
+ p {}
117
+ SCSS
118
+
119
+ it { should_not report_lint }
120
+ end
121
+
122
+ context 'when a function is used in the selector' do
123
+ let(:scss) { <<-SCSS }
124
+ \#{function()} {
125
+ }
126
+ SCSS
127
+
128
+ it { should_not report_lint }
129
+ end
130
+ end
@@ -0,0 +1,332 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::SpaceAfterComma do
4
+ context 'in a mixin declaration' do
5
+ context 'where spaces do not follow commas' do
6
+ let(:scss) { <<-SCSS }
7
+ @mixin mixin($arg1,$arg2,$kwarg1: 'default',$kwarg2: 'default') {
8
+ }
9
+ SCSS
10
+
11
+ it { should report_lint count: 3 }
12
+ end
13
+
14
+ context 'where spaces follow commas' do
15
+ let(:scss) { <<-SCSS }
16
+ @mixin mixin($arg1, $arg2, $kwarg1: 'default', $kwarg2: 'default') {
17
+ }
18
+ SCSS
19
+
20
+ it { should_not report_lint }
21
+ end
22
+
23
+ context 'where spaces surround commas' do
24
+ let(:scss) { <<-SCSS }
25
+ @mixin mixin($arg1 , $arg2 , $kwarg1: 'default' , $kwarg2: 'default') {
26
+ }
27
+ SCSS
28
+
29
+ it { should_not report_lint }
30
+ end
31
+
32
+ context 'where commas are followed by a newline' do
33
+ let(:scss) { <<-SCSS }
34
+ @mixin mixin($arg1,
35
+ $arg2,
36
+ $kwarg1: 'default',
37
+ $kwarg2: 'default') {
38
+ }
39
+ SCSS
40
+
41
+ it { should_not report_lint }
42
+ end
43
+
44
+ context 'definining a variable argument' do
45
+ context 'where spaces do not follow commas' do
46
+ let(:scss) { <<-SCSS }
47
+ @mixin mixin($arg,$args...) {
48
+ }
49
+ SCSS
50
+
51
+ it { should report_lint count: 1 }
52
+ end
53
+
54
+ context 'where spaces follow commas' do
55
+ let(:scss) { <<-SCSS }
56
+ @mixin mixin($arg, $args...) {
57
+ }
58
+ SCSS
59
+
60
+ it { should_not report_lint }
61
+ end
62
+
63
+ context 'where spaces surround commas' do
64
+ let(:scss) { <<-SCSS }
65
+ @mixin mixin($arg , $args...) {
66
+ }
67
+ SCSS
68
+
69
+ it { should_not report_lint }
70
+ end
71
+
72
+ context 'where commas are followed by a newline' do
73
+ let(:scss) { <<-SCSS }
74
+ @mixin mixin($arg,
75
+ $args...) {
76
+ }
77
+ SCSS
78
+
79
+ it { should_not report_lint }
80
+ end
81
+ end
82
+ end
83
+
84
+ context 'in a mixin inclusion' do
85
+ context 'where spaces do not follow commas' do
86
+ let(:scss) { <<-SCSS }
87
+ p {
88
+ @include mixin(1,2,3,$args...,$kwarg1: 4,$kwarg2: 5,$kwargs...);
89
+ }
90
+ SCSS
91
+
92
+ it { should report_lint count: 6 }
93
+ end
94
+
95
+ context 'where spaces follow commas' do
96
+ let(:scss) { <<-SCSS }
97
+ p {
98
+ @include mixin(1, 2, 3, $args..., $kwarg1: 4, $kwarg2: 5, $kwargs...);
99
+ }
100
+ SCSS
101
+
102
+ it { should_not report_lint }
103
+ end
104
+
105
+ context 'where spaces surround commas' do
106
+ let(:scss) { <<-SCSS }
107
+ p {
108
+ @include mixin(1 , 2 , 3 , $args... , $kwarg1: 4 , $kwarg2: 5 , $kwargs...);
109
+ }
110
+ SCSS
111
+
112
+ it { should_not report_lint }
113
+ end
114
+
115
+ context 'where commas are followed by a newline' do
116
+ let(:scss) { <<-SCSS }
117
+ p {
118
+ @include mixin(1,
119
+ 2,
120
+ 3,
121
+ $args...,
122
+ $kwarg1: 4,
123
+ $kwarg2: 5,
124
+ $kwargs...);
125
+ }
126
+ SCSS
127
+
128
+ it { should_not report_lint }
129
+ end
130
+ end
131
+
132
+ context 'in a function declaration' do
133
+ context 'where spaces do not follow commas' do
134
+ let(:scss) { <<-SCSS }
135
+ @function func($arg1,$arg2,$kwarg1: 'default',$kwarg2: 'default') {
136
+ }
137
+ SCSS
138
+
139
+ it { should report_lint count: 3 }
140
+ end
141
+
142
+ context 'where spaces follow commas' do
143
+ let(:scss) { <<-SCSS }
144
+ @function func($arg1, $arg2, $kwarg1: 'default', $kwarg2: 'default') {
145
+ }
146
+ SCSS
147
+
148
+ it { should_not report_lint }
149
+ end
150
+
151
+ context 'where spaces surround commas' do
152
+ let(:scss) { <<-SCSS }
153
+ @function func($arg1 , $arg2 , $kwarg1: 'default' , $kwarg2: 'default') {
154
+ }
155
+ SCSS
156
+
157
+ it { should_not report_lint }
158
+ end
159
+
160
+ context 'where commas are followed by a newline' do
161
+ let(:scss) { <<-SCSS }
162
+ @function func($arg1,
163
+ $arg2,
164
+ $kwarg1: 'default',
165
+ $kwarg2: 'default') {
166
+ }
167
+ SCSS
168
+
169
+ it { should_not report_lint }
170
+ end
171
+
172
+ context 'definining a variable argument' do
173
+ context 'where spaces do not follow commas' do
174
+ let(:scss) { <<-SCSS }
175
+ @function func($arg,$args...) {
176
+ }
177
+ SCSS
178
+
179
+ it { should report_lint count: 1 }
180
+ end
181
+
182
+ context 'where spaces follow commas' do
183
+ let(:scss) { <<-SCSS }
184
+ @function func($arg, $args...) {
185
+ }
186
+ SCSS
187
+
188
+ it { should_not report_lint }
189
+ end
190
+
191
+ context 'where spaces surround commas' do
192
+ let(:scss) { <<-SCSS }
193
+ @function func($arg , $args...) {
194
+ }
195
+ SCSS
196
+
197
+ it { should_not report_lint }
198
+ end
199
+
200
+ context 'where commas are followed by a newline' do
201
+ let(:scss) { <<-SCSS }
202
+ @function func($arg,
203
+ $args...) {
204
+ }
205
+ SCSS
206
+
207
+ it { should_not report_lint }
208
+ end
209
+ end
210
+ end
211
+
212
+ context 'in a function invocation' do
213
+ context 'where spaces do not follow commas' do
214
+ let(:scss) { <<-SCSS }
215
+ p {
216
+ margin: func(1,2,3,$args...,$kwarg1: 4,$kwarg2: 5,$kwargs...);
217
+ }
218
+ SCSS
219
+
220
+ it { should report_lint count: 6 }
221
+ end
222
+
223
+ context 'where spaces follow commas' do
224
+ let(:scss) { <<-SCSS }
225
+ p {
226
+ margin: func(1, 2, 3, $args..., $kwarg1: 4, $kwarg2: 5, $kwargs...);
227
+ }
228
+ SCSS
229
+
230
+ it { should_not report_lint }
231
+ end
232
+
233
+ context 'where spaces surround commas' do
234
+ let(:scss) { <<-SCSS }
235
+ p {
236
+ margin: func(1 , 2 , 3 , $args... , $kwarg1: 4 , $kwarg2: 5 , $kwargs...);
237
+ }
238
+ SCSS
239
+
240
+ it { should_not report_lint }
241
+ end
242
+
243
+ context 'where commas are followed by a newline' do
244
+ let(:scss) { <<-SCSS }
245
+ p {
246
+ margin: func(1,
247
+ 2,
248
+ 3,
249
+ $args...,
250
+ $kwarg1: 4,
251
+ $kwarg2: 5,
252
+ $kwargs...);
253
+ }
254
+ SCSS
255
+
256
+ it { should_not report_lint }
257
+ end
258
+ end
259
+
260
+ context 'in a comma-separated literal list' do
261
+ context 'where spaces do not follow commas' do
262
+ let(:scss) { <<-SCSS }
263
+ p {
264
+ property: $a,$b,$c,$d;
265
+ }
266
+ SCSS
267
+
268
+ it { should report_lint count: 3 }
269
+ end
270
+
271
+ context 'where spaces follow commas' do
272
+ let(:scss) { <<-SCSS }
273
+ p {
274
+ property: $a, $b, $c, $d;
275
+ }
276
+ SCSS
277
+
278
+ it { should_not report_lint }
279
+ end
280
+
281
+ context 'where spaces surround commas' do
282
+ let(:scss) { <<-SCSS }
283
+ p {
284
+ property: $a , $b , $c , $d;
285
+ }
286
+ SCSS
287
+
288
+ it { should_not report_lint }
289
+ end
290
+
291
+ context 'where commas are followed by a newline' do
292
+ let(:scss) { <<-SCSS }
293
+ p {
294
+ property: $a,
295
+ $b,
296
+ $c,
297
+ $d;
298
+ }
299
+ SCSS
300
+
301
+ it { should_not report_lint }
302
+ end
303
+
304
+ context 'when commas are followed by a space and a newline' do
305
+ let(:scss) { <<-SCSS }
306
+ p {
307
+ property: $a,\s
308
+ $b;
309
+ }
310
+ SCSS
311
+
312
+ it { should_not report_lint }
313
+ end
314
+ end
315
+
316
+ context 'when declaring list variables' do
317
+ context 'and one argument does not have a trailing comma' do
318
+ let(:scss) { <<-SCSS }
319
+ $z-list: (
320
+ (
321
+ name1
322
+ ),
323
+ (
324
+ name2,
325
+ )
326
+ );
327
+ SCSS
328
+
329
+ it { should_not report_lint }
330
+ end
331
+ end
332
+ end