Skip to content

Commit 1807ebf

Browse files
committed
Include link to rule docs
1 parent 4a9e2c6 commit 1807ebf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/erblint-github/linters/custom_helpers.rb

Lines changed: 7 additions & 3 deletions
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.gsub("ERBLint::Linters::", "")
14+
rule_name = simple_class_name
1515

1616
if indicator == "#" && comment.start_with?("erblint:disable") && comment.match(rule_name)
1717
if @offenses.any?
@@ -26,8 +26,8 @@ def rule_disabled?(processed_source)
2626

2727
def generate_offense(klass, processed_source, tag, message = nil, replacement = nil)
2828
message ||= klass::MESSAGE
29-
klass_name = klass.name.demodulize
30-
offense = ["#{klass_name}:#{message}", tag.node.loc.source].join("\n")
29+
message += "\nLearn more at https://github.com/github/erblint-github#rules.\n"
30+
offense = ["#{simple_class_name}:#{message}", tag.node.loc.source].join("\n")
3131
add_offense(processed_source.to_source_range(tag.loc), offense, replacement)
3232
end
3333

@@ -45,6 +45,10 @@ def basic_conditional_code_check(code)
4545
def tags(processed_source)
4646
processed_source.parser.nodes_with_type(:tag).map { |tag_node| BetterHtml::Tree::Tag.from_node(tag_node) }
4747
end
48+
49+
def simple_class_name
50+
self.class.name.gsub("ERBLint::Linters::", "")
51+
end
4852
end
4953
end
5054
end

0 commit comments

Comments
 (0)