erblint-github 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/erblint-github/linters/custom_helpers.rb +2 -20
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 241e053b11c2e8e99f2393e5810b8bf9206e9db587a579c7ba20f67575f07874
|
4
|
+
data.tar.gz: 60470f738221eda4e5ee04d230cbdb63f80aa9098e87381cf75b4a6f732c4dbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 267422c819129ea1e6eca8cc66ef95448345f3278cdd2ee036cc04303c8b9ef3628757808c9edc2dae815f30d56b9dceafa10670f0a60b492cb8c1df9e5254cf
|
7
|
+
data.tar.gz: 30566b29367c5991e4e6229c98f85f217467f8cbd7dd15c03a3f8f270c11da6d2439a699e9133f707d0b4a256f38e611a83e32774decbe4f35fa09647fde7d78
|
@@ -8,24 +8,6 @@ module ERBLint
|
|
8
8
|
module CustomHelpers
|
9
9
|
INTERACTIVE_ELEMENTS = %w[button summary input select textarea a].freeze
|
10
10
|
|
11
|
-
def rule_disabled?(processed_source)
|
12
|
-
processed_source.parser.ast.descendants(:erb).each do |node|
|
13
|
-
indicator_node, _, code_node, = *node
|
14
|
-
indicator = indicator_node&.loc&.source
|
15
|
-
comment = code_node&.loc&.source&.strip
|
16
|
-
rule_name = simple_class_name
|
17
|
-
|
18
|
-
if indicator == "#" && comment.start_with?("erblint:disable") && comment.match(rule_name)
|
19
|
-
if @offenses.any?
|
20
|
-
clear_offenses
|
21
|
-
else
|
22
|
-
add_offense(processed_source.to_source_range(code_node.loc),
|
23
|
-
"Unused erblint:disable comment for #{rule_name}")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
11
|
def counter_correct?(processed_source)
|
30
12
|
comment_node = nil
|
31
13
|
expected_count = 0
|
@@ -52,10 +34,10 @@ module ERBLint
|
|
52
34
|
first_offense = @offenses[0]
|
53
35
|
|
54
36
|
if comment_node.nil?
|
55
|
-
add_offense(processed_source.to_source_range(first_offense.source_range), "#{rule_name}: If you must, add <%# erblint:
|
37
|
+
add_offense(processed_source.to_source_range(first_offense.source_range), "#{rule_name}: If you must, add <%# erblint:disable #{rule_name} %> at the end of the offending line to bypass this check. See https://github.com/shopify/erb-lint#disable-rule-at-offense-level", "<%# erblint:disable #{rule_name} %>")
|
56
38
|
else
|
57
39
|
clear_offenses
|
58
|
-
add_offense(processed_source.to_source_range(comment_node.loc), "Incorrect erblint:counter number for #{rule_name}. Expected: #{expected_count}, actual: #{offenses_count}.", "<%# erblint:counter #{rule_name} #{offenses_count} %>") if expected_count != offenses_count
|
40
|
+
add_offense(processed_source.to_source_range(comment_node.loc), "Incorrect erblint:counter number for #{rule_name}. Expected: #{expected_count}, actual: #{offenses_count}.", "<%# erblint:counter #{rule_name}Counter #{offenses_count} %>") if expected_count != offenses_count
|
59
41
|
end
|
60
42
|
end
|
61
43
|
|