Method: ERBLint::Linters::FlashMigrationCounter#map_arguments
- Defined in:
- lib/primer/view_components/linters/flash_migration_counter.rb
#map_arguments(tag, tag_tree) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/primer/view_components/linters/flash_migration_counter.rb', line 19 def map_arguments(tag, tag_tree) # We can only autocorrect elements with simple text as content. return nil if tag_tree[:children].size != 1 # Hash children indicates that there are tags in the content. return nil if tag_tree[:children].first.is_a?(Hash) content = tag_tree[:children].first # Don't accept content with ERB blocks return nil if content.type != :text || content.children&.any? { |n| n.try(:type) == :erb } ARGUMENT_MAPPER.new(tag).to_s rescue ArgumentMappers::ConversionError nil end |