scss-lint 0.27.0 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scss_lint/linter/capitalization_in_selector.rb +1 -1
- data/lib/scss_lint/linter/single_line_per_selector.rb +15 -27
- data/lib/scss_lint/linter/string_quotes.rb +11 -0
- data/lib/scss_lint/linter/unnecessary_parent_reference.rb +1 -1
- data/lib/scss_lint/version.rb +1 -1
- data/spec/scss_lint/linter/single_line_per_selector_spec.rb +2 -2
- data/spec/scss_lint/linter/string_quotes_spec.rb +20 -0
- data/spec/scss_lint/selector_visitor_spec.rb +6 -6
- metadata +7 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42f28b5047a9fc0063a953cfe84bf4d7e61939ae
|
4
|
+
data.tar.gz: dbf4ea16dadcdff7fde653b7433478085bf80260
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0354b7af1ee236a8add0483e6adc97751e687b1f19850cc248cc94a9200fa28c5a1f84244b35b01a812a7f48a6c25056fdb07508d9e3d9b55ba928b7daa2a998
|
7
|
+
data.tar.gz: 321fbeeee64c9d02cd4dddd2176ac1b546f71a4f4b66bb861d089de1490316ffe0ce804395ff02727b78a8c4908fc1cf2c7c30ca198147ec5f3f828af3406efa
|
@@ -3,37 +3,25 @@ module SCSSLint
|
|
3
3
|
class Linter::SingleLinePerSelector < Linter
|
4
4
|
include LinterRegistry
|
5
5
|
|
6
|
-
def visit_rule(node)
|
7
|
-
add_lint(node, MESSAGE) if invalid_comma_placement?(node)
|
8
|
-
yield # Continue linting children
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
6
|
MESSAGE = 'Each selector in a comma sequence should be on its own line'
|
14
7
|
|
15
|
-
|
16
|
-
|
17
|
-
# We must ignore selectors with interpolation, since there's no way to
|
18
|
-
# tell if the overall selector is valid since the interpolation could
|
19
|
-
# insert commas incorrectly. Thus we simply ignore.
|
20
|
-
return unless node.rule.all? { |item| item.is_a?(String) }
|
8
|
+
def visit_comma_sequence(node)
|
9
|
+
return unless node.members.count > 1
|
21
10
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
# Sass::Script::Nodes, we need to condense it into a single string that we
|
27
|
-
# can run a regex against.
|
28
|
-
def condense_to_string(sequence_list)
|
29
|
-
sequence_list.select { |item| item.is_a?(String) }.inject(:+)
|
30
|
-
end
|
11
|
+
if node.members[0].members[1] == "\n"
|
12
|
+
# Comma is on its own line
|
13
|
+
add_lint(node, MESSAGE)
|
14
|
+
end
|
31
15
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
16
|
+
node.members[1..-1].each_with_index do |sequence, index|
|
17
|
+
if sequence.members[0] != "\n"
|
18
|
+
# Next sequence doesn't reside on its own line
|
19
|
+
add_lint(node.line + index, MESSAGE)
|
20
|
+
elsif sequence.members[1] == "\n"
|
21
|
+
# Comma is on its own line
|
22
|
+
add_lint(node.line + index, MESSAGE)
|
23
|
+
end
|
24
|
+
end
|
37
25
|
end
|
38
26
|
end
|
39
27
|
end
|
@@ -3,6 +3,17 @@ module SCSSLint
|
|
3
3
|
class Linter::StringQuotes < Linter
|
4
4
|
include LinterRegistry
|
5
5
|
|
6
|
+
def visit_script_stringinterpolation(node)
|
7
|
+
# We can't statically determine what the resultant string looks like when
|
8
|
+
# string interpolation is used, e.g. "one #{$var} three" could be a very
|
9
|
+
# different string depending on $var = `'" + "'` or $var = `two`.
|
10
|
+
#
|
11
|
+
# Thus we manually skip the substrings in the string interpolation and
|
12
|
+
# visit the expressions in the interpolation itself.
|
13
|
+
node.children.reject { |child| child.is_a?(Sass::Script::Tree::Literal) }
|
14
|
+
.each { |child| visit(child) }
|
15
|
+
end
|
16
|
+
|
6
17
|
def visit_script_string(node)
|
7
18
|
check_quotes(node, source_from_range(node.source_range))
|
8
19
|
end
|
@@ -38,7 +38,7 @@ module SCSSLint
|
|
38
38
|
first = simple_sequence.members.first
|
39
39
|
simple_sequence.members.size == 1 &&
|
40
40
|
first.is_a?(Sass::Selector::Parent) &&
|
41
|
-
first.suffix.
|
41
|
+
first.suffix.nil? # Ignore concatenated selectors, like `&-something`
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
data/lib/scss_lint/version.rb
CHANGED
@@ -29,7 +29,7 @@ describe SCSSLint::Linter::SingleLinePerSelector do
|
|
29
29
|
}
|
30
30
|
CSS
|
31
31
|
|
32
|
-
it { should report_lint line:
|
32
|
+
it { should report_lint line: 3 }
|
33
33
|
end
|
34
34
|
|
35
35
|
context 'when commas are not at the end of the line' do
|
@@ -64,7 +64,7 @@ describe SCSSLint::Linter::SingleLinePerSelector do
|
|
64
64
|
}
|
65
65
|
CSS
|
66
66
|
|
67
|
-
it { should report_lint line:
|
67
|
+
it { should report_lint line: 4 }
|
68
68
|
end
|
69
69
|
|
70
70
|
context 'when rule contains interpolated selectors' do
|
@@ -218,6 +218,26 @@ describe SCSSLint::Linter::StringQuotes do
|
|
218
218
|
|
219
219
|
it { should_not report_lint }
|
220
220
|
end
|
221
|
+
|
222
|
+
context 'and contains interpolation inside a substring with single quotes' do
|
223
|
+
let(:css) { <<-CSS }
|
224
|
+
p {
|
225
|
+
content: "<svg width='\#{$something}'>";
|
226
|
+
}
|
227
|
+
CSS
|
228
|
+
|
229
|
+
it { should_not report_lint }
|
230
|
+
end
|
231
|
+
|
232
|
+
context 'and contains a single-quoted string inside interpolation' do
|
233
|
+
let(:css) { <<-CSS }
|
234
|
+
p {
|
235
|
+
content: "<svg width='\#{func('hello')}'>";
|
236
|
+
}
|
237
|
+
CSS
|
238
|
+
|
239
|
+
it { should report_lint }
|
240
|
+
end
|
221
241
|
end
|
222
242
|
|
223
243
|
context 'and string is written with double quotes' do
|
@@ -36,7 +36,7 @@ describe SCSSLint::SelectorVisitor do
|
|
36
36
|
context 'when visitor defines visit_attribute' do
|
37
37
|
class TestAttributeVisitor < TrackingSelectorVisitor
|
38
38
|
def visit_attribute(attribute)
|
39
|
-
@node_order << attribute.name
|
39
|
+
@node_order << attribute.name
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -56,7 +56,7 @@ describe SCSSLint::SelectorVisitor do
|
|
56
56
|
context 'when visitor defines visit_class' do
|
57
57
|
class TestClassVisitor < TrackingSelectorVisitor
|
58
58
|
def visit_class(klass)
|
59
|
-
@node_order << klass.name
|
59
|
+
@node_order << klass.name
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -76,7 +76,7 @@ describe SCSSLint::SelectorVisitor do
|
|
76
76
|
context 'when visitor defines visit_element' do
|
77
77
|
class TestElementVisitor < TrackingSelectorVisitor
|
78
78
|
def visit_element(element)
|
79
|
-
@node_order << element.name
|
79
|
+
@node_order << element.name
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
@@ -96,7 +96,7 @@ describe SCSSLint::SelectorVisitor do
|
|
96
96
|
context 'when visitor defines visit_id' do
|
97
97
|
class TestIdVisitor < TrackingSelectorVisitor
|
98
98
|
def visit_id(id)
|
99
|
-
@node_order << id.name
|
99
|
+
@node_order << id.name
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
@@ -137,7 +137,7 @@ describe SCSSLint::SelectorVisitor do
|
|
137
137
|
context 'when visitor defines visit_placeholder' do
|
138
138
|
class TestPlaceholderVisitor < TrackingSelectorVisitor
|
139
139
|
def visit_placeholder(placeholder)
|
140
|
-
@node_order << placeholder.name
|
140
|
+
@node_order << placeholder.name
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
@@ -156,7 +156,7 @@ describe SCSSLint::SelectorVisitor do
|
|
156
156
|
context 'when visitor defines visit_pseudo' do
|
157
157
|
class TestPseudoVisitor < TrackingSelectorVisitor
|
158
158
|
def visit_pseudo(pseudo)
|
159
|
-
@node_order << pseudo.name
|
159
|
+
@node_order << pseudo.name
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
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.
|
4
|
+
version: 0.28.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-
|
12
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|
@@ -31,20 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 3.
|
35
|
-
- - '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 3.3.7
|
34
|
+
version: 3.4.0
|
38
35
|
type: :runtime
|
39
36
|
prerelease: false
|
40
37
|
version_requirements: !ruby/object:Gem::Requirement
|
41
38
|
requirements:
|
42
39
|
- - ~>
|
43
40
|
- !ruby/object:Gem::Version
|
44
|
-
version: 3.
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 3.3.7
|
41
|
+
version: 3.4.0
|
48
42
|
- !ruby/object:Gem::Dependency
|
49
43
|
name: nokogiri
|
50
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,14 +73,14 @@ dependencies:
|
|
79
73
|
requirements:
|
80
74
|
- - '='
|
81
75
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
76
|
+
version: 0.25.0
|
83
77
|
type: :development
|
84
78
|
prerelease: false
|
85
79
|
version_requirements: !ruby/object:Gem::Requirement
|
86
80
|
requirements:
|
87
81
|
- - '='
|
88
82
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
83
|
+
version: 0.25.0
|
90
84
|
description: Configurable tool for writing clean and consistent SCSS
|
91
85
|
email:
|
92
86
|
- eng@causes.com
|
@@ -295,3 +289,4 @@ test_files:
|
|
295
289
|
- spec/support/matchers/report_lint.rb
|
296
290
|
- spec/support/isolated_environment.rb
|
297
291
|
- spec/spec_helper.rb
|
292
|
+
has_rdoc:
|