Sha256: 1714090a3df096cd188bbf1f28b086dac8e534cf5e79987ad7c942b3aa4acf0a
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true require "rubocop" require "yattho/deprecations" # :nocov: module RuboCop module Cop module Yattho # This cop ensures that components don't use deprecated component names # # bad # Yattho::ComponentNameComponent.new() # # good # Yattho::Beta::ComponentName.new() class ComponentNameMigration < BaseCop def on_send(node) return unless node.method_name == :new && !node.receiver.nil? && ::Yattho::Deprecations.deprecated?(node.receiver.const_name) message = ::Yattho::Deprecations.deprecation_message(node.receiver.const_name) add_offense(node.receiver, message: message) end def autocorrect(node) lambda do |corrector| component_name = node.const_name return unless ::Yattho::Deprecations.correctable?(component_name) replacement = ::Yattho::Deprecations.replacement(component_name) corrector.replace(node, replacement) if replacement.present? end 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/component_name_migration.rb |
yattho_view_components-0.0.1 | lib/rubocop/cop/yattho/component_name_migration.rb |