Sha256: 3af5b684e9adf4c5caf45751e3813b5095d483e759fdb10e95d77378c0183c87

Contents?: true

Size: 735 Bytes

Versions: 2

Compression:

Stored size: 735 Bytes

Contents

# frozen_string_literal: true

require "rubocop"

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

        def_node_matcher :legacy_component?, <<~PATTERN
          (send (const (const nil? :Yattho) :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

2 entries across 2 versions & 1 rubygems

Version Path
yattho_view_components-0.1.1 lib/rubocop/cop/yattho/deprecated_layout_component.rb
yattho_view_components-0.0.1 lib/rubocop/cop/yattho/deprecated_layout_component.rb