Skip to content

Commit 3a80817

Browse files
committed
add disable rule test
1 parent 3e3f59d commit 3a80817

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/erblint-github/linters/custom_helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def rule_disabled?(processed_source)
1111
indicator_node, _, code_node, = *node
1212
indicator = indicator_node&.loc&.source
1313
comment = code_node&.loc&.source&.strip
14-
rule_name = self.class.name.match(/:?:?(\w+)\Z/)[1]
14+
rule_name = self.class.name.gsub("ERBLint::Linters::", "")
1515

1616
if indicator == "#" && comment.start_with?("erblint:disable") && comment.match(rule_name)
1717
if @offenses.any?

test/linters/accessibility/no_redundant_image_alt_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,14 @@ def test_does_not_warn_if_alt_contains_no_redundant_text
2828

2929
assert_empty @linter.offenses
3030
end
31+
32+
def test_does_not_warn_if_linter_is_disabled_in_file
33+
@file = <<~HTML
34+
<%# erblint:disable GitHub::Accessibility::NoRedundantImageAlt %>
35+
<img alt='image of an octopus'></img>
36+
HTML
37+
38+
@linter.run(processed_source)
39+
assert_empty @linter.offenses
40+
end
3141
end

0 commit comments

Comments
 (0)