From b6503447d255dc8d86128e30136ea9e18436760a Mon Sep 17 00:00:00 2001 From: Jamie Shark <5520141+jamieshark@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:17:39 -0500 Subject: [PATCH] Update details_menu_migration linter config (#3139) --- .changeset/new-nails-walk.md | 5 +++++ .../view_components/linters/details_menu_migration.rb | 5 +++-- test/lib/erblint/details_menu_migration_test.rb | 6 ++++-- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 .changeset/new-nails-walk.md diff --git a/.changeset/new-nails-walk.md b/.changeset/new-nails-walk.md new file mode 100644 index 0000000000..549ddd23d6 --- /dev/null +++ b/.changeset/new-nails-walk.md @@ -0,0 +1,5 @@ +--- +'@primer/view-components': patch +--- + +Adjusts config for DetailsMenuMigration linter to take in an array of strings instead of array of regexp diff --git a/lib/primer/view_components/linters/details_menu_migration.rb b/lib/primer/view_components/linters/details_menu_migration.rb index 2ae7d6de28..e54cf7bdb0 100644 --- a/lib/primer/view_components/linters/details_menu_migration.rb +++ b/lib/primer/view_components/linters/details_menu_migration.rb @@ -16,7 +16,7 @@ class DetailsMenuMigration < Linter # Allow custom pattern matching for ERB nodes class ConfigSchema < LinterConfig - property :custom_erb_pattern, accepts: array_of?(Regexp), + property :custom_erb_pattern, accepts: array_of?(String), default: -> { [] } end self.config_schema = ConfigSchema @@ -51,7 +51,8 @@ def custom_erb_pattern if @config.custom_erb_pattern.empty? nil else - Regexp.new(@config.custom_erb_pattern.join("|"), true) + regexes = @config.custom_erb_pattern.map { |pattern| Regexp.new(pattern, true) } + Regexp.new(regexes.join("|"), true) end end diff --git a/test/lib/erblint/details_menu_migration_test.rb b/test/lib/erblint/details_menu_migration_test.rb index 9b2cb48993..c510763995 100644 --- a/test/lib/erblint/details_menu_migration_test.rb +++ b/test/lib/erblint/details_menu_migration_test.rb @@ -54,7 +54,8 @@ def test_does_not_warn_if_inline_disable_comment end def test_accepts_custom_regex_pattern - @linter.config.custom_erb_pattern = [/render[\s\(]GitHub::MenuComponent/] + @linter.config.custom_erb_pattern = ["render[\s\(]GitHub::MenuComponent"] + @file = <<~HTML <%= render GitHub::MenuComponent.new do %> HTML @@ -64,7 +65,8 @@ def test_accepts_custom_regex_pattern end def test_accepts_multiple_custom_regex_pattern - @linter.config.custom_erb_pattern = [/render[\s\(]GitHub::MenuComponent/, /SomeOtherComponent/] + @linter.config.custom_erb_pattern = ["render[\s\(]GitHub::MenuComponent", "SomeOtherComponent"] + @file = <<~HTML <%= render GitHub::MenuComponent.new do %> <% end %>