scss-lint 0.33.0 → 0.34.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +19 -1
  3. data/data/properties.txt +4 -0
  4. data/lib/scss_lint.rb +1 -0
  5. data/lib/scss_lint/cli.rb +4 -42
  6. data/lib/scss_lint/config.rb +1 -45
  7. data/lib/scss_lint/control_comment_processor.rb +47 -15
  8. data/lib/scss_lint/file_finder.rb +57 -0
  9. data/lib/scss_lint/linter/bang_format.rb +1 -1
  10. data/lib/scss_lint/linter/border_zero.rb +25 -9
  11. data/lib/scss_lint/linter/color_keyword.rb +3 -13
  12. data/lib/scss_lint/linter/color_variable.rb +36 -0
  13. data/lib/scss_lint/linter/declaration_order.rb +2 -2
  14. data/lib/scss_lint/linter/important_rule.rb +12 -0
  15. data/lib/scss_lint/linter/indentation.rb +7 -1
  16. data/lib/scss_lint/linter/property_count.rb +44 -0
  17. data/lib/scss_lint/linter/property_sort_order.rb +73 -19
  18. data/lib/scss_lint/linter/string_quotes.rb +9 -0
  19. data/lib/scss_lint/linter/variable_for_property.rb +20 -0
  20. data/lib/scss_lint/linter/vendor_prefixes.rb +3 -3
  21. data/lib/scss_lint/runner.rb +5 -7
  22. data/lib/scss_lint/utils.rb +34 -0
  23. data/lib/scss_lint/version.rb +1 -1
  24. data/spec/scss_lint/cli_spec.rb +1 -1
  25. data/spec/scss_lint/config_spec.rb +4 -203
  26. data/spec/scss_lint/engine_spec.rb +4 -4
  27. data/spec/scss_lint/file_finder_spec.rb +110 -0
  28. data/spec/scss_lint/linter/bang_format_spec.rb +28 -18
  29. data/spec/scss_lint/linter/border_zero_spec.rb +50 -16
  30. data/spec/scss_lint/linter/color_keyword_spec.rb +16 -16
  31. data/spec/scss_lint/linter/color_variable_spec.rb +102 -0
  32. data/spec/scss_lint/linter/comment_spec.rb +9 -9
  33. data/spec/scss_lint/linter/compass/property_with_mixin_spec.rb +10 -10
  34. data/spec/scss_lint/linter/debug_statement_spec.rb +4 -4
  35. data/spec/scss_lint/linter/declaration_order_spec.rb +80 -80
  36. data/spec/scss_lint/linter/duplicate_property_spec.rb +30 -30
  37. data/spec/scss_lint/linter/else_placement_spec.rb +16 -16
  38. data/spec/scss_lint/linter/empty_line_between_blocks_spec.rb +38 -38
  39. data/spec/scss_lint/linter/empty_rule_spec.rb +4 -4
  40. data/spec/scss_lint/linter/final_newline_spec.rb +6 -6
  41. data/spec/scss_lint/linter/hex_length_spec.rb +16 -16
  42. data/spec/scss_lint/linter/hex_notation_spec.rb +16 -16
  43. data/spec/scss_lint/linter/hex_validation_spec.rb +6 -6
  44. data/spec/scss_lint/linter/id_selector_spec.rb +10 -10
  45. data/spec/scss_lint/linter/import_path_spec.rb +45 -45
  46. data/spec/scss_lint/linter/important_rule_spec.rb +43 -0
  47. data/spec/scss_lint/linter/indentation_spec.rb +103 -43
  48. data/spec/scss_lint/linter/leading_zero_spec.rb +45 -45
  49. data/spec/scss_lint/linter/mergeable_selector_spec.rb +32 -32
  50. data/spec/scss_lint/linter/name_format_spec.rb +75 -41
  51. data/spec/scss_lint/linter/nesting_depth_spec.rb +14 -14
  52. data/spec/scss_lint/linter/placeholder_in_extend_spec.rb +12 -12
  53. data/spec/scss_lint/linter/property_count_spec.rb +104 -0
  54. data/spec/scss_lint/linter/property_sort_order_spec.rb +138 -48
  55. data/spec/scss_lint/linter/property_spelling_spec.rb +14 -14
  56. data/spec/scss_lint/linter/qualifying_element_spec.rb +26 -26
  57. data/spec/scss_lint/linter/selector_depth_spec.rb +26 -26
  58. data/spec/scss_lint/linter/selector_format_spec.rb +114 -114
  59. data/spec/scss_lint/linter/shorthand_spec.rb +32 -32
  60. data/spec/scss_lint/linter/single_line_per_property_spec.rb +10 -10
  61. data/spec/scss_lint/linter/single_line_per_selector_spec.rb +24 -24
  62. data/spec/scss_lint/linter/space_after_comma_spec.rb +60 -60
  63. data/spec/scss_lint/linter/space_after_property_colon_spec.rb +44 -44
  64. data/spec/scss_lint/linter/space_after_property_name_spec.rb +6 -6
  65. data/spec/scss_lint/linter/space_before_brace_spec.rb +119 -119
  66. data/spec/scss_lint/linter/space_between_parens_spec.rb +48 -48
  67. data/spec/scss_lint/linter/string_quotes_spec.rb +74 -62
  68. data/spec/scss_lint/linter/trailing_semicolon_spec.rb +53 -54
  69. data/spec/scss_lint/linter/trailing_zero_spec.rb +34 -34
  70. data/spec/scss_lint/linter/unnecessary_mantissa_spec.rb +10 -10
  71. data/spec/scss_lint/linter/unnecessary_parent_reference_spec.rb +18 -18
  72. data/spec/scss_lint/linter/url_format_spec.rb +4 -4
  73. data/spec/scss_lint/linter/url_quotes_spec.rb +14 -14
  74. data/spec/scss_lint/linter/variable_for_property_spec.rb +115 -0
  75. data/spec/scss_lint/linter/vendor_prefixes_spec.rb +66 -56
  76. data/spec/scss_lint/linter/zero_unit_spec.rb +22 -22
  77. data/spec/scss_lint/linter_spec.rb +72 -28
  78. data/spec/scss_lint/runner_spec.rb +0 -1
  79. data/spec/scss_lint/selector_visitor_spec.rb +23 -23
  80. data/spec/spec_helper.rb +2 -2
  81. metadata +27 -12
