Sha256: 3356ac7f275340443d3545178c5312ddc82c65a8354a190be71edd95334df8e4
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true require "rubocop" # :nocov: module RuboCop module Cop module Primer # This cop ensures that components don't use deprecated component names # # bad # Primer::ComponentNameComponent.new() # # good # Primer::Beta::ComponentName.new() class ComponentNameMigration < BaseCop DEPRECATIONS = { "Primer::BoxComponent" => "Primer::Box", "Primer::ButtonGroup" => "Primer::Beta::ButtonGroup", "Primer::BlankslateComponent" => "Primer::Beta::Blankslate", "Primer::BorderBoxComponent" => "Primer::Beta::BorderBox", "Primer::BaseButton" => "Primer::Beta::BaseButton", "Primer::TestComponent" => "Primer::Beta::Test" }.freeze def on_send(node) return unless node.method_name == :new && !node.receiver.nil? && DEPRECATIONS.key?(node.receiver.const_name) add_offense(node.receiver, message: "Don't use deprecated names") end def autocorrect(node) lambda do |corrector| corrector.replace(node, DEPRECATIONS[node.const_name]) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
primer_view_components-0.0.89 | lib/rubocop/cop/primer/component_name_migration.rb |
primer_view_components-0.0.88 | lib/rubocop/cop/primer/component_name_migration.rb |