haml_lint 0.23.1 → 0.23.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/haml_lint/document.rb +1 -1
- data/lib/haml_lint/linter/line_length.rb +6 -1
- data/lib/haml_lint/tree/node.rb +20 -0
- data/lib/haml_lint/tree/root_node.rb +1 -1
- data/lib/haml_lint/version.rb +1 -1
- 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: 5e1e7727e9ee3dadac7fe5fbc6ba6e4a42e482b5
|
4
|
+
data.tar.gz: 7176808267f479eeb56757133e8c0015c4841b77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c944db1432ca3b9133769fde9173b0dee6ec253f0ac1d16d5d194fce086bfce9952ae49603a196b3d9fc30dbd93572d067169490483ee01b14c36433cdb49c32
|
7
|
+
data.tar.gz: e533c56866c2ad9702be3461068cb2aab5fe73c1a39eaf059bfae0850628a1145c67e832eae29f663f6b336d96bff8851d0dcafd8feebb1972767af8c89c6e67
|
data/lib/haml_lint/document.rb
CHANGED
@@ -43,7 +43,7 @@ module HamlLint
|
|
43
43
|
def process_source(source)
|
44
44
|
@source = process_encoding(source)
|
45
45
|
@source = strip_frontmatter(source)
|
46
|
-
@source_lines = @source.split(
|
46
|
+
@source_lines = @source.split(/\r\n|\r|\n/)
|
47
47
|
|
48
48
|
@tree = process_tree(HamlLint::Adapter.detect_class.new(@source).parse)
|
49
49
|
rescue Haml::Error => ex
|
@@ -5,6 +5,11 @@ module HamlLint
|
|
5
5
|
class Linter::LineLength < Linter
|
6
6
|
include LinterRegistry
|
7
7
|
|
8
|
+
# A marker for a line within a multiline node.
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
DummyNode = Struct.new(:line)
|
12
|
+
|
8
13
|
MSG = 'Line is too long. [%d/%d]'.freeze
|
9
14
|
|
10
15
|
def visit_root(root)
|
@@ -15,7 +20,7 @@ module HamlLint
|
|
15
20
|
|
16
21
|
node = root.node_for_line(index + 1)
|
17
22
|
unless node.disabled?(self)
|
18
|
-
record_lint(
|
23
|
+
record_lint(DummyNode.new(index + 1), format(MSG, line.length, max_length))
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
data/lib/haml_lint/tree/node.rb
CHANGED
@@ -85,6 +85,26 @@ module HamlLint::Tree
|
|
85
85
|
"#<#{self.class.name}>"
|
86
86
|
end
|
87
87
|
|
88
|
+
# The lines of text, if any, that are contained in the node.
|
89
|
+
#
|
90
|
+
# @api public
|
91
|
+
# @return [Array<String>]
|
92
|
+
def lines
|
93
|
+
return [] unless @value && text
|
94
|
+
|
95
|
+
text.split(/\r\n|\r|\n/)
|
96
|
+
end
|
97
|
+
|
98
|
+
# The line numbers that are contained within the node.
|
99
|
+
#
|
100
|
+
# @api public
|
101
|
+
# @return [Range]
|
102
|
+
def line_numbers
|
103
|
+
return (line..line) unless @value && text
|
104
|
+
|
105
|
+
(line..line + lines.count)
|
106
|
+
end
|
107
|
+
|
88
108
|
# The previous node to be traversed in the tree.
|
89
109
|
#
|
90
110
|
# @return [HamlLint::Tree::Node, nil]
|
@@ -15,7 +15,7 @@ module HamlLint::Tree
|
|
15
15
|
# @param line [Integer] the line number of the node
|
16
16
|
# @return [HamlLint::Node]
|
17
17
|
def node_for_line(line)
|
18
|
-
find(-> { HamlLint::Tree::NullNode.new }) { |node| node.line
|
18
|
+
find(-> { HamlLint::Tree::NullNode.new }) { |node| node.line_numbers.cover?(line) }
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/lib/haml_lint/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.23.
|
4
|
+
version: 0.23.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: 2017-03-
|
12
|
+
date: 2017-03-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml
|