module ERBLint::Linters::Autocorrectable

Provides the autocorrection functionality for the linter. Once included, you should define the following constants:

Public Instance Methods

correction(args) click to toggle source
# File lib/primer/view_components/linters/autocorrectable.rb, line 17
def correction(args)
  return nil if args.nil?

  correction = "<%= render #{self.class::COMPONENT}.new"
  correction += "(#{args})" if args.present?
  "#{correction} do %>"
end
map_arguments(tag, _tag_tree) click to toggle source
# File lib/primer/view_components/linters/autocorrectable.rb, line 11
def map_arguments(tag, _tag_tree)
  self.class::ARGUMENT_MAPPER.new(tag).to_s
rescue ArgumentMappers::ConversionError
  nil
end
message(args, processed_source) click to toggle source
# File lib/primer/view_components/linters/autocorrectable.rb, line 25
def message(args, processed_source)
  return self.class::MESSAGE if args.nil?

  "#{self.class::MESSAGE}\nTry using:\n\n#{correction(args)}\n\nYou can also run erblint in autocorrect mode:\n\nbundle exec erblint -a #{processed_source.filename}\n"
end