scss-lint 0.26.2 → 0.27.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a16f9ac38af8dac62fb417a4a3dd09ed10e56f33
4
- data.tar.gz: 06c53108efb983ee32ca189a0e9838b0a177bf49
3
+ metadata.gz: 09f5144a404feb287b0142ae57abdc1fba664079
4
+ data.tar.gz: 8d199cc76993c5b93a99e0ece1e91e929b052d2f
5
5
  SHA512:
6
- metadata.gz: 87ed567488756c8b381b5a57c0d1ffced33bfe7711689a8a0844ccd34c884bb7655d8756096b278655685f31a6becd033654279837220b01ee282fb0a7a8a80f
7
- data.tar.gz: 59bdaba7321a09c292d8e767cebd8a2813ddb4127f60518be40db3bd3c5c650643e59a3eda6d4c5d2ec7e915fcca9f8cf29c7911373c3211f53b9f8f0ed03ced
6
+ metadata.gz: 85c7e8f492803782ea48d4da4ed4981c1ed516e3dce5dfb2b7baef837986b7b27804b8294f10b4d640fd6898d64394ce8a8f2b30625b988e991b5d23417f22e0
7
+ data.tar.gz: e45e2bf8e0ec689a8b1561afc560ac9c5a960a560e3a8d4f40abe5b0f0a27669ed1eb9af3344a5d36912c2d1d3bc559fb19ebd06e50af3776b3d9828d2e5821d
@@ -13,7 +13,7 @@ module SCSSLint
13
13
 
14
14
  private
15
15
 
