haml_lint 0.17.1 → 0.18.0
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/linter/classes_before_ids.rb +16 -2
- data/lib/haml_lint/linter/rubocop.rb +1 -1
- data/lib/haml_lint/linter.rb +1 -1
- data/lib/haml_lint/reporter/json_reporter.rb +3 -1
- data/lib/haml_lint/ruby_extractor.rb +4 -0
- data/lib/haml_lint/tree/node.rb +2 -2
- data/lib/haml_lint/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf21b69028eb0a691d60eaad90bdab27b7a52829
|
4
|
+
data.tar.gz: 58a24369859f1384180c1e928b672417abebac94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf10d59ef201f50b68daa5328fef0df54f2cd455e1c82779355f13bffff833dc3b35770719785460c3cf10d7b517e16ec4d6b61ffb23df560b59597666788ea3
|
7
|
+
data.tar.gz: ad94abfd0a1c776e86ffdf3a1ac271323ab519a5a62e38adc01ad22632b32f0f0a0c6548d74bcb2795c72ac47556ec316a128beb39fb3e18286f42ae0c50ca4a
|
@@ -13,14 +13,28 @@ module HamlLint
|
|
13
13
|
# Convert ".class#id" into [.class, #id] (preserving order)
|
14
14
|
components = node.static_attributes_source.scan(/[.#][^.#]+/)
|
15
15
|
|
16
|
+
first, second = attribute_prefix_order
|
17
|
+
|
16
18
|
(1...components.count).each do |index|
|
17
|
-
next unless components[index].start_with?(
|
18
|
-
components[index - 1].start_with?(
|
19
|
+
next unless components[index].start_with?(first) &&
|
20
|
+
components[index - 1].start_with?(second)
|
19
21
|
|
20
22
|
record_lint(node, 'Classes should be listed before IDs '\
|
21
23
|
"(#{components[index]} should precede #{components[index - 1]})")
|
22
24
|
break
|
23
25
|
end
|
24
26
|
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def attribute_prefix_order
|
31
|
+
enforced_style = config.fetch('EnforcedStyle', 'class')
|
32
|
+
case enforced_style
|
33
|
+
when 'id'
|
34
|
+
['#', '.']
|
35
|
+
else
|
36
|
+
['.', '#']
|
37
|
+
end
|
38
|
+
end
|
25
39
|
end
|
26
40
|
end
|
@@ -60,7 +60,7 @@ module HamlLint
|
|
60
60
|
def extract_lints_from_offenses(offenses, source_map)
|
61
61
|
dummy_node = Struct.new(:line)
|
62
62
|
|
63
|
-
offenses.select { |offense| !config['ignored_cops'].include?(offense.cop_name) }
|
63
|
+
offenses.select { |offense| !Array(config['ignored_cops']).include?(offense.cop_name) }
|
64
64
|
.each do |offense|
|
65
65
|
record_lint(dummy_node.new(source_map[offense.line]), offense.message)
|
66
66
|
end
|
data/lib/haml_lint/linter.rb
CHANGED
@@ -168,7 +168,7 @@ module HamlLint
|
|
168
168
|
# Normalize each of the lines to ignore the multiline bar (|) and
|
169
169
|
# excess whitespace
|
170
170
|
@document.source_lines[(tag_node.line - 1)...(following_node_line(tag_node) - 1)]
|
171
|
-
|
171
|
+
.map do |line|
|
172
172
|
line.strip.gsub(/\|\z/, '').rstrip
|
173
173
|
end.join(' ')
|
174
174
|
end
|
data/lib/haml_lint/tree/node.rb
CHANGED
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.
|
4
|
+
version: 0.18.0
|
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: 2016-
|
12
|
+
date: 2016-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml
|
@@ -165,8 +165,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
167
|
rubyforge_project:
|
168
|
-
rubygems_version: 2.
|
168
|
+
rubygems_version: 2.5.1
|
169
169
|
signing_key:
|
170
170
|
specification_version: 4
|
171
171
|
summary: HAML lint tool
|
172
172
|
test_files: []
|
173
|
+
has_rdoc:
|