Skip to content

Commit b650344

Browse files
authoredOct 21, 2024··
Update details_menu_migration linter config (#3139)
1 parent 683abd2 commit b650344

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed
 

‎.changeset/new-nails-walk.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/view-components': patch
3+
---
4+
5+
Adjusts config for DetailsMenuMigration linter to take in an array of strings instead of array of regexp

‎lib/primer/view_components/linters/details_menu_migration.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class DetailsMenuMigration < Linter
1616

1717
# Allow custom pattern matching for ERB nodes
1818
class ConfigSchema < LinterConfig
19-
property :custom_erb_pattern, accepts: array_of?(Regexp),
19+
property :custom_erb_pattern, accepts: array_of?(String),
2020
default: -> { [] }
2121
end
2222
self.config_schema = ConfigSchema
@@ -51,7 +51,8 @@ def custom_erb_pattern
5151
if @config.custom_erb_pattern.empty?
5252
nil
5353
else
54-
Regexp.new(@config.custom_erb_pattern.join("|"), true)
54+
regexes = @config.custom_erb_pattern.map { |pattern| Regexp.new(pattern, true) }
55+
Regexp.new(regexes.join("|"), true)
5556
end
5657
end
5758

‎test/lib/erblint/details_menu_migration_test.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def test_does_not_warn_if_inline_disable_comment
5454
end
5555

5656
def test_accepts_custom_regex_pattern
57-
@linter.config.custom_erb_pattern = [/render[\s\(]GitHub::MenuComponent/]
57+
@linter.config.custom_erb_pattern = ["render[\s\(]GitHub::MenuComponent"]
58+
5859
@file = <<~HTML
5960
<%= render GitHub::MenuComponent.new do %>
6061
HTML
@@ -64,7 +65,8 @@ def test_accepts_custom_regex_pattern
6465
end
6566

6667
def test_accepts_multiple_custom_regex_pattern
67-
@linter.config.custom_erb_pattern = [/render[\s\(]GitHub::MenuComponent/, /SomeOtherComponent/]
68+
@linter.config.custom_erb_pattern = ["render[\s\(]GitHub::MenuComponent", "SomeOtherComponent"]
69+
6870
@file = <<~HTML
6971
<%= render GitHub::MenuComponent.new do %>
7072
<% end %>

0 commit comments

Comments
 (0)
Please sign in to comment.