haml_lint 0.60.0 → 0.61.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 +4 -4
- data/config/default.yml +7 -0
- data/lib/haml_lint/linter/strict_locals.rb +58 -0
- data/lib/haml_lint/tree/haml_comment_node.rb +7 -0
- data/lib/haml_lint/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62ac7e2f95151a5906ccd99c47f5d948db8502aedf5423fa421666e90922d79e
|
4
|
+
data.tar.gz: 39f4f0952d37d191662215f919a1ee62bf38a4a9f93b4b5ad87545f334a97f6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21bdfc9e4ac041b44dbf6ca6d1ceca373f54d210c5c6035bc9e47ff0be3c772a4fcbfcbd4b3fe0131facb3e42a816d9a8d7dbae824bf66198a3453daff8c865a
|
7
|
+
data.tar.gz: 2a459e90165257a12086205ff8bad69dd39845873e7d95888788f56b538be330f69bca13deb3c993ae77d05e7f8c43586db3be737a9d3af178adcc2919a6f9fd
|
data/config/default.yml
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HamlLint
|
4
|
+
# Checks for the presence of a `locals` magic comment at the beginning of a partial.
|
5
|
+
class Linter::StrictLocals < Linter
|
6
|
+
include LinterRegistry
|
7
|
+
|
8
|
+
DummyNode = Struct.new(:line)
|
9
|
+
|
10
|
+
# Enables the linter if the tree is for the right file type.
|
11
|
+
#
|
12
|
+
# @param [HamlLint::Tree::RootNode] the root of a syntax tree
|
13
|
+
# @return [true, false] whether the linter is enabled for the tree
|
14
|
+
def visit_root(root)
|
15
|
+
return unless enabled?(root)
|
16
|
+
|
17
|
+
first_children = root.children.first
|
18
|
+
return if first_children.is_a?(HamlLint::Tree::HamlCommentNode) &&
|
19
|
+
first_children.is_strict_locals?
|
20
|
+
|
21
|
+
record_lint(DummyNode.new(1), failure_message)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# Checks whether the linter is enabled for the file.
|
27
|
+
#
|
28
|
+
# @api private
|
29
|
+
# @return [true, false]
|
30
|
+
def enabled?(root)
|
31
|
+
matcher.match(File.basename(root.file)) ? true : false
|
32
|
+
end
|
33
|
+
|
34
|
+
# The type of files the linter is configured to check.
|
35
|
+
#
|
36
|
+
# @api private
|
37
|
+
# @return [String]
|
38
|
+
def file_types
|
39
|
+
@file_types ||= config['file_types'] || 'partial'
|
40
|
+
end
|
41
|
+
|
42
|
+
# The matcher to use for testing whether to check a file by file name.
|
43
|
+
#
|
44
|
+
# @api private
|
45
|
+
# @return [Regexp]
|
46
|
+
def matcher
|
47
|
+
@matcher ||= Regexp.new(config['matchers'][file_types] || '\A_.*\.haml\z')
|
48
|
+
end
|
49
|
+
|
50
|
+
# The error message when an `locals` comment is not found.
|
51
|
+
#
|
52
|
+
# @api private
|
53
|
+
# @return [String]
|
54
|
+
def failure_message
|
55
|
+
'Expected a strict `-# locals: ()` comment at the beginning of the file'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -25,6 +25,13 @@ module HamlLint::Tree
|
|
25
25
|
.rstrip
|
26
26
|
end
|
27
27
|
|
28
|
+
# Returns whether this comment contains a `locals` directive.
|
29
|
+
#
|
30
|
+
# @return [Boolean]
|
31
|
+
def is_strict_locals?
|
32
|
+
text.lstrip.start_with?('locals:')
|
33
|
+
end
|
34
|
+
|
28
35
|
private
|
29
36
|
|
30
37
|
def contained_directives
|
data/lib/haml_lint/version.rb
CHANGED
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.
|
4
|
+
version: 0.61.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-02-24 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: haml
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- lib/haml_lint/linter/ruby_comments.rb
|
134
134
|
- lib/haml_lint/linter/space_before_script.rb
|
135
135
|
- lib/haml_lint/linter/space_inside_hash_attributes.rb
|
136
|
+
- lib/haml_lint/linter/strict_locals.rb
|
136
137
|
- lib/haml_lint/linter/syntax.rb
|
137
138
|
- lib/haml_lint/linter/tag_name.rb
|
138
139
|
- lib/haml_lint/linter/trailing_empty_lines.rb
|