@@ -4,88 +4,88 @@ require 'spec_helper'
4
4
 
5
5
  describe SCSSLint::Linter::TrailingSemicolon do
6
6
  context 'when a property does not end with a semicolon' do
7
- let(:css) { <<-CSS }
7
+ let(:scss) { <<-SCSS }
8
8
  p {
9
9
  margin: 0
10
10
  }
11
- CSS
11
+ SCSS
12
12
 
13
13
  it { should report_lint line: 2 }
14
14
  end
15
15
 
16
16
  context 'when a property ends with a semicolon' do
17
- let(:css) { <<-CSS }
17
+ let(:scss) { <<-SCSS }
18
18
  p {
19
19
  margin: 0;
20
20
  }
21
- CSS
21
+ SCSS
22
22
 
23
23
  it { should_not report_lint }
24
24
  end
25
25
 
26
26
  context 'when a property ends with a space followed by a semicolon' do
27
- let(:css) { <<-CSS }
27
+ let(:scss) { <<-SCSS }
28
28
  p {
29
29
  margin: 0 ;
30
30
  }
31
- CSS
31
+ SCSS
32
32
 
33
33
  it { should report_lint line: 2 }
34
34
  end
35
35
 
36
36
  context 'when a property ends with a semicolon and is followed by a comment' do
37
- let(:css) { <<-CSS }
37
+ let(:scss) { <<-SCSS }
38
38
  p {
39
39
  margin: 0; // This is a comment
40
40
  padding: 0; /* This is another comment */
41
41
  }
42
- CSS
42
+ SCSS
43
43
 
44
44
  it { should_not report_lint }
45
45
  end
46
46
 
47
47
  context 'when a property contains nested properties' do
48
48
  context 'and there is a value on the namespace' do
