Class: RuboCop::Cop::Yattho::DeprecatedComponents

Inherits:
BaseCop
  • Object
show all
Includes:
ERBLint::Linters::Helpers::DeprecatedComponentsHelpers
Defined in:
lib/rubocop/cop/yattho/deprecated_components.rb

Overview

This cop ensures that components marked as “deprecated” in ‘static/statuses.json` are discouraged from use.

bad Yattho::BlankslateComponent.new(:foo)

good Yattho::Beta::Blankslate.new(:foo)

bad Yattho::Tooltip.new(:foo)

good Yattho::Alpha::Tooltip.new(:foo)

Instance Method Summary collapse

Methods included from ERBLint::Linters::Helpers::DeprecatedComponentsHelpers

#deprecated_components, #message

Methods inherited from BaseCop

#valid_node?

Instance Method Details

#on_send(node) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/rubocop/cop/yattho/deprecated_components.rb', line 27

def on_send(node)
  return unless node.source.include?("Yattho::")

  deprecated_components.each do |component|
    pattern = NodePattern.new("(send #{pattern(component)} :new ...)")
    add_offense(node, message: message(component)) if pattern.match(node)
  end
end