16
- HEX_REGEX = /(#(\h{3}|\h{6}))(?!\h)/
16
+ HEX_REGEX = /(#(\h{3}|\h{6}|\h{8}))(?!\h)/
17
17
 
18
18
  def check_hex(hex, node)
19
19
  return if HEX_REGEX.match(hex)
@@ -8,7 +8,7 @@ module SCSSLint
8
8
  yield
9
9
  end
10
10
 
11
- def visit_rule(node)
11
+ def check_sort_order(node)
12
12
  sortable_props = node.children.select do |child|
13
13
  child.is_a?(Sass::Tree::PropNode) && !ignore_property?(child)
14
14
  end
@@ -33,6 +33,14 @@ module SCSSLint
33
33
  yield # Continue linting children
34
34
  end
35
35
 
36
+ alias_method :visit_rule, :check_sort_order
37
+ alias_method :visit_mixin, :check_sort_order
38
+
39
+ def visit_if(node, &block)
40
+ check_sort_order(node, &block)
41
+ visit(node.else) if node.else
42
+ end
43
+
36
44
  private
37
45
 
38
46
  # Compares two properties which can contain a vendor prefix. It allows for a
@@ -109,7 +117,7 @@ module SCSSLint
109
117
  def ignore_property?(prop_node)
110
118
  return true if prop_node.name.any? { |part| !part.is_a?(String) }
111
119
 
112
- config['ignored_unspecified'] &&
120
+ config['ignore_unspecified'] &&
113
121
  @preferred_order &&
114
122
  !@preferred_order.include?(prop_node.name.join)
115
123
  end
@@ -12,6 +12,12 @@ module SCSSLint
12
12
  def visit_sequence(sequence)
13
13
  return unless sequence_starts_with_parent?(sequence.members.first)
14
14
 
15
+ # Allow sequences that contain multiple parent references, e.g.
16
+ # element {
17
+ # & + & { ... }
18
+ # }
19
+ return if sequence.members[1..-1].any? { |ss| sequence_starts_with_parent?(ss) }
20
+
15
21
  # Special case: allow an isolated parent to appear if it is part of a
16
22
  # comma sequence of more than one sequence, as this could be used to DRY
17
23
  # up code.
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module SCSSLint
3
- VERSION = '0.26.2'
3
+ VERSION = '0.27.0'
4
4
  end
@@ -11,11 +11,15 @@ describe SCSSLint::Linter::HexValidation do
11
11
  end
12
12
 
13
13
  context 'when rule contains valid hex codes or color keyword' do
14
+ gradient_css = 'progid:DXImageTransform.Microsoft.gradient' \
15
+ '(startColorstr=#99000000, endColorstr=#99000000)'
16
+
14
17
  let(:css) { <<-CSS }
15
18
  p {
16
19
  background: #000;
17
20
  color: #FFFFFF;
18
21
  border-color: red;
22
+ filter: #{gradient_css};
19
23
  }
20
24
  CSS
21
25
 
@@ -160,6 +160,85 @@ describe SCSSLint::Linter::PropertySortOrder do
160
160
  it { should report_lint line: 3 }
161
161
  end
162
162
 
163
+ context 'when include block contains properties in sorted order' do
164
+ let(:css) { <<-CSS }
165
+ @include some-mixin {
166
+ background: #000;
167
+ display: none;
168
+ margin: 5px;
169
+ padding: 10px;
170
+ }
171
+ CSS
172
+
173
+ it { should_not report_lint }
174
+ end
175
+
176
+ context 'when include block contains properties not in sorted order' do
177
+ let(:css) { <<-CSS }
178
+ @include some-mixin {
179
+ background: #000;
180
+ margin: 5px;
181
+ display: none;
182
+ }
183
+ CSS
184
+
185
+ it { should report_lint line: 3 }
186
+ end
187
+
188
+ context 'when if block contains properties in sorted order' do
189
+ let(:css) { <<-CSS }
190
+ @if $var {
191
+ background: #000;
192
+ display: none;
193
+ margin: 5px;
194
+ padding: 10px;
195
+ }
196
+ CSS
197
+
198
+ it { should_not report_lint }
199
+ end
200
+
201
+ context 'when if block contains properties not in sorted order' do
202
+ let(:css) { <<-CSS }
203
+ @if $var {
204
+ background: #000;
205
+ margin: 5px;
206
+ display: none;
207
+ }
208
+ CSS
209
+
210
+ it { should report_lint line: 3 }
211
+ end
212
+
213
+ context 'when if block contains properties in sorted order' do
214
+ let(:css) { <<-CSS }
215
+ @if $var {
216
+ // Content
217
+ } @else {
218
+ background: #000;
219
+ display: none;
220
+ margin: 5px;
221
+ padding: 10px;
222
+ }
223
+ CSS
224
+
225
+ it { should_not report_lint }
226
+ end
227
+
228
+ context 'when else block contains properties not in sorted order' do
229
+ let(:css) { <<-CSS }
230
+ @if $var {
231
+ // Content
232
+ } @else {
233
+ background: #000;
234
+ margin: 5px;
235
+ display: none;
236
+ }
237
+ CSS
238
+
239
+ it { should report_lint line: 5 }
240
+ end
241
+
163
242
  context 'when the order has been explicitly set' do
164
243
  let(:linter_config) { { 'order' => %w[position display padding margin width] } }
165
244
 
@@ -200,14 +279,14 @@ describe SCSSLint::Linter::PropertySortOrder do
200
279
  }
201
280
  CSS
202
281
 
203
- context 'and the ignored_omitted option is enabled' do
204
- let(:linter_config) { super().merge('ignored_unspecified' => true) }
282
+ context 'and the ignore_unspecified option is enabled' do
283
+ let(:linter_config) { super().merge('ignore_unspecified' => true) }
205
284
 
206
285
  it { should_not report_lint }
207
286
  end
208
287
 
209
- context 'and the ignored_omitted option is disabled' do
210
- let(:linter_config) { super().merge('ignored_unspecified' => false) }
288
+ context 'and the ignore_unspecified option is disabled' do
289
+ let(:linter_config) { super().merge('ignore_unspecified' => false) }
211
290
 
212
291
  it { should report_lint }
213
292
  end
@@ -41,6 +41,17 @@ describe SCSSLint::Linter::UnnecessaryParentReference do
41
41
  it { should_not report_lint }
42
42
  end
43
43
 
44
+ context 'when an ampersand precedes a sibling operator' do
45
+ let(:css) { <<-CSS }
46
+ p {
47
+ & + & {}
48
+ & ~ & {}
49
+ }
50
+ CSS
51
+
52
+ it { should_not report_lint }
53
+ end
54
+
44
55
  context 'when an amperand is used in a comma sequence to DRY up code' do
45
56
  let(:css) { <<-CSS }
46
57
  p {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scss-lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.2
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Causes Engineering
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-29 00:00:00.000000000 Z
12
+ date: 2014-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rainbow