scss-lint 0.25.1 → 0.26.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +10 -1
  3. data/data/property-sort-orders/concentric.txt +99 -0
  4. data/lib/scss_lint.rb +1 -0
  5. data/lib/scss_lint/cli.rb +9 -3
  6. data/lib/scss_lint/exceptions.rb +4 -0
  7. data/lib/scss_lint/linter.rb +10 -1
  8. data/lib/scss_lint/linter/capitalization_in_selector.rb +14 -6
  9. data/lib/scss_lint/linter/compass/property_with_mixin.rb +9 -2
  10. data/lib/scss_lint/linter/indentation.rb +28 -6
  11. data/lib/scss_lint/linter/property_sort_order.rb +61 -9
  12. data/lib/scss_lint/linter/single_line_per_property.rb +53 -0
  13. data/lib/scss_lint/linter/single_line_per_selector.rb +6 -1
  14. data/lib/scss_lint/linter/space_after_comma.rb +27 -19
  15. data/lib/scss_lint/linter/space_before_brace.rb +5 -4
  16. data/lib/scss_lint/linter/trailing_semicolon.rb +53 -0
  17. data/lib/scss_lint/linter/unnecessary_parent_reference.rb +36 -0
  18. data/lib/scss_lint/reporter/default_reporter.rb +7 -2
  19. data/lib/scss_lint/reporter/xml_reporter.rb +2 -1
  20. data/lib/scss_lint/runner.rb +7 -3
  21. data/lib/scss_lint/version.rb +1 -1
  22. data/spec/scss_lint/cli_spec.rb +314 -0
  23. data/spec/scss_lint/config_spec.rb +439 -0
  24. data/spec/scss_lint/engine_spec.rb +24 -0
  25. data/spec/scss_lint/linter/border_zero_spec.rb +84 -0
  26. data/spec/scss_lint/linter/capitalization_in_selector_spec.rb +71 -0
  27. data/spec/scss_lint/linter/color_keyword_spec.rb +83 -0
  28. data/spec/scss_lint/linter/comment_spec.rb +55 -0
  29. data/spec/scss_lint/linter/compass/property_with_mixin_spec.rb +55 -0
  30. data/spec/scss_lint/linter/debug_statement_spec.rb +21 -0
  31. data/spec/scss_lint/linter/declaration_order_spec.rb +94 -0
  32. data/spec/scss_lint/linter/duplicate_property_spec.rb +176 -0
  33. data/spec/scss_lint/linter/else_placement_spec.rb +106 -0
  34. data/spec/scss_lint/linter/empty_line_between_blocks_spec.rb +263 -0
  35. data/spec/scss_lint/linter/empty_rule_spec.rb +27 -0
  36. data/spec/scss_lint/linter/final_newline_spec.rb +49 -0
  37. data/spec/scss_lint/linter/hex_length_spec.rb +104 -0
  38. data/spec/scss_lint/linter/hex_notation_spec.rb +104 -0
  39. data/spec/scss_lint/linter/hex_validation_spec.rb +36 -0
  40. data/spec/scss_lint/linter/id_with_extraneous_selector_spec.rb +139 -0
  41. data/spec/scss_lint/linter/indentation_spec.rb +242 -0
  42. data/spec/scss_lint/linter/leading_zero_spec.rb +233 -0
  43. data/spec/scss_lint/linter/mergeable_selector_spec.rb +283 -0
  44. data/spec/scss_lint/linter/name_format_spec.rb +206 -0
  45. data/spec/scss_lint/linter/placeholder_in_extend_spec.rb +63 -0
  46. data/spec/scss_lint/linter/property_sort_order_spec.rb +246 -0
  47. data/spec/scss_lint/linter/property_spelling_spec.rb +57 -0
  48. data/spec/scss_lint/linter/selector_depth_spec.rb +159 -0
  49. data/spec/scss_lint/linter/shorthand_spec.rb +172 -0
  50. data/spec/scss_lint/linter/single_line_per_property_spec.rb +73 -0
  51. data/spec/scss_lint/linter/single_line_per_selector_spec.rb +121 -0
  52. data/spec/scss_lint/linter/space_after_comma_spec.rb +315 -0
  53. data/spec/scss_lint/linter/space_after_property_colon_spec.rb +238 -0
  54. data/spec/scss_lint/linter/space_after_property_name_spec.rb +23 -0
  55. data/spec/scss_lint/linter/space_before_brace_spec.rb +447 -0
  56. data/spec/scss_lint/linter/space_between_parens_spec.rb +263 -0
  57. data/spec/scss_lint/linter/string_quotes_spec.rb +303 -0
  58. data/spec/scss_lint/linter/trailing_semicolon_spec.rb +188 -0
  59. data/spec/scss_lint/linter/unnecessary_mantissa_spec.rb +67 -0
  60. data/spec/scss_lint/linter/unnecessary_parent_reference_spec.rb +67 -0
  61. data/spec/scss_lint/linter/url_format_spec.rb +55 -0
  62. data/spec/scss_lint/linter/url_quotes_spec.rb +63 -0
  63. data/spec/scss_lint/linter/zero_unit_spec.rb +113 -0
  64. data/spec/scss_lint/linter_registry_spec.rb +50 -0
  65. data/spec/scss_lint/location_spec.rb +42 -0
  66. data/spec/scss_lint/reporter/config_reporter_spec.rb +42 -0
  67. data/spec/scss_lint/reporter/default_reporter_spec.rb +73 -0
  68. data/spec/scss_lint/reporter/files_reporter_spec.rb +38 -0
  69. data/spec/scss_lint/reporter/xml_reporter_spec.rb +103 -0
  70. data/spec/scss_lint/reporter_spec.rb +11 -0
  71. data/spec/scss_lint/runner_spec.rb +132 -0
  72. data/spec/scss_lint/selector_visitor_spec.rb +264 -0
  73. data/spec/spec_helper.rb +34 -0
  74. data/spec/support/isolated_environment.rb +25 -0
  75. data/spec/support/matchers/report_lint.rb +48 -0
  76. metadata +126 -8
  77. data/lib/scss_lint/linter/trailing_semicolon_after_property_value.rb +0 -40
