Class: ERBLint::Linters::Primer::Accessibility::TooltippedMigration
- Inherits:
-
Linter
- Object
- Linter
- ERBLint::Linters::Primer::Accessibility::TooltippedMigration
- Includes:
- Helpers::RuleHelpers, LinterRegistry
- Defined in:
- lib/primer/view_components/linters/tooltipped_migration.rb
Overview
Flag when ‘.tooltipped` is being used and offer alternatives.
Constant Summary collapse
- MIGRATE_TO_NEWER_TOOLTIP =
".tooltipped has been deprecated. Due to major accessibility concerns with using this tooltip, please migrate to a Primer Tooltip component or rework the design to eliminate the tooltip. See https://primer.style/guides/rails/migration-guides/primer-css-tooltipped."
- TOOLTIPPED_RUBY_PATTERN =
/classes:.*tooltipped|class:.*tooltipped/.freeze
Instance Method Summary collapse
Methods included from Helpers::RuleHelpers
#erb_nodes, #extract_ruby_from_erb_node, #generate_node_offense, #generate_offense, #tags
Instance Method Details
#run(processed_source) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/primer/view_components/linters/tooltipped_migration.rb', line 16 def run(processed_source) # HTML tags (processed_source).each do |tag| next if tag.closing? classes = tag.attributes["class"]&.value generate_offense(self.class, processed_source, tag, MIGRATE_TO_NEWER_TOOLTIP) if classes&.include?("tooltipped") end # ERB nodes erb_nodes(processed_source).each do |node| code = extract_ruby_from_erb_node(node) generate_node_offense(self.class, processed_source, node, MIGRATE_TO_NEWER_TOOLTIP) if code.match?(TOOLTIPPED_RUBY_PATTERN) end end |