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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 398ba6aea803c2ccd2cb94f71cc64b376b349d0a
4
- data.tar.gz: a9718d142545be1f4b1dbb74cba9e4e6c8b68a02
3
+ metadata.gz: cf21b69028eb0a691d60eaad90bdab27b7a52829
4
+ data.tar.gz: 58a24369859f1384180c1e928b672417abebac94
5
5
  SHA512:
6
- metadata.gz: 1d7d1a80c77be94d7caf19ae80035aca983571d57e5c74b7b6e127cb51ed7b3c0fdbff7406a3d71e052501d9a717cf338250af87041205e9f6c8ff865f09ad18
7
- data.tar.gz: 55aaaad3b2112e3e94e1ca24f955b851168a47b556bae2f3398d3ce24ca8cb825350e5795189966ddb656a801252a2adc56019dbf38ab6934665b198761a8738
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
@@ -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
- .map do |line|
171
+ .map do |line|
172
172
  line.strip.gsub(/\|\z/, '').rstrip
173
173
  end.join(' ')
174
174
  end
@@ -43,7 +43,9 @@ module HamlLint
43
43
  location: {
44
44
  line: offense.line,
45
45
  },
46
- }
46
+ }.tap do |h|
47
+ h[:linter_name] = offense.linter.name if offense.linter
48
+ end
47
49
  end
48
50
  end
49
51
  end
@@ -108,6 +108,10 @@ module HamlLint
108
108
  end
109
109
  end
110
110
 
111
+ def visit_haml_comment(node)
112
+ add_line("##{node.text}", node)
113
+ end
114
+
111
115
  def visit_silent_script(node, &block)
112
116
  visit_script(node, &block)
113
117
  end
@@ -55,8 +55,8 @@ module HamlLint::Tree
55
55
  end
56
56
 
57
57
  @document.source_lines[@line - 1...next_node_line]
58
- .join("\n")
59
- .gsub(/^\s*\z/m, '') # Remove blank lines at the end
58
+ .join("\n")
59
+ .gsub(/^\s*\z/m, '') # Remove blank lines at the end
60
60
  end
61
61
 
62
62
  def inspect
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module HamlLint
5
- VERSION = '0.17.1'.freeze
5
+ VERSION = '0.18.0'.freeze
6
6
  end
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.17.1
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-04-07 00:00:00.000000000 Z
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.4.5.1
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: