Sha256: 29da327c8fe9ec320ff6f1cb0cfad6c5d56a9ce54d4cc153713bb72a4c5bb7a1

Contents?: true

Size: 1.31 KB

Versions: 52

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require_relative "helpers/rule_helpers"
module ERBLint
  module Linters
    module Primer
      module Accessibility
        # Flag when `.tooltipped` is being used and offer alternatives.
        class TooltippedMigration < Linter
          include LinterRegistry
          include Helpers::RuleHelpers

          MIGRATE_TO_NEWER_TOOLTIP = ".tooltipped has been deprecated. There are major accessibility concerns with using this tooltip so please take action. See https://primer.style/guides/rails/migration-guides/primer-css-tooltipped."
          TOOLTIPPED_RUBY_PATTERN = /classes:.*tooltipped|class:.*tooltipped/.freeze

          def run(processed_source)
            # HTML tags
            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
        end
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.34.0 lib/primer/view_components/linters/tooltipped_migration.rb
openproject-primer_view_components-0.33.2 lib/primer/view_components/linters/tooltipped_migration.rb
openproject-primer_view_components-0.33.1 lib/primer/view_components/linters/tooltipped_migration.rb
openproject-primer_view_components-0.33.0 lib/primer/view_components/linters/tooltipped_migration.rb
primer_view_components-0.25.1 lib/primer/view_components/linters/tooltipped_migration.rb
openproject-primer_view_components-0.32.1 lib/primer/view_components/linters/tooltipped_migration.rb
openproject-primer_view_components-0.32.0 lib/primer/view_components/linters/tooltipped_migration.rb
openproject-primer_view_components-0.29.1 lib/primer/view_components/linters/tooltipped_migration.rb
openproject-primer_view_components-0.29.0 lib/primer/view_components/linters/tooltipped_migration.rb
primer_view_components-0.23.0 lib/primer/view_components/linters/tooltipped_migration.rb
openproject-primer_view_components-0.28.1 lib/primer/view_components/linters/tooltipped_migration.rb
openproject-primer_view_components-0.28.0 lib/primer/view_components/linters/tooltipped_migration.rb
openproject-primer_view_components-0.27.0 lib/primer/view_components/linters/tooltipped_migration.rb
openproject-primer_view_components-0.26.0 lib/primer/view_components/linters/tooltipped_migration.rb
openproject-primer_view_components-0.25.1 lib/primer/view_components/linters/tooltipped_migration.rb
primer_view_components-0.22.0 lib/primer/view_components/linters/tooltipped_migration.rb
primer_view_components-0.21.1 lib/primer/view_components/linters/tooltipped_migration.rb
openproject-primer_view_components-0.25.0 lib/primer/view_components/linters/tooltipped_migration.rb
openproject-primer_view_components-0.24.0 lib/primer/view_components/linters/tooltipped_migration.rb
primer_view_components-0.21.0 lib/primer/view_components/linters/tooltipped_migration.rb