File tree 3 files changed +12
-4
lines changed
lib/primer/view_components/linters
3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class DetailsMenuMigration < Linter
16
16
17
17
# Allow custom pattern matching for ERB nodes
18
18
class ConfigSchema < LinterConfig
19
- property :custom_erb_pattern , accepts : array_of? ( Regexp ) ,
19
+ property :custom_erb_pattern , accepts : array_of? ( String ) ,
20
20
default : -> { [ ] }
21
21
end
22
22
self . config_schema = ConfigSchema
@@ -51,7 +51,8 @@ def custom_erb_pattern
51
51
if @config . custom_erb_pattern . empty?
52
52
nil
53
53
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 )
55
56
end
56
57
end
57
58
Original file line number Diff line number Diff line change @@ -54,7 +54,8 @@ def test_does_not_warn_if_inline_disable_comment
54
54
end
55
55
56
56
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
+
58
59
@file = <<~HTML
59
60
< %= render GitHub::MenuComponent.new do %>
60
61
HTML
@@ -64,7 +65,8 @@ def test_accepts_custom_regex_pattern
64
65
end
65
66
66
67
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
+
68
70
@file = <<~HTML
69
71
< %= render GitHub::MenuComponent.new do %>
70
72
< % end %>
You can’t perform that action at this time.
0 commit comments