haml_lint 0.61.1 → 0.62.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61b19bf998b26f91fc8ea0578a3e189b8edb1d3c31a942c873e1e895747bcd82
4
- data.tar.gz: 66b19273123ec6618faade749c390ded3e5ccdb608e2f64b43a4def9f575a298
3
+ metadata.gz: 3754327462146047a8677d8e91b7d47e3d538f2459f2d3ebd583ad2dafc92c3b
4
+ data.tar.gz: 33ccb58e67c32798c90da242cc8708e763f93a1509c6083d54b351453f587a5f
5
5
  SHA512:
6
- metadata.gz: c279dc5f30fa736cfac959aedfd8dec1bf7e5e25b1a0508989ce1276afa5d8b4ddd802f9a139ab48b773a1a0e4d9f9bd91e599cf63700e3eea383cbfa7407bc4
7
- data.tar.gz: 88a18703c06bcc0b95e0072d3ca0e3970302d7807bba29bcb05d2ad8f43dcbf184d76015dc13924d41e7acfcd36762cd6c0eefe3e46d58eae4d26dd8ef2cae2a
6
+ metadata.gz: 8a9ece6eda4dac35772948661486fc6c4fada9d3071b8b4ff52d37bab8930d032d0138a95f59a1a54c760951001010102317965e11aea2fd6dec4a35c7528aac
7
+ data.tar.gz: 67d13e3d045dd804f7f93c662dd8dfb833ac8104a2c52bd1699ba9201861630e686228de725ede55d469a9b3c15a02fcf0b910b843c3d425314e59721ae01ba0
@@ -14,12 +14,16 @@ module HamlLint
14
14
  def visit_root(root)
15
15
  return unless enabled?(root)
16
16
 
17
- first_child = root.children.first
18
- return if first_child.is_a?(HamlLint::Tree::HamlCommentNode) &&
19
- first_child.is_strict_locals?
17
+ # Rails technically allows the comment to be anywhere in the file,
18
+ # but as a best practice they should be at the top of the file.
19
+ # https://guides.rubyonrails.org/action_view_overview.html#strict-locals
20
+ # https://github.com/rails/rails/blob/v8.0.2/actionview/lib/action_view/template.rb#L368
21
+ found =
22
+ root.children
23
+ .take_while { |child| child.is_a?(HamlLint::Tree::HamlCommentNode) }
24
+ .any?(&:is_strict_locals?)
20
25
 
21
- # Check whether this linter is disabled by a comment
22
- return if first_child.disabled?(self)
26
+ return if found
23
27
 
24
28
  record_lint(DummyNode.new(1), failure_message)
25
29
  end
@@ -31,7 +35,11 @@ module HamlLint
31
35
  # @api private
32
36
  # @return [true, false]
33
37
  def enabled?(root)
34
- matcher.match(File.basename(root.file)) ? true : false
38
+ return false unless matcher.match(File.basename(root.file))
39
+
40
+ # This linter can also be disabled by a comment at the top of the file
41
+ first_child = root.children.first
42
+ first_child.nil? || !first_child.disabled?(self)
35
43
  end
36
44
 
37
45
  # The type of files the linter is configured to check.
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module HamlLint
5
- VERSION = '0.61.1'
5
+ VERSION = '0.62.0'
6
6
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.61.1
4
+ version: 0.62.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-20 00:00:00.000000000 Z
10
+ date: 2025-04-08 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: haml