Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update details_menu_migration linter config #3139

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/new-nails-walk.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions test/lib/erblint/details_menu_migration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 %>
Expand Down
Loading