49
- let(:css) { <<-CSS }
49
+ let(:scss) { <<-SCSS }
50
50
  p {
51
51
  font: 2px/3px {
52
52
  style: italic;
53
53
  weight: bold;
54
54
  }
55
55
  }
56
- CSS
56
+ SCSS
57
57
 
58
58
  it { should_not report_lint }
59
59
  end
60
60
 
61
61
  context 'and there is no value on the namespace' do
62
- let(:css) { <<-CSS }
62
+ let(:scss) { <<-SCSS }
63
63
  p {
64
64
  font: {
65
65
  style: italic;
66
66
  weight: bold;
67
67
  }
68
68
  }
69
- CSS
69
+ SCSS
70
70
 
71
71
  it { should_not report_lint }
72
72
  end
73
73
  end
74
74
 
75
75
  context 'when a nested property does not end with a semicolon' do
76
- let(:css) { <<-CSS }
76
+ let(:scss) { <<-SCSS }
77
77
  p {
78
78
  font: {
79
79
  weight: bold
80
80
  }
81
81
  }
82
- CSS
82
+ SCSS
83
83
 
84
84
  it { should report_lint line: 3 }
85
85
  end
86
86
 
87
87
  context 'when a multi-line property ends with a semicolon' do
88
- let(:css) { <<-CSS }
88
+ let(:scss) { <<-SCSS }
89
89
  p {
90
90
  background:
91
91
  top repeat-x url('top-image.jpg'),
@@ -93,13 +93,13 @@ describe SCSSLint::Linter::TrailingSemicolon do
93
93
  bottom repeat-x url('bottom-image.jpg'),
94
94
  left repeat-y url('left-image.jpg');
95
95
  }
96
- CSS
96
+ SCSS
97
97
 
98
98
  it { should_not report_lint }
99
99
  end
100
100
 
101
101
  context 'when a multi-line property does not end with a semicolon' do
102
- let(:css) { <<-CSS }
102
+ let(:scss) { <<-SCSS }
103
103
  p {
104
104
  background:
105
105
  top repeat-x url('top-image.jpg'),
@@ -107,71 +107,71 @@ describe SCSSLint::Linter::TrailingSemicolon do
107
107
  bottom repeat-x url('bottom-image.jpg'),
108
108
  left repeat-y url('left-image.jpg')
109
109
  }
110
- CSS
110
+ SCSS
111
111
 
112
112
  it { should report_lint line: 2 }
113
113
  end
114
114
 
115
115
  context 'when a oneline rule does not end with a semicolon' do
116
- let(:css) { <<-CSS }
116
+ let(:scss) { <<-SCSS }
117
117
  .foo { border: 0 }
118
- CSS
118
+ SCSS
119
119
 
120
120
  it { should report_lint line: 1 }
121
121
  end
122
122
 
123
123
  context 'when a oneline rule has a space before a semicolon' do
124
- let(:css) { <<-CSS }
124
+ let(:scss) { <<-SCSS }
125
125
  .foo { border: 0 ; }
126
- CSS
126
+ SCSS
127
127
 
128
128
  it { should report_lint line: 1 }
129
129
  end
130
130
 
131
131
  context 'when @extend does not end with a semicolon' do
132
- let(:css) { <<-CSS }
132
+ let(:scss) { <<-SCSS }
133
133
  .foo {
134
134
  @extend %bar
135
135
  }
136
- CSS
136
+ SCSS
137
137
 
138
138
  it { should report_lint line: 2 }
139
139
  end
140
140
 
141
141
  context 'when @extend ends with a semicolon' do
142
- let(:css) { <<-CSS }
142
+ let(:scss) { <<-SCSS }
143
143
  .foo {
144
144
  @extend %bar;
145
145
  }
146
- CSS
146
+ SCSS
147
147
 
148
148
  it { should_not report_lint }
149
149
  end
150
150
 
151
151
  context 'when @include does not end with a semicolon' do
152
- let(:css) { <<-CSS }
152
+ let(:scss) { <<-SCSS }
153
153
  .foo {
154
154
  @include bar
155
155
  }
156
- CSS
156
+ SCSS
157
157
 
158
158
  it { should report_lint line: 2 }
159
159
  end
160
160
 
