Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def autocorrect(processed_source, offense)
private

def banned_text?(text)
BANNED_GENERIC_TEXT.map(&:downcase).include?(text.downcase)
BANNED_GENERIC_TEXT.map(&:downcase).include?(text.downcase.gsub(/\W+/, " ").strip)
end

def valid_accessible_name?(aria_label, text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ def test_warns_when_link_text_is_link
refute_empty @linter.offenses
end

def test_warns_when_link_text_is_banned_text_with_punctuation_and_space
@file = <<~ERB
<a>Learn more!</a>
<a> read more.</a>
<a>click here.</a>
ERB
@linter.run(processed_source)

refute_empty @linter.offenses
# 3 offenses, 1 related to matching counter comment not present despite violations
assert_equal 4, @linter.offenses.count
end

def test_does_not_warn_when_banned_text_is_part_of_more_text
@file = "<a>Learn more about GitHub Stars</a>"
@linter.run(processed_source)
Expand Down