@@ -0,0 +1,263 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::SpaceBetweenParens do
4
+ context 'when the opening parens is followed by a space' do
5
+ let(:css) { <<-CSS }
6
+ p {
7
+ property: ( value);
8
+ }
9
+ CSS
10
+
11
+ it { should report_lint line: 2 }
12
+ end
13
+
14
+ context 'when the closing parens is preceded by a space' do
15
+ let(:css) { <<-CSS }
16
+ p {
17
+ property: (value );
18
+ }
19
+ CSS
20
+
21
+ it { should report_lint line: 2 }
22
+ end
23
+
24
+ context 'when both parens are space padded' do
25
+ let(:css) { <<-CSS }
26
+ p {
27
+ property: ( value );
28
+ }
29
+ CSS
30
+
31
+ it { should report_lint line: 2, count: 2 }
32
+ end
33
+
34
+ context 'when neither parens are space padded' do
35
+ let(:css) { <<-CSS }
36
+ p {
37
+ property: (value);
38
+ }
39
+ CSS
40
+
41
+ it { should_not report_lint }
42
+ end
43
+
44
+ context 'when parens are multi-line' do
45
+ let(:css) { <<-CSS }
46
+ p {
47
+ property: (
48
+ value
49
+ );
50
+ }
51
+ CSS
52
+
53
+ it { should_not report_lint }
54
+ end
55
+
56
+ context 'when parens are multi-line with tabs' do
57
+ let(:css) { <<-CSS }
58
+ \t\t\tp {
59
+ \t\t\t\tproperty: (
60
+ \t\t\t\t\tvalue
61
+ \t\t\t\t);
62
+ \t\t\t}
63
+ CSS
64
+
65
+ it { should_not report_lint }
66
+ end
67
+
68
+ context 'when outer parens are space padded' do
69
+ let(:css) { <<-CSS }
70
+ p {
71
+ property: fn( fn2(val1, val2) );
72
+ }
73
+ CSS
74
+
75
+ it { should report_lint line: 2, count: 2 }
76
+ end
77
+
78
+ context 'when inner parens are space padded' do
79
+ let(:css) { <<-CSS }
80
+ p {
81
+ property: fn(fn2( val1, val2 ));
82
+ }
83
+ CSS
84
+
85
+ it { should report_lint line: 2, count: 2 }
86
+ end
87
+
88
+ context 'when both parens are not space padded' do
89
+ let(:css) { <<-CSS }
90
+ p {
91
+ property: fn(fn2(val1, val2));
92
+ }
93
+ CSS
94
+
95
+ it { should_not report_lint }
96
+ end
97
+
98
+ context 'when both parens are space padded' do
99
+ let(:css) { <<-CSS }
100
+ p {
101
+ property: fn( fn2( val1, val2 ) );
102
+ }
103
+ CSS
104
+
105
+ it { should report_lint line: 2, count: 4 }
106
+ end
107
+
108
+ context 'when multi level parens are multi-line' do
109
+ let(:css) { <<-CSS }
110
+ p {
111
+ property: fn(
112
+ fn2(
113
+ val1, val2
114
+ )
115
+ );
116
+ }
117
+ CSS
118
+
119
+ it { should_not report_lint }
120
+ end
121
+
122
+ context 'when parens exist in a silent comment' do
123
+ let(:css) { <<-CSS }
124
+ p {
125
+ margin: 0; // Some comment ( with parens )
126
+ }
127
+ CSS
128
+
129
+ it { should_not report_lint }
130
+ end
131
+
132
+ context 'when parens exist in an outputted comment' do
133
+ let(:css) { <<-CSS }
134
+ p {
135
+ margin: 0; /* Some comment ( with parens ) */
136
+ }
137
+ CSS
138
+
139
+ it { should_not report_lint }
140
+ end
141
+
142
+ context 'when the number of spaces has been explicitly set' do
143
+ let(:linter_config) { { 'spaces' => 1 } }
144
+
145
+ context 'when the opening parens is followed by a space' do
146
+ let(:css) { <<-CSS }
147
+ p {
148
+ property: ( value);
149
+ }
150
+ CSS
151
+
152
+ it { should report_lint line: 2 }
153
+ end
154
+
155
+ context 'when the closing parens is preceded by a space' do
156
+ let(:css) { <<-CSS }
157
+ p {
158
+ property: (value );
159
+ }
160
+ CSS
161
+
162
+ it { should report_lint line: 2 }
163
+ end
164
+
165
+ context 'when neither parens are space padded' do
166
+ let(:css) { <<-CSS }
167
+ p {
168
+ property: (value);
169
+ }
170
+ CSS
171
+
172
+ it { should report_lint line: 2, count: 2 }
173
+ end
174
+
175
+ context 'when both parens are space padded' do
176
+ let(:css) { <<-CSS }
177
+ p {
178
+ property: ( value );
179
+ }
180
+ CSS
181
+
182
+ it { should_not report_lint }
183
+ end
184
+
185
+ context 'when parens are multi-line' do
186
+ let(:css) { <<-CSS }
187
+ p {
188
+ property: (
189
+ value
190
+ );
191
+ }
192
+ CSS
193
+
194
+ it { should_not report_lint }
195
+ end
196
+
197
+ context 'when parens are multi-line with tabs' do
198
+ let(:css) { <<-CSS }
199
+ \t\t\t\tp {
200
+ \t\t\t\t\tproperty: (
201
+ \t\t\t\t\t\tvalue
202
+ \t\t\t\t\t);
203
+ \t\t\t\t}
204
+ CSS
205
+
206
+ it { should_not report_lint }
207
+ end
208
+
209
+ context 'when outer parens are space padded' do
210
+ let(:css) { <<-CSS }
211
+ p {
212
+ property: fn( fn2(val1, val2) );
213
+ }
214
+ CSS
215
+
216
+ it { should report_lint line: 2, count: 2 }
217
+ end
218
+
219
+ context 'when inner parens are space padded' do
220
+ let(:css) { <<-CSS }
221
+ p {
222
+ property: fn(fn2( val1, val2 ));
223
+ }
224
+ CSS
225
+
226
+ it { should report_lint line: 2, count: 2 }
227
+ end
228
+
229
+ context 'when both parens are not space padded' do
230
+ let(:css) { <<-CSS }
231
+ p {
232
+ property: fn(fn2(val1, val2));
233
+ }
234
+ CSS
235
+
236
+ it { should report_lint line: 2, count: 4 }
237
+ end
238
+
239
+ context 'when both parens are space padded' do
240
+ let(:css) { <<-CSS }
241
+ p {
242
+ property: fn( fn2( val1, val2 ) );
243
+ }
244
+ CSS
245
+
246
+ it { should_not report_lint }
247
+ end
248
+
249
+ context 'when multi level parens are multi-line' do
250
+ let(:css) { <<-CSS }
251
+ p {
252
+ property: fn(
253
+ fn2(
254
+ val1, val2
255
+ )
256
+ );
257
+ }
258
+ CSS
259
+
260
+ it { should_not report_lint }
261
+ end
262
+ end
263
+ end
@@ -0,0 +1,303 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::StringQuotes do
4
+ context 'when string is written with single quotes' do
5
+ let(:css) { <<-CSS }
6
+ p {
7
+ content: 'hello';
8
+ }
9
+ CSS
10
+
11
+ it { should_not report_lint }
12
+
13
+ context 'and contains escaped single quotes' do
14
+ let(:css) { <<-CSS }
15
+ p {
16
+ content: 'hello \\'world\\'';
17
+ }
18
+ CSS
19
+
20
+ it { should report_lint line: 2 }
21
+ end
22
+
23
+ context 'and contains single quotes escaped as hex' do
24
+ let(:css) { <<-CSS }
25
+ p {
26
+ content: 'hello \\27world\\27';
27
+ }
28
+ CSS
29
+
30
+ it { should_not report_lint }
31
+ end
32
+
33
+ context 'and contains double quotes' do
34
+ let(:css) { <<-CSS }
35
+ p {
36
+ content: 'hello "world"';
37
+ }
38
+ CSS
39
+
40
+ it { should_not report_lint }
41
+ end
42
+
43
+ context 'and contains interpolation' do
44
+ let(:css) { <<-CSS }
45
+ p {
46
+ content: 'hello \#{$world}';
47
+ }
48
+ CSS
49
+
50
+ it { should_not report_lint }
51
+ end
52
+ end
53
+
54
+ context 'when @import uses single quotes' do
55
+ let(:css) { "@import 'file';" }
56
+
57
+ it { should_not report_lint }
58
+
59
+ context 'and has no trailing semicolon' do
60
+ let(:css) { "@import 'file'\n" }
61
+
62
+ it { should_not report_lint }
63
+ end
64
+ end
65
+
66
+ context 'when @charset uses single quotes' do
67
+ let(:css) { "@charset 'UTF-8';" }
68
+
69
+ it { should_not report_lint }
70
+ end
71
+
72
+ context 'when string is written with double quotes' do
73
+ let(:css) { <<-CSS }
74
+ p {
75
+ content: "hello";
76
+ }
77
+ CSS
78
+
79
+ it { should report_lint line: 2 }
80
+
81
+ context 'and contains escaped double quotes' do
82
+ let(:css) { <<-CSS }
83
+ p {
84
+ content: "hello \\"world\\"";
85
+ }
86
+ CSS
87
+
88
+ it { should report_lint line: 2 }
89
+ end
90
+
91
+ context 'and contains double quotes escaped as hex' do
92
+ let(:css) { <<-CSS }
93
+ p {
94
+ content: "hello \\22world\\22";
95
+ }
96
+ CSS
97
+
98
+ it { should report_lint line: 2 }
99
+ end
100
+
101
+ context 'and contains single quotes' do
102
+ let(:css) { <<-CSS }
103
+ p {
104
+ content: "hello 'world'";
105
+ }
106
+ CSS
107
+
108
+ it { should_not report_lint }
109
+ end
110
+
111
+ context 'and contains interpolation' do
112
+ let(:css) { <<-CSS }
113
+ p {
114
+ content: "hello \#{$world}"
115
+ }
116
+ CSS
117
+
118
+ it { should_not report_lint }
119
+ end
120
+ end
121
+
122
+ context 'when @import uses double quotes' do
123
+ let(:css) { '@import "file";' }
124
+
125
+ it { should report_lint }
126
+
127
+ context 'and has no trailing semicolon' do
128
+ let(:css) { '@import "file"' }
129
+
130
+ it { should report_lint }
131
+ end
132
+ end
133
+
134
+ context 'when @charset uses double quotes' do
135
+ let(:css) { '@charset "UTF-8";' }
136
+
137
+ it { should report_lint }
138
+ end
139
+
140
+ context 'when property has a literal identifier' do
141
+ let(:css) { <<-CSS }
142
+ p {
143
+ display: none;
144
+ }
145
+ CSS
146
+
147
+ it { should_not report_lint }
148
+ end
149
+
150
+ context 'when property is a URL with single quotes' do
151
+ let(:css) { <<-CSS }
152
+ p {
153
+ background: url('image.png');
154
+ }
155
+ CSS
156
+
157
+ it { should_not report_lint }
158
+ end
159
+
160
+ context 'when property is a URL with double quotes' do
161
+ let(:css) { <<-CSS }
162
+ p {
163
+ background: url("image.png");
164
+ }
165
+ CSS
166
+
167
+ it { should report_lint line: 2 }
168
+ end
169
+
170
+ context 'when the configuration has been set to prefer double quotes' do
171
+ let(:linter_config) { { 'style' => 'double_quotes' } }
172
+
173
+ context 'and string is written with single quotes' do
174
+ let(:css) { <<-CSS }
175
+ p {
176
+ content: 'hello';
177
+ }
178
+ CSS
179
+
180
+ it { should report_lint line: 2 }
181
+
182
+ context 'and contains escaped single quotes' do
183
+ let(:css) { <<-CSS }
184
+ p {
185
+ content: 'hello \\'world\\'';
186
+ }
187
+ CSS
188
+
189
+ it { should report_lint line: 2 }
190
+ end
191
+
192
+ context 'and contains single quotes escaped as hex' do
193
+ let(:css) { <<-CSS }
194
+ p {
195
+ content: 'hello \\27world\\27';
196
+ }
197
+ CSS
198
+
199
+ it { should report_lint line: 2 }
200
+ end
201
+
202
+ context 'and contains double quotes' do
203
+ let(:css) { <<-CSS }
204
+ p {
205
+ content: 'hello "world"';
206
+ }
207
+ CSS
208
+
209
+ it { should_not report_lint }
210
+ end
211
+
212
+ context 'and contains interpolation' do
213
+ let(:css) { <<-CSS }
214
+ p {
215
+ content: 'hello \#{$world}';
216
+ }
217
+ CSS
218
+
219
+ it { should_not report_lint }
220
+ end
221
+ end
222
+
223
+ context 'and string is written with double quotes' do
224
+ let(:css) { <<-CSS }
225
+ p {
226
+ content: "hello";
227
+ }
228
+ CSS
229
+
230
+ it { should_not report_lint }
231
+
232
+ context 'and contains escaped double quotes' do
233
+ let(:css) { <<-CSS }
234
+ p {
235
+ content: "hello \\"world\\"";
236
+ }
237
+ CSS
238
+
239
+ it { should report_lint line: 2 }
240
+ end
241
+
242
+ context 'and contains double quotes escaped as hex' do
243
+ let(:css) { <<-CSS }
244
+ p {
245
+ content: "hello \\22world\\22";
246
+ }
247
+ CSS
248
+
249
+ it { should_not report_lint }
250
+ end
251
+
252
+ context 'and contains single quotes' do
253
+ let(:css) { <<-CSS }
254
+ p {
255
+ content: "hello 'world'";
256
+ }
257
+ CSS
258
+
259
+ it { should_not report_lint }
260
+ end
261
+
262
+ context 'and contains interpolation' do
263
+ let(:css) { <<-CSS }
264
+ p {
265
+ content: "hello \#{$world}";
266
+ }
267
+ CSS
268
+
269
+ it { should_not report_lint }
270
+ end
271
+ end
272
+
273
+ context 'when property has a literal identifier' do
274
+ let(:css) { <<-CSS }
275
+ p {
276
+ display: none;
277
+ }
278
+ CSS
279
+
280
+ it { should_not report_lint }
281
+ end
282
+
283
+ context 'when property is a URL with single quotes' do
284
+ let(:css) { <<-CSS }
285
+ p {
286
+ background: url('image.png');
287
+ }
288
+ CSS
289
+
290
+ it { should report_lint line: 2 }
291
+ end
292
+
293
+ context 'when property is a URL with double quotes' do
294
+ let(:css) { <<-CSS }
295
+ p {
296
+ background: url("image.png");
297
+ }
298
+ CSS
299
+
300
+ it { should_not report_lint }
301
+ end
302
+ end
303
+ end