From 32b281c6cd5359cbee00c2abde79f42b3c720a31 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Tue, 18 Jul 2023 15:14:19 +0100 Subject: [PATCH] point Primer namespace to root This resolves an Uninitialized Constant error coming from ruby, because `ERBLint::Linter::Primer::` is a namespace that exists. This error was not invoked before because the only liner in that namespace - `ERBLint::Linter::Primer::Accessibility::TooltippedMigration` in the `tooltipped_migration.rb` file - would load _after_ `argument_mappers/label.rb` and `label_component_migration_counter.rb`. The introduction of `ERBLint::Linter::Primer::Accessibility::DetailsMenuMigration` in the `details_menu_migration.rb` file would load _before_ `label_component_migration_counter.rb`, populating the `ERBLint::Linter::Primer` namespace, which then causes the failed scope lookup. Prepending `::` to these values tells ruby to always look in the root scope, not any local constants. --- .../view_components/linters/argument_mappers/label.rb | 8 ++++---- .../linters/label_component_migration_counter.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/primer/view_components/linters/argument_mappers/label.rb b/lib/primer/view_components/linters/argument_mappers/label.rb index a97c2d5cc6..97864d4e7f 100644 --- a/lib/primer/view_components/linters/argument_mappers/label.rb +++ b/lib/primer/view_components/linters/argument_mappers/label.rb @@ -7,24 +7,24 @@ module Linters module ArgumentMappers # Maps classes in a label element to arguments for the Label component. class Label < Base - SCHEME_MAPPINGS = Primer::ViewComponents::Constants.get( + SCHEME_MAPPINGS = ::Primer::ViewComponents::Constants.get( component: "Primer::Beta::Label", constant: "SCHEME_MAPPINGS", symbolize: true ).freeze - SIZE_MAPPINGS = Primer::ViewComponents::Constants.get( + SIZE_MAPPINGS = ::Primer::ViewComponents::Constants.get( component: "Primer::Beta::Label", constant: "SIZE_MAPPINGS", symbolize: true ).freeze - DEFAULT_TAG = Primer::ViewComponents::Constants.get( + DEFAULT_TAG = ::Primer::ViewComponents::Constants.get( component: "Primer::Beta::Label", constant: "DEFAULT_TAG" ).freeze - INLINE_CLASS = Primer::ViewComponents::Constants.get( + INLINE_CLASS = ::Primer::ViewComponents::Constants.get( component: "Primer::Beta::Label", constant: "INLINE_CLASS" ).freeze diff --git a/lib/primer/view_components/linters/label_component_migration_counter.rb b/lib/primer/view_components/linters/label_component_migration_counter.rb index 50662d2c0c..579e2eb4d1 100644 --- a/lib/primer/view_components/linters/label_component_migration_counter.rb +++ b/lib/primer/view_components/linters/label_component_migration_counter.rb @@ -10,7 +10,7 @@ module Linters class LabelComponentMigrationCounter < BaseLinter include Autocorrectable - TAGS = Primer::ViewComponents::Constants.get( + TAGS = ::Primer::ViewComponents::Constants.get( component: "Primer::Beta::Label", constant: "TAG_OPTIONS" ).freeze