Module: ERBLint::Linters::Autocorrectable
- Included in:
 - ButtonComponentMigrationCounter, ClipboardCopyComponentMigrationCounter, CloseButtonComponentMigrationCounter, FlashMigrationCounter, LabelComponentMigrationCounter
 
- Defined in:
 - lib/primer/view_components/linters/autocorrectable.rb
 
Overview
Provides the autocorrection functionality for the linter. Once included, you should define the following constants:
- 
‘ARGUMENT_MAPPER` - required - The class responsible for transforming classes and attributes into arguments for the component.
 - 
‘COMPONENT` - required - The component name for the linter. It will be used to generate the correction.
 
Instance Method Summary collapse
- #correction(args) ⇒ Object
 - #map_arguments(tag, _tag_tree) ⇒ Object
 - #message(args, processed_source) ⇒ Object
 
Instance Method Details
#correction(args) ⇒ Object
      17 18 19 20 21 22 23  | 
    
      # 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) ⇒ Object
      11 12 13 14 15  | 
    
      # 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) ⇒ Object
      25 26 27 28 29  | 
    
      # File 'lib/primer/view_components/linters/autocorrectable.rb', line 25 def (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  |