Sha256: 0a6890f0bd3ebb0cb8d4b9a335ce03a8843d118834803f9f43d88ee4e5f9c4bb

Contents?: true

Size: 735 Bytes

Versions: 188

Compression:

Stored size: 735 Bytes

Contents

# frozen_string_literal: true

require "rubocop"

module RuboCop
  module Cop
    module Primer
      # This cop ensures that the deprecated `Primer::LayoutComponent` isn't used.
      #
      # bad
      # Primer::LayoutComponent.new(foo: :deprecated)
      #
      # good
      # Primer::Alpha::Layout.new(foo: :deprecated)
      class DeprecatedLayoutComponent < BaseCop
        MSG = "Please try Primer::Alpha::Layout instead."

        def_node_matcher :legacy_component?, <<~PATTERN
          (send (const (const nil? :Primer) :LayoutComponent) :new ...)
        PATTERN

        def on_send(node)
          return unless legacy_component?(node)

          add_offense(node, message: MSG)
        end
      end
    end
  end
end

Version data entries

188 entries across 188 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.49.2 lib/rubocop/cop/primer/deprecated_layout_component.rb
primer_view_components-0.35.2 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.49.1 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.49.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
primer_view_components-0.35.1 lib/rubocop/cop/primer/deprecated_layout_component.rb
primer_view_components-0.35.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.48.2 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.48.1 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.48.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.47.1 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.47.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
primer_view_components-0.34.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.46.1 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.46.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.45.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.44.3 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.44.2 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.44.1 lib/rubocop/cop/primer/deprecated_layout_component.rb
primer_view_components-0.33.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.44.0 lib/rubocop/cop/primer/deprecated_layout_component.rb