scss_lint 0.42.1 → 0.42.2
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 +4 -4
- data/lib/scss_lint/linter/color_variable.rb +11 -1
- data/lib/scss_lint/linter/hex_validation.rb +1 -1
- data/lib/scss_lint/linter/space_around_operator.rb +12 -3
- data/lib/scss_lint/version.rb +1 -1
- data/spec/scss_lint/linter/color_variable_spec.rb +8 -0
- data/spec/scss_lint/linter/hex_validation_spec.rb +11 -0
- data/spec/scss_lint/linter/space_around_operator_spec.rb +14 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bb29e6e4cef4d98cce3e61248d11f2dde2315a1
|
4
|
+
data.tar.gz: 52c5cdfb7895f10c883188633a75c32b3e77267a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e68b7e8d5afa4970b42da268f4fb2085c2ee81ab5f4eb0d020a67b97af286ec629ccad33429d542723bf0dd851e9c8ae31a93c464d203609c0b0c4c26db7c5b
|
7
|
+
data.tar.gz: 5cc833524095ed48bd5a01e3aebd2a4919ec4c79149b7d0f7c006552bdeb5d6fd42512109fdb6994ee78b50461cb144c3a7283703726d99b71a5cca2d4b691f7
|
@@ -33,7 +33,7 @@ module SCSSLint
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def visit_script_funcall(node)
|
36
|
-
if
|
36
|
+
if literal_color_function?(node)
|
37
37
|
record_lint node, node.to_sass
|
38
38
|
else
|
39
39
|
yield
|
@@ -63,6 +63,10 @@ module SCSSLint
|
|
63
63
|
parent.node_parent.is_a?(Sass::Tree::VariableNode)
|
64
64
|
end
|
65
65
|
|
66
|
+
def function_in_variable_declaration?(node)
|
67
|
+
node.node_parent.is_a?(Sass::Tree::VariableNode)
|
68
|
+
end
|
69
|
+
|
66
70
|
def in_rgba_function_call?(node)
|
67
71
|
grandparent = node_ancestor(node, 2)
|
68
72
|
|
@@ -83,5 +87,11 @@ module SCSSLint
|
|
83
87
|
def color_function?(node)
|
84
88
|
COLOR_FUNCTIONS.include?(node.name)
|
85
89
|
end
|
90
|
+
|
91
|
+
def literal_color_function?(node)
|
92
|
+
color_function?(node) &&
|
93
|
+
all_arguments_are_literals?(node) &&
|
94
|
+
!function_in_variable_declaration?(node)
|
95
|
+
end
|
86
96
|
end
|
87
97
|
end
|
@@ -21,24 +21,33 @@ module SCSSLint
|
|
21
21
|
yield
|
22
22
|
end
|
23
23
|
|
24
|
+
# Making a public version of #source_from_range, a private method.
|
24
25
|
def source_fm_range(range)
|
25
26
|
source_from_range(range)
|
26
27
|
end
|
27
28
|
|
28
29
|
private
|
29
30
|
|
30
|
-
def check(node, operation_sources)
|
31
|
+
def check(node, operation_sources) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/LineLength
|
31
32
|
match = operation_sources.operator_source.match(/
|
32
33
|
(?<left_space>\s*)
|
33
34
|
(?<operator>\S+)
|
34
35
|
(?<right_space>\s*)
|
35
36
|
/x)
|
36
37
|
|
38
|
+
# We forgive spacing with newlines. In the case of a newline occurring on
|
39
|
+
# one side or another, we don't care about indentation, and the
|
40
|
+
# TrailingWhitespace linter will worry about trailing whitespace, so we
|
41
|
+
# just don't worry about space with a newline.
|
42
|
+
left_newline = match[:left_space].include?("\n")
|
43
|
+
right_newline = match[:right_space].include?("\n")
|
37
44
|
if config['style'] == 'one_space'
|
38
|
-
if match[:left_space] != ' '
|
45
|
+
if (match[:left_space] != ' ' && !left_newline) ||
|
46
|
+
(match[:right_space] != ' ' && !right_newline)
|
39
47
|
add_lint(node, operation_sources.space_msg(match[:operator]))
|
40
48
|
end
|
41
|
-
elsif match[:left_space] != ''
|
49
|
+
elsif (match[:left_space] != '' && !left_newline) ||
|
50
|
+
(match[:right_space] != '' && !right_newline)
|
42
51
|
add_lint(node, operation_sources.no_space_msg(match[:operator]))
|
43
52
|
end
|
44
53
|
end
|
data/lib/scss_lint/version.rb
CHANGED
@@ -9,6 +9,14 @@ describe SCSSLint::Linter::ColorVariable do
|
|
9
9
|
it { should_not report_lint }
|
10
10
|
end
|
11
11
|
|
12
|
+
context 'when a color function containing literals is used in a variable declaration' do
|
13
|
+
let(:scss) { <<-SCSS }
|
14
|
+
$my-color: rgba(0, 0, 0, 0.2);
|
15
|
+
SCSS
|
16
|
+
|
17
|
+
it { should_not report_lint }
|
18
|
+
end
|
19
|
+
|
12
20
|
context 'when a color literal is used in a property' do
|
13
21
|
let(:scss) { <<-SCSS }
|
14
22
|
p {
|
@@ -37,4 +37,15 @@ describe SCSSLint::Linter::HexValidation do
|
|
37
37
|
it { should report_lint line: 2 }
|
38
38
|
it { should report_lint line: 3 }
|
39
39
|
end
|
40
|
+
|
41
|
+
context 'when rule contains hex codes in a longer string' do
|
42
|
+
let(:scss) { <<-SCSS }
|
43
|
+
p {
|
44
|
+
content: 'foo#bad';
|
45
|
+
content: 'foo #ba';
|
46
|
+
}
|
47
|
+
SCSS
|
48
|
+
|
49
|
+
it { should report_lint line: 3 }
|
50
|
+
end
|
40
51
|
end
|
@@ -60,18 +60,28 @@ describe SCSSLint::Linter::SpaceAroundOperator do
|
|
60
60
|
it { should report_lint line: 10 }
|
61
61
|
end
|
62
62
|
|
63
|
-
context 'when
|
63
|
+
context 'when infix operators and newlines exist' do
|
64
64
|
let(:scss) { <<-SCSS }
|
65
65
|
p {
|
66
66
|
margin: 7px+
|
67
67
|
7px;
|
68
|
+
}
|
69
|
+
SCSS
|
70
|
+
|
71
|
+
it { should report_lint line: 2 }
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when infix operators and newlines exist, but otherwise correct spacing' do
|
75
|
+
let(:scss) { <<-SCSS }
|
76
|
+
p {
|
77
|
+
margin: 7px +
|
78
|
+
7px;
|
68
79
|
padding: 9px
|
69
80
|
+ 9px;
|
70
81
|
}
|
71
82
|
SCSS
|
72
83
|
|
73
|
-
it {
|
74
|
-
it { should report_lint line: 4 }
|
84
|
+
it { should_not report_lint }
|
75
85
|
end
|
76
86
|
|
77
87
|
context 'when numeric values with multiple infix operators exist' do
|
@@ -232,7 +242,7 @@ describe SCSSLint::Linter::SpaceAroundOperator do
|
|
232
242
|
end
|
233
243
|
end
|
234
244
|
|
235
|
-
context 'when
|
245
|
+
context 'when no space is preferred' do
|
236
246
|
let(:style) { 'no_space' }
|
237
247
|
|
238
248
|
context 'when values with single-spaced infix operators exist' do
|
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.42.
|
4
|
+
version: 0.42.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brigade Engineering
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-10-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|