161
161
  context 'when @include takes a block' do
162
- let(:css) { <<-CSS }
162
+ let(:scss) { <<-SCSS }
163
163
  .foo {
164
164
  @include bar {
165
165
  border: 0;
166
166
  }
167
167
  }
168
- CSS
168
+ SCSS
169
169
 
170
170
  it { should_not report_lint }
171
171
  end
172
172
 
173
173
  context 'when @include takes a block with nested props' do
174
- let(:css) { <<-CSS }
174
+ let(:scss) { <<-SCSS }
175
175
  .foo {
176
176
  @include bar {
177
177
  .bar {
@@ -179,13 +179,13 @@ describe SCSSLint::Linter::TrailingSemicolon do
179
179
  }
180
180
  }
181
181
  }
182
- CSS
182
+ SCSS
183
183
 
184
184
  it { should_not report_lint }
185
185
  end
186
186
 
187
187
  context 'when @include takes a block with an if-node' do
188
- let(:css) { <<-CSS }
188
+ let(:scss) { <<-SCSS }
189
189
  .foo {
190
190
  @include bar {
191
191
  @if $var {
@@ -193,112 +193,111 @@ describe SCSSLint::Linter::TrailingSemicolon do
193
193
  }
194
194
  }
195
195
  }
196
- CSS
196
+ SCSS
197
197
 
198
198
  it { should_not report_lint }
199
199
  end
200
200
 
201
201
  context 'when @include ends with a semicolon' do
202
- let(:css) { <<-CSS }
202
+ let(:scss) { <<-SCSS }
203
203
  .foo {
204
204
  @include bar;
205
205
  }
206
- CSS
206
+ SCSS
207
207
 
208
208
  it { should_not report_lint }
209
209
  end
210
210
 
211
211
  context 'when @import ends with a semicolon' do
212
- let(:css) { '@import "something";' }
212
+ let(:scss) { '@import "something";' }
213
213
 
214
214
  it { should_not report_lint }
215
215
  end
216
216
 
217
217
  context 'when @import does not end with a semicolon' do
218
- let(:css) { '@import "something"' }
218
+ let(:scss) { '@import "something"' }
219
219
 
220
220
  it { should report_lint line: 1 }
221
221
  end
222
222
 
223
223
  context 'when @import has a space before a semicolon' do
224
- let(:css) { '@import "something" ;' }
224
+ let(:scss) { '@import "something" ;' }
225
225
 
226
226
  it { should report_lint line: 1 }
227
227
  end
228
228
 
229
229
  context 'when an import directive is split over multiple lines' do
230
230
  context 'and is missing the trailing semicolon' do
231
- let(:css) { <<-CSS }
231
+ let(:scss) { <<-SCSS }
232
232
  @import 'functions/strip-units',
233
233
  'functions/pc'
234
- CSS
234
+ SCSS
235
235
 
236
236
  it { should report_lint }
237
237
  end
238
238
 
239
239
  context 'and is not missing the trailing semicolon' do
240
- let(:css) { <<-CSS }
240
+ let(:scss) { <<-SCSS }
241
241
  @import 'functions/strip-units',
242
242
  'functions/pc';
243
- CSS
243
+ SCSS
244
244
 
245
245
  it { should_not report_lint }
246
246
  end
247
247
  end
248
248
 
249
249
  context 'when variable declaration does not end with a semicolon' do
250
- let(:css) { <<-CSS }
250
+ let(:scss) { <<-SCSS }
251
251
  .foo {
252
252
  $bar: 1
253
253
  }
254
- CSS
254
+ SCSS
255
255
 
256
256
  it { should report_lint line: 2 }
257
257
  end
258
258
 
259
259
  context 'when variable declaration ends with a semicolon' do
260
- let(:css) { <<-CSS }
260
+ let(:scss) { <<-SCSS }
261
261
  .foo {
262
262
  $bar: 1;
263
263
  }
264
- CSS
264
+ SCSS
265
265
 
266
266
  it { should_not report_lint }
267
267
  end
268
268
 
269
269
  context 'when variable declaration ends with multiple semicolons' do
270
- let(:css) { <<-CSS }
270
+ let(:scss) { <<-SCSS }
271
271
  .foo {
272
272
  $bar: 1;;
273
273
  }
274
- CSS
274
+ SCSS
275
275
 
276
276
  it { should report_lint line: 2 }
277
277
  end
278
278
 
279
279
  context 'when interpolation within single quotes is followed by property' do
280
280
  context 'and property has a trailing semicolon' do
281
- let(:css) { "[class~='\#{$test}'] { width: 100%; }" }
281
+ let(:scss) { "[class~='\#{$test}'] { width: 100%; }" }
282
282
 
283
283
  it { should_not report_lint }
284
284
  end
285
285
 
286
286
  context 'and property does not have a trailing semicolon' do
287
- let(:css) { "[class~='\#{$test}'] { width : 100% }" }
287
+ let(:scss) { "[class~='\#{$test}'] { width : 100% }" }
288
288
 
289
289
  it { should report_lint }
290
290
  end
291
291
  end
292
292
 
293
293
  context 'when triggering a bug based on Windows IBM437 encoding' do
294
- CSS = <<-CSS
294
+ let(:scss) { <<-SCSS.force_encoding('IBM437') }
295
295
  @charset "UTF-8";
296
296
 
297
297
  .foo:before {
298
298
  content: '▼';
299
299
  }
300
- CSS
301
- let(:css) { CSS.force_encoding('IBM437') }
300
+ SCSS
302
301
 
303
302
  it { should_not report_lint }
304
303
  end
@@ -2,174 +2,174 @@ require 'spec_helper'
2
2
 
3
3
  describe SCSSLint::Linter::TrailingZero do
4
4
  context 'when no values exist' do
5
- let(:css) { 'p {}' }
5
+ let(:scss) { 'p {}' }
6
6
 
7
7
  it { should_not report_lint }
8
8
  end
9
9
 
10
10
  context 'when a zero exists' do
11
- let(:css) { <<-CSS }
11
+ let(:scss) { <<-SCSS }
12
12
  p {
13
13
  margin: 0;
14
14
  }
15
- CSS
15
+ SCSS
16
16
 
17
17
  it { should_not report_lint }
18
18
  end
19
19
 
20
20
  context 'when an integer value exists' do
21
- let(:css) { <<-CSS }
21
+ let(:scss) { <<-SCSS }
22
22
  p {
23
23
  line-height: 2;
24
24
  }
25
- CSS
25
+ SCSS
26
26
 
27
27
  it { should_not report_lint }
28
28
  end
29
29
 
30
30
  context 'when an integer value with units exists' do
31
- let(:css) { <<-CSS }
31
+ let(:scss) { <<-SCSS }
32
32
  p {
33
33
  margin: 5px;
34
34
  }
35
- CSS
35
+ SCSS
36
36
 
37
37
  it { should_not report_lint }
38
38
  end
39
39
 
40
40
  context 'when a unitless fractional value with no trailing zero exists' do
41
- let(:css) { <<-CSS }
41
+ let(:scss) { <<-SCSS }
42
42
  p {
43
43
  line-height: .5;
44
44
  }
45
- CSS
45
+ SCSS
46
46
 
47
47
  it { should_not report_lint }
48
48
  end
49
49
 
50
50
  context 'when a negative unitless fractional value with no trailing zero exists' do
51
- let(:css) { <<-CSS }
51
+ let(:scss) { <<-SCSS }
52
52
  p {
53
53
  line-height: -.5;
54
54
  }
55
- CSS
55
+ SCSS
56
56
 
57
57
  it { should_not report_lint }
58
58
  end
59
59
 
60
60
  context 'when a fractional value with units and no trailing zero exists' do
61
- let(:css) { <<-CSS }
61
+ let(:scss) { <<-SCSS }
62
62
  p {
63
63
  margin: .5em;
64
64
  }
65
- CSS
65
+ SCSS
66
66
 
67
67
  it { should_not report_lint }
68
68
  end
69
69
 
70
70
  context 'when a negative fractional value with units and no trailing zero exists' do
71
- let(:css) { <<-CSS }
71
+ let(:scss) { <<-SCSS }
72
72
  p {
73
73
  margin: -.5em;
74
74
  }
75
- CSS
75
+ SCSS
76
76
 
77
77
  it { should_not report_lint }
78
78
  end
79
79
 
80
80
  context 'when a fractional value with a trailing zero exists' do
81
- let(:css) { <<-CSS }
81
+ let(:scss) { <<-SCSS }
82
82
  p {
83
83
  line-height: .50;
84
84
  }
85
- CSS
85
+ SCSS
86
86
 
87
87
  it { should report_lint line: 2 }
88
88
  end
89
89
 
90
90
  context 'when a fractional value with units and a trailing zero exists' do
91
- let(:css) { <<-CSS }
91
+ let(:scss) { <<-SCSS }
92
92
  p {
93
93
  margin: .50em;
94
94
  }
95
- CSS
95
+ SCSS
96
96
 
97
97
  it { should report_lint line: 2 }
98
98
  end
99
99
 
100
100
  context 'when a negative fractional value with units and a trailing zero exists' do
101
- let(:css) { <<-CSS }
101
+ let(:scss) { <<-SCSS }
102
102
  p {
103
103
  margin: -.50em;
104
104
  }
105
- CSS
105
+ SCSS
106
106
 
107
107
  it { should report_lint line: 2 }
108
108
  end
109
109
 
110
110
  context 'when a fractional value with a mantissa ending in zero exists' do
111
- let(:css) { <<-CSS }
111
+ let(:scss) { <<-SCSS }
112
112
  p {
113
113
  line-height: 10.5;
114
114
  }
115
- CSS
115
+ SCSS
116
116
 
117
117
  it { should_not report_lint }
118
118
  end
119
119
 
120
120
  context 'when multiple fractional values with trailing zeros exist' do
121
- let(:css) { <<-CSS }
121
+ let(:scss) { <<-SCSS }
122
122
  p {
123
123
  margin: 0.50em .50 0.10px .90pt;
124
124
  }
125
- CSS
125
+ SCSS
126
126
 
127
127
  it { should report_lint count: 4, line: 2 }
128
128
  end
129
129
 
130
130
  context 'when trailing zeros appear in function arguments' do
131
- let(:css) { <<-CSS }
131
+ let(:scss) { <<-SCSS }
132
132
  p {
133
133
  margin: some-function(.50em, 0.40 0.30 .2);
134
134
  }
135
- CSS
135
+ SCSS
136
136
 
137
137
  it { should report_lint count: 3, line: 2 }
138
138
  end
139
139
 
140
140
  context 'when trailing zeros appear in mixin arguments' do
141
- let(:css) { <<-CSS }
141
+ let(:scss) { <<-SCSS }
142
142
  p {
143
143
  @include some-mixin(0.50em, 0.40 0.30 .2);
144
144
  }
145
- CSS
145
+ SCSS
146
146
 
147
147
  it { should report_lint count: 3, line: 2 }
148
148
  end
149
149
 
150
150
  context 'when trailiing zeros appear in variable declarations' do
151
- let(:css) { '$some-var: .50em;' }
151
+ let(:scss) { '$some-var: .50em;' }
152
152
 
153
153
  it { should report_lint line: 1 }
154
154
  end
155
155
 
156
156
  context 'when trailing zeros appear in named arguments' do
157
- let(:css) { <<-CSS }
157
+ let(:scss) { <<-SCSS }
158
158
  p {
159
159
  @include line-clamp($line-height: .90, $line-count: 2);
160
160
  }
161
- CSS
161
+ SCSS
162
162
 
163
163
  it { should report_lint line: 2 }
164
164
  end
165
165
 
166
166
  context 'when trailing zeros appear in parameter defaults' do
167
- let(:css) { <<-CSS }
167
+ let(:scss) { <<-SCSS }
168
168
  @mixin my-mixin($bad-value: .50, $good-value: .9, $string-value: ".90") {
169
169
  margin: $some-value;
170
170
  padding: $some-other-value;
171
171
  }
172
- CSS
172
+ SCSS
173
173
 
174
174
  it { should report_lint count: 1, line: 1 }
175
175
  end