# 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