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.43.1 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.43.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
primer_view_components-0.32.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.42.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
primer_view_components-0.31.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.41.1 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.41.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.40.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
primer_view_components-0.30.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.39.1 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.39.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.38.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
primer_view_components-0.29.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
primer_view_components-0.28.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.37.1 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.37.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.36.2 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.36.1 lib/rubocop/cop/primer/deprecated_layout_component.rb
openproject-primer_view_components-0.36.0 lib/rubocop/cop/primer/deprecated_layout_component.rb
primer_view_components-0.27.0 lib/rubocop/cop/primer/deprecated_layout_component.rb