scss-lint 0.22.0 → 0.23.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 +4 -4
- data/config/default.yml +6 -0
- data/lib/scss_lint.rb +1 -0
- data/lib/scss_lint/cli.rb +1 -1
- data/lib/scss_lint/lint.rb +4 -4
- data/lib/scss_lint/linter.rb +24 -3
- data/lib/scss_lint/linter/capitalization_in_selector.rb +1 -1
- data/lib/scss_lint/linter/color_keyword.rb +1 -1
- data/lib/scss_lint/linter/compass/property_with_mixin.rb +5 -0
- data/lib/scss_lint/linter/declaration_order.rb +1 -1
- data/lib/scss_lint/linter/duplicate_root.rb +33 -0
- data/lib/scss_lint/linter/empty_line_between_blocks.rb +1 -1
- data/lib/scss_lint/linter/id_with_extraneous_selector.rb +4 -2
- data/lib/scss_lint/linter/indentation.rb +1 -1
- data/lib/scss_lint/linter/name_format.rb +1 -1
- data/lib/scss_lint/linter/property_sort_order.rb +1 -1
- data/lib/scss_lint/linter/selector_depth.rb +1 -1
- data/lib/scss_lint/linter/shorthand.rb +10 -3
- data/lib/scss_lint/linter/space_after_property_colon.rb +5 -5
- data/lib/scss_lint/linter/space_before_brace.rb +33 -12
- data/lib/scss_lint/linter/space_between_parens.rb +4 -2
- data/lib/scss_lint/linter/string_quotes.rb +2 -2
- data/lib/scss_lint/linter/trailing_semicolon_after_property_value.rb +1 -1
- data/lib/scss_lint/linter/unnecessary_mantissa.rb +42 -0
- data/lib/scss_lint/linter/zero_unit.rb +6 -1
- data/lib/scss_lint/location.rb +38 -0
- data/lib/scss_lint/reporter/default_reporter.rb +1 -1
- data/lib/scss_lint/reporter/xml_reporter.rb +6 -4
- data/lib/scss_lint/runner.rb +3 -3
- data/lib/scss_lint/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bbc506b11e888967c3a60b4ee497049899db21d
|
4
|
+
data.tar.gz: 3474861bb7c69bc96acfc51a6c4c78ac75372bb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abdcc9357f0db63b291114acf5748ea2df1ca077fca03033b8b71ac4faae48d26424d00ea23c846854f9da47a6c67baf5187cb34932182ced1f987932cc58970
|
7
|
+
data.tar.gz: 673461370cc8c5598b25bea6b2a06e8e61cb3b53389a7a729cebf6eb79b836b36d4e4c3d211a5aebf6826423b0536f27575042b1ee450712acc5f837b0031941
|
data/config/default.yml
CHANGED
@@ -21,6 +21,9 @@ linters:
|
|
21
21
|
DuplicateProperty:
|
22
22
|
enabled: true
|
23
23
|
|
24
|
+
DuplicateRoot:
|
25
|
+
enabled: true
|
26
|
+
|
24
27
|
EmptyLineBetweenBlocks:
|
25
28
|
enabled: true
|
26
29
|
ignore_single_line_blocks: true
|
@@ -94,6 +97,9 @@ linters:
|
|
94
97
|
TrailingSemicolonAfterPropertyValue:
|
95
98
|
enabled: true
|
96
99
|
|
100
|
+
UnnecessaryMantissa:
|
101
|
+
enabled: true
|
102
|
+
|
97
103
|
UrlFormat:
|
98
104
|
enabled: true
|
99
105
|
|
data/lib/scss_lint.rb
CHANGED
data/lib/scss_lint/cli.rb
CHANGED
@@ -181,7 +181,7 @@ module SCSSLint
|
|
181
181
|
|
182
182
|
# @param lints [Array<Lint>]
|
183
183
|
def report_lints(lints)
|
184
|
-
sorted_lints = lints.sort_by { |l| [l.filename, l.
|
184
|
+
sorted_lints = lints.sort_by { |l| [l.filename, l.location] }
|
185
185
|
reporter = @options.fetch(:reporter, Reporter::DefaultReporter)
|
186
186
|
.new(sorted_lints)
|
187
187
|
output = reporter.report_lints
|
data/lib/scss_lint/lint.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
module SCSSLint
|
2
2
|
# Stores information about a single problem that was detected by a [Linter].
|
3
3
|
class Lint
|
4
|
-
attr_reader :filename, :
|
4
|
+
attr_reader :filename, :location, :description, :severity
|
5
5
|
|
6
6
|
# @param filename [String]
|
7
|
-
# @param
|
7
|
+
# @param location [SCSSLint::Location]
|
8
8
|
# @param description [String]
|
9
9
|
# @param severity [Symbol]
|
10
|
-
def initialize(filename,
|
10
|
+
def initialize(filename, location, description, severity = :warning)
|
11
11
|
@filename = filename
|
12
|
-
@
|
12
|
+
@location = location
|
13
13
|
@description = description
|
14
14
|
@severity = severity
|
15
15
|
end
|
data/lib/scss_lint/linter.rb
CHANGED
@@ -23,13 +23,34 @@ module SCSSLint
|
|
23
23
|
# @param node_or_line [Sass::Script::Tree::Node, Sass::Engine::Line]
|
24
24
|
# @param message [String]
|
25
25
|
def add_lint(node_or_line, message)
|
26
|
-
|
26
|
+
location = if node_or_line.respond_to?(:source_range) && node_or_line.source_range
|
27
|
+
location_from_range(node_or_line.source_range)
|
28
|
+
elsif node_or_line.respond_to?(:line)
|
29
|
+
Location.new(node_or_line.line)
|
30
|
+
else
|
31
|
+
Location.new(node_or_line)
|
32
|
+
end
|
27
33
|
|
28
34
|
@lints << Lint.new(engine.filename,
|
29
|
-
|
35
|
+
location,
|
30
36
|
message)
|
31
37
|
end
|
32
38
|
|
39
|
+
# Extract {SCSSLint::Location} from a {Sass::Source::Range}.
|
40
|
+
#
|
41
|
+
# @param range [Sass::Source::Range]
|
42
|
+
# @return [SCSSLint::Location]
|
43
|
+
def location_from_range(range)
|
44
|
+
length = if range.start_pos.line == range.end_pos.line
|
45
|
+
range.end_pos.offset - range.start_pos.offset
|
46
|
+
else
|
47
|
+
line_source = engine.lines[range.start_pos.line]
|
48
|
+
line_source.length - range.start_pos.offset + 1
|
49
|
+
end
|
50
|
+
|
51
|
+
Location.new(range.start_pos.line, range.start_pos.offset, length)
|
52
|
+
end
|
53
|
+
|
33
54
|
# @param source_position [Sass::Source::Position]
|
34
55
|
# @param offset [Integer]
|
35
56
|
# @return [String] the character at the given [Sass::Source::Position]
|
@@ -72,7 +93,7 @@ module SCSSLint
|
|
72
93
|
#
|
73
94
|
# @param node [Sass::Tree::Node]
|
74
95
|
# @return [true,false] whether the node spans a single line
|
75
|
-
def node_on_single_line(node)
|
96
|
+
def node_on_single_line?(node)
|
76
97
|
return if node.source_range.start_pos.line != node.source_range.end_pos.line
|
77
98
|
|
78
99
|
# The Sass parser reports an incorrect source range if the trailing curly
|
@@ -33,7 +33,7 @@ module SCSSLint
|
|
33
33
|
name = node.name.join
|
34
34
|
if name =~ /[A-Z]/
|
35
35
|
selector_name ||= node.class.name.split('::').last
|
36
|
-
add_lint(node, "#{selector_name} `#{name}` in selector should be "
|
36
|
+
add_lint(node, "#{selector_name} `#{name}` in selector should be " \
|
37
37
|
"written in all lowercase as `#{name.downcase}`")
|
38
38
|
end
|
39
39
|
end
|
@@ -9,6 +9,11 @@ module SCSSLint
|
|
9
9
|
if PROPERTIES_WITH_MIXINS.include?(prop_name)
|
10
10
|
add_lint node, "Use the Compass `#{prop_name}` mixin instead of the property"
|
11
11
|
end
|
12
|
+
|
13
|
+
if prop_name == 'display' && node.value.to_sass == 'inline-block'
|
14
|
+
add_lint node,
|
15
|
+
'Use the Compass `inline-block` mixin instead of `display: inline-block`'
|
16
|
+
end
|
12
17
|
end
|
13
18
|
|
14
19
|
private
|
@@ -27,7 +27,7 @@ module SCSSLint
|
|
27
27
|
private
|
28
28
|
|
29
29
|
MESSAGE =
|
30
|
-
'Rule sets should start with @extend declarations, followed by '
|
30
|
+
'Rule sets should start with @extend declarations, followed by ' \
|
31
31
|
'properties and nested rule sets, in that order'
|
32
32
|
|
33
33
|
def important_node?(node)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module SCSSLint
|
2
|
+
# Checks for identical root selectors.
|
3
|
+
class Linter::DuplicateRoot < Linter
|
4
|
+
include LinterRegistry
|
5
|
+
|
6
|
+
def visit_root(node)
|
7
|
+
# Root rules are evaluated per document, so use new hashes for eash file
|
8
|
+
@roots = {}
|
9
|
+
yield # Continue linting children
|
10
|
+
end
|
11
|
+
|
12
|
+
def visit_rule(node)
|
13
|
+
if @roots[node.rule]
|
14
|
+
add_lint node.line,
|
15
|
+
"Merge root rule `#{node.rule.join}` with identical " \
|
16
|
+
"rule on line #{@roots[node.rule].line}"
|
17
|
+
else
|
18
|
+
@roots[node.rule] = node
|
19
|
+
end
|
20
|
+
|
21
|
+
# Don't yield so we only check one level deep
|
22
|
+
end
|
23
|
+
|
24
|
+
# Define stubs so we don't check rules nested in other constructs
|
25
|
+
%w[
|
26
|
+
media
|
27
|
+
mixin
|
28
|
+
mixindef
|
29
|
+
].each do |node_type|
|
30
|
+
define_method("visit_#{node_type}") { |*args| }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -30,7 +30,7 @@ module SCSSLint
|
|
30
30
|
MESSAGE_FORMAT = '%s declaration should be %s by an empty line'
|
31
31
|
|
32
32
|
def check(node, type)
|
33
|
-
return if config['ignore_single_line_blocks'] && node_on_single_line(node)
|
33
|
+
return if config['ignore_single_line_blocks'] && node_on_single_line?(node)
|
34
34
|
check_preceding_node(node, type)
|
35
35
|
check_following_node(node, type)
|
36
36
|
end
|
@@ -13,8 +13,10 @@ module SCSSLint
|
|
13
13
|
end
|
14
14
|
|
15
15
|
if can_be_simplified
|
16
|
-
|
17
|
-
|
16
|
+
# TODO: Sass::Selector::SimpleSequence#source_range sometimes lies about
|
17
|
+
# its line, so reference `#line` directly
|
18
|
+
add_lint(seq.line, "Selector `#{seq}` can be simplified to `#{id_sel}`, " <<
|
19
|
+
'since IDs should be uniquely identifying')
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -47,7 +47,7 @@ module SCSSLint
|
|
47
47
|
|
48
48
|
def check_name(node, node_type, node_text = node.name)
|
49
49
|
if convention = violated_convention(node_text)
|
50
|
-
add_lint(node, "Name of #{node_type} `#{node_text}` should be "
|
50
|
+
add_lint(node, "Name of #{node_type} `#{node_text}` should be " \
|
51
51
|
"written #{convention[:explanation]}")
|
52
52
|
end
|
53
53
|
end
|
@@ -32,7 +32,7 @@ module SCSSLint
|
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
-
MESSAGE = 'Properties should be sorted in order, with vendor-prefixed '
|
35
|
+
MESSAGE = 'Properties should be sorted in order, with vendor-prefixed ' \
|
36
36
|
'extensions before the standardized CSS property'
|
37
37
|
|
38
38
|
# Compares two properties which can contain a vendor prefix. It allows for a
|
@@ -15,7 +15,7 @@ module SCSSLint
|
|
15
15
|
|
16
16
|
if @depth > @max_depth
|
17
17
|
add_lint(node.parsed_rules || node,
|
18
|
-
'Selector should have depth of applicability no greater '
|
18
|
+
'Selector should have depth of applicability no greater ' \
|
19
19
|
"than #{@max_depth}, but was #{@depth}")
|
20
20
|
end
|
21
21
|
|
@@ -43,10 +43,17 @@ module SCSSLint
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
LIST_LITERAL_REGEX = %r{
|
47
|
+
\A
|
48
|
+
(\S+\s+\S+(\s+\S+){0,2}) # Two to four values separated by spaces
|
49
|
+
(\s+!\w+)? # Ignore `!important` priority overrides
|
50
|
+
\z
|
51
|
+
}x
|
52
|
+
|
46
53
|
def check_script_string(prop, script_string)
|
47
54
|
return unless script_string.type == :identifier
|
48
55
|
|
49
|
-
if values = script_string.value.strip[
|
56
|
+
if values = script_string.value.strip[LIST_LITERAL_REGEX, 1]
|
50
57
|
check_shorthand(prop, script_string, values.split)
|
51
58
|
end
|
52
59
|
end
|
@@ -57,8 +64,8 @@ module SCSSLint
|
|
57
64
|
shortest_form = condensed_shorthand(*values)
|
58
65
|
return if values == shortest_form
|
59
66
|
|
60
|
-
add_lint(node, "Shorthand form for property `#{prop}` should be "
|
61
|
-
"written more concisely as `#{shortest_form.join(' ')}` "
|
67
|
+
add_lint(node, "Shorthand form for property `#{prop}` should be " \
|
68
|
+
"written more concisely as `#{shortest_form.join(' ')}` " \
|
62
69
|
"instead of `#{values.join(' ')}`")
|
63
70
|
end
|
64
71
|
|
@@ -11,13 +11,13 @@ module SCSSLint
|
|
11
11
|
|
12
12
|
if config['allow_extra_spaces']
|
13
13
|
if spaces < MINIMUM_SPACES_AFTER_COLON
|
14
|
-
add_lint node, 'Colon after property should be followed by '
|
15
|
-
"at least #{pluralize(MINIMUM_SPACES_AFTER_COLON, 'space')}
|
14
|
+
add_lint node, 'Colon after property should be followed by ' \
|
15
|
+
"at least #{pluralize(MINIMUM_SPACES_AFTER_COLON, 'space')}"
|
16
16
|
end
|
17
17
|
elsif spaces != MINIMUM_SPACES_AFTER_COLON
|
18
|
-
add_lint node, 'Colon after property should be followed by '
|
19
|
-
pluralize(MINIMUM_SPACES_AFTER_COLON, 'space')
|
20
|
-
"
|
18
|
+
add_lint node, 'Colon after property should be followed by ' \
|
19
|
+
"#{pluralize(MINIMUM_SPACES_AFTER_COLON, 'space')} " \
|
20
|
+
"instead of #{pluralize(spaces, 'space')}"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -3,19 +3,40 @@ module SCSSLint
|
|
3
3
|
class Linter::SpaceBeforeBrace < Linter
|
4
4
|
include LinterRegistry
|
5
5
|
|
6
|
-
def
|
7
|
-
|
6
|
+
def check_node(node)
|
7
|
+
source = source_from_range(node.source_range).strip
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
# Only lint `@include`s which have curly braces
|
10
|
+
if source[-1] == '{'
|
11
|
+
check_for_space(node, source)
|
12
|
+
end
|
13
|
+
|
14
|
+
yield
|
15
|
+
end
|
16
|
+
|
17
|
+
alias_method :visit_function, :check_node
|
18
|
+
alias_method :visit_each, :check_node
|
19
|
+
alias_method :visit_for, :check_node
|
20
|
+
alias_method :visit_function, :check_node
|
21
|
+
alias_method :visit_mixindef, :check_node
|
22
|
+
alias_method :visit_mixin, :check_node
|
23
|
+
alias_method :visit_rule, :check_node
|
24
|
+
alias_method :visit_while, :check_node
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def check_for_space(node, string)
|
29
|
+
line = node.source_range.end_pos.line
|
30
|
+
|
31
|
+
if config['allow_single_line_padding'] && node_on_single_line?(node)
|
32
|
+
if string[-2] != ' '
|
33
|
+
add_lint(line, 'Opening curly brace `{` should be ' \
|
34
|
+
'preceded by at least one space')
|
35
|
+
end
|
36
|
+
else
|
37
|
+
if string[-2] != ' ' || string[-3] == ' '
|
38
|
+
add_lint(line, 'Opening curly brace `{` should be ' \
|
39
|
+
'preceded by one space')
|
19
40
|
end
|
20
41
|
end
|
21
42
|
end
|
@@ -26,8 +26,10 @@ module SCSSLint
|
|
26
26
|
spaces = str.count ' '
|
27
27
|
|
28
28
|
if spaces != @spaces
|
29
|
-
|
30
|
-
|
29
|
+
location = Location.new(index + 1)
|
30
|
+
message = "Expected #{pluralize(@spaces, 'space')}" <<
|
31
|
+
" between parentheses instead of #{spaces}"
|
32
|
+
@lints << Lint.new(engine.filename, location, message)
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -53,7 +53,7 @@ module SCSSLint
|
|
53
53
|
add_lint(node, 'Prefer single quoted strings') if string !~ /'/
|
54
54
|
else
|
55
55
|
if string =~ /(?<! \\) \\"/x && string !~ /'/
|
56
|
-
add_lint(node, 'Use single-quoted strings when writing double '
|
56
|
+
add_lint(node, 'Use single-quoted strings when writing double ' \
|
57
57
|
'quotes to avoid having to escape the double quotes')
|
58
58
|
end
|
59
59
|
end
|
@@ -62,7 +62,7 @@ module SCSSLint
|
|
62
62
|
def check_single_quotes(node, string)
|
63
63
|
if config['style'] == 'single_quotes'
|
64
64
|
if string =~ /(?<! \\) \\'/x && string !~ /"/
|
65
|
-
add_lint(node, 'Use double-quoted strings when writing single '
|
65
|
+
add_lint(node, 'Use double-quoted strings when writing single ' \
|
66
66
|
'quotes to avoid having to escape the single quotes')
|
67
67
|
elsif string =~ /(?<! \\) \\"/x
|
68
68
|
add_lint(node, "Don't escape double quotes in single-quoted strings")
|
@@ -16,7 +16,7 @@ module SCSSLint
|
|
16
16
|
# being on the next line
|
17
17
|
line = node.source_range.end_pos.line - 1
|
18
18
|
add_lint line,
|
19
|
-
'Property declaration should not have a space before '
|
19
|
+
'Property declaration should not have a space before ' \
|
20
20
|
'the terminating semicolon'
|
21
21
|
end
|
22
22
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module SCSSLint
|
2
|
+
# Checks for the unnecessary inclusion of a zero-value mantissa in numbers.
|
3
|
+
# (e.g. `4.0` could be written as just `4`)
|
4
|
+
class Linter::UnnecessaryMantissa < Linter
|
5
|
+
include LinterRegistry
|
6
|
+
|
7
|
+
def visit_script_string(node)
|
8
|
+
return unless node.type == :identifier
|
9
|
+
|
10
|
+
node.value.scan(REAL_NUMBER_REGEX) do |number, integer, mantissa, units|
|
11
|
+
if unnecessary_mantissa?(mantissa)
|
12
|
+
add_lint(node, MESSAGE_FORMAT % [number, integer, units])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def visit_script_number(node)
|
18
|
+
return unless match = REAL_NUMBER_REGEX.match(source_from_range(node.source_range))
|
19
|
+
|
20
|
+
if unnecessary_mantissa?(match[:mantissa])
|
21
|
+
add_lint(node, MESSAGE_FORMAT % [match[:number], match[:integer], match[:units]])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
REAL_NUMBER_REGEX = %r{
|
28
|
+
\b(?<number>
|
29
|
+
(?<integer>\d*)
|
30
|
+
\.
|
31
|
+
(?<mantissa>\d+)
|
32
|
+
(?<units>\w*)
|
33
|
+
)\b
|
34
|
+
}ix
|
35
|
+
|
36
|
+
MESSAGE_FORMAT = '`%s` should be written without the mantissa as `%s%s`'
|
37
|
+
|
38
|
+
def unnecessary_mantissa?(mantissa)
|
39
|
+
mantissa !~ /[^0]/
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -21,7 +21,12 @@ module SCSSLint
|
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
|
-
ZERO_UNIT_REGEX =
|
24
|
+
ZERO_UNIT_REGEX = %r{
|
25
|
+
\b
|
26
|
+
(?<!\.|\#) # Ignore zeroes following `#` or `.` (colors / decimals)
|
27
|
+
(0[a-z]+) # Zero followed by letters (indicating some sort of unit)
|
28
|
+
\b
|
29
|
+
}ix
|
25
30
|
|
26
31
|
MESSAGE_FORMAT = '`%s` should be written without units as `0`'
|
27
32
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module SCSSLint
|
2
|
+
# Stores a location of {Lint} in a source.
|
3
|
+
class Location
|
4
|
+
include Comparable
|
5
|
+
|
6
|
+
attr_reader :line, :column, :length
|
7
|
+
|
8
|
+
# @param line [Integer] One-based index
|
9
|
+
# @param column [Integer] One-based index
|
10
|
+
# @param length [Integer] Number of characters, including the first character
|
11
|
+
def initialize(line = 1, column = 1, length = 1)
|
12
|
+
raise ArgumentError, "Line must be more than 0, passed #{line}" if line < 1
|
13
|
+
raise ArgumentError, "Column must be more than 0, passed #{column}" if column < 1
|
14
|
+
raise ArgumentError, "Length must be more than 0, passed #{length}" if length < 1
|
15
|
+
|
16
|
+
@line = line
|
17
|
+
@column = column
|
18
|
+
@length = length
|
19
|
+
end
|
20
|
+
|
21
|
+
def ==(other)
|
22
|
+
[:line, :column, :length].all? do |attr|
|
23
|
+
send(attr) == other.send(attr)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
alias_method :eql?, :==
|
28
|
+
|
29
|
+
def <=>(other)
|
30
|
+
[:line, :column, :length].each do |attr|
|
31
|
+
result = send(attr) <=> other.send(attr)
|
32
|
+
return result unless result == 0
|
33
|
+
end
|
34
|
+
|
35
|
+
0
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -5,7 +5,7 @@ module SCSSLint
|
|
5
5
|
if lints.any?
|
6
6
|
lints.map do |lint|
|
7
7
|
type = lint.error? ? '[E]'.color(:red) : '[W]'.color(:yellow)
|
8
|
-
"#{lint.filename.color(:cyan)}:" << "#{lint.line}".color(:magenta) <<
|
8
|
+
"#{lint.filename.color(:cyan)}:" << "#{lint.location.line}".color(:magenta) <<
|
9
9
|
" #{type} #{lint.description}"
|
10
10
|
end.join("\n") + "\n"
|
11
11
|
end
|
@@ -6,12 +6,14 @@ module SCSSLint
|
|
6
6
|
|
7
7
|
output << '<lint>'
|
8
8
|
lints.group_by(&:filename).each do |filename, file_lints|
|
9
|
-
output << "<file name
|
9
|
+
output << "<file name=#{filename.encode(:xml => :attr)}>"
|
10
10
|
|
11
11
|
file_lints.each do |lint|
|
12
|
-
output << "<issue line
|
13
|
-
"
|
14
|
-
"
|
12
|
+
output << "<issue line=\"#{lint.location.line}\" " <<
|
13
|
+
"column=\"#{lint.location.column}\" " <<
|
14
|
+
"length=\"#{lint.location.length}\" " <<
|
15
|
+
"severity=\"#{lint.severity}\" " <<
|
16
|
+
"reason=#{lint.description.encode(:xml => :attr)} />"
|
15
17
|
end
|
16
18
|
|
17
19
|
output << '</file>'
|
data/lib/scss_lint/runner.rb
CHANGED
@@ -43,15 +43,15 @@ module SCSSLint
|
|
43
43
|
linter.run(engine, config.linter_options(linter))
|
44
44
|
rescue => error
|
45
45
|
raise LinterError,
|
46
|
-
"#{linter.class} raised unexpected error linting file #{file}: "
|
46
|
+
"#{linter.class} raised unexpected error linting file #{file}: " \
|
47
47
|
"'#{error.message}'",
|
48
48
|
error.backtrace
|
49
49
|
end
|
50
50
|
end
|
51
51
|
rescue Sass::SyntaxError => ex
|
52
|
-
@lints << Lint.new(ex.sass_filename, ex.sass_line, ex.to_s, :error)
|
52
|
+
@lints << Lint.new(ex.sass_filename, Location.new(ex.sass_line), ex.to_s, :error)
|
53
53
|
rescue FileEncodingError => ex
|
54
|
-
@lints << Lint.new(file,
|
54
|
+
@lints << Lint.new(file, Location.new, ex.to_s, :error)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
data/lib/scss_lint/version.rb
CHANGED
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.23.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-04-
|
12
|
+
date: 2014-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- lib/scss_lint/version.rb
|
82
82
|
- lib/scss_lint/constants.rb
|
83
83
|
- lib/scss_lint/utils.rb
|
84
|
+
- lib/scss_lint/location.rb
|
84
85
|
- lib/scss_lint/reporter/files_reporter.rb
|
85
86
|
- lib/scss_lint/reporter/xml_reporter.rb
|
86
87
|
- lib/scss_lint/reporter/default_reporter.rb
|
@@ -106,6 +107,7 @@ files:
|
|
106
107
|
- lib/scss_lint/linter/declaration_order.rb
|
107
108
|
- lib/scss_lint/linter/zero_unit.rb
|
108
109
|
- lib/scss_lint/linter/placeholder_in_extend.rb
|
110
|
+
- lib/scss_lint/linter/duplicate_root.rb
|
109
111
|
- lib/scss_lint/linter/selector_depth.rb
|
110
112
|
- lib/scss_lint/linter/compass/property_with_mixin.rb
|
111
113
|
- lib/scss_lint/linter/space_after_property_name.rb
|
@@ -122,6 +124,7 @@ files:
|
|
122
124
|
- lib/scss_lint/linter/color_keyword.rb
|
123
125
|
- lib/scss_lint/linter/string_quotes.rb
|
124
126
|
- lib/scss_lint/linter/leading_zero.rb
|
127
|
+
- lib/scss_lint/linter/unnecessary_mantissa.rb
|
125
128
|
- lib/scss_lint/linter/comment.rb
|
126
129
|
- lib/scss_lint/linter/empty_rule.rb
|
127
130
|
- lib/scss_lint/linter/single_line_per_selector.rb
|
@@ -156,4 +159,3 @@ signing_key:
|
|
156
159
|
specification_version: 4
|
157
160
|
summary: SCSS lint tool
|
158
161
|
test_files: []
|
159
|
-
has_rdoc:
|