haml_lint 0.61.0 → 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: 62ac7e2f95151a5906ccd99c47f5d948db8502aedf5423fa421666e90922d79e
4
- data.tar.gz: 39f4f0952d37d191662215f919a1ee62bf38a4a9f93b4b5ad87545f334a97f6b
3
+ metadata.gz: 3754327462146047a8677d8e91b7d47e3d538f2459f2d3ebd583ad2dafc92c3b
4
+ data.tar.gz: 33ccb58e67c32798c90da242cc8708e763f93a1509c6083d54b351453f587a5f
5
5
  SHA512:
6
- metadata.gz: 21bdfc9e4ac041b44dbf6ca6d1ceca373f54d210c5c6035bc9e47ff0be3c772a4fcbfcbd4b3fe0131facb3e42a816d9a8d7dbae824bf66198a3453daff8c865a
7
- data.tar.gz: 2a459e90165257a12086205ff8bad69dd39845873e7d95888788f56b538be330f69bca13deb3c993ae77d05e7f8c43586db3be737a9d3af178adcc2919a6f9fd
6
+ metadata.gz: 8a9ece6eda4dac35772948661486fc6c4fada9d3071b8b4ff52d37bab8930d032d0138a95f59a1a54c760951001010102317965e11aea2fd6dec4a35c7528aac
7
+ data.tar.gz: 67d13e3d045dd804f7f93c662dd8dfb833ac8104a2c52bd1699ba9201861630e686228de725ede55d469a9b3c15a02fcf0b910b843c3d425314e59721ae01ba0
@@ -14,9 +14,16 @@ module HamlLint
14
14
  def visit_root(root)
15
15
  return unless enabled?(root)
16
16
 
17
- first_children = root.children.first
18
- return if first_children.is_a?(HamlLint::Tree::HamlCommentNode) &&
19
- first_children.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?)
25
+
26
+ return if found
20
27
 
21
28
  record_lint(DummyNode.new(1), failure_message)
22
29
  end
@@ -28,7 +35,11 @@ module HamlLint
28
35
  # @api private
29
36
  # @return [true, false]
30
37
  def enabled?(root)
31
- 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)
32
43
  end
33
44
 
34
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.0'
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.0
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-02-24 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