From ac8cb0bd65e4ba1b220ac091b4e732ba7cc41a46 Mon Sep 17 00:00:00 2001 From: Joel Hawksley Date: Fri, 18 Jun 2021 16:49:53 -0600 Subject: [PATCH] add support for `with_content` https://github.com/rubocop/rubocop-ast/blob/master/docs/modules/ROOT/pages/node_pattern.adoc ^ Was JUST enough context for me to figure this out! --- lib/rubocop/cop/github/render_literal_helpers.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/rubocop/cop/github/render_literal_helpers.rb b/lib/rubocop/cop/github/render_literal_helpers.rb index 658d0af..67417a5 100644 --- a/lib/rubocop/cop/github/render_literal_helpers.rb +++ b/lib/rubocop/cop/github/render_literal_helpers.rb @@ -28,6 +28,10 @@ module RenderLiteralHelpers (send nil? {:render :render_to_string} (send _ :new ...) ...) PATTERN + def_node_matcher :render_view_component_instance_with_content?, <<-PATTERN + (send nil? {:render :render_to_string} (send (send _ :new ...) `:with_content ...)) + PATTERN + def_node_matcher :render_view_component_collection?, <<-PATTERN (send nil? {:render :render_to_string} (send _ :with_collection ...) ...) PATTERN @@ -41,7 +45,8 @@ def hash_with_literal_keys?(hash) end def render_view_component?(node) - render_view_component_instance?(node) || + render_view_component_instance_with_content?(node) || + render_view_component_instance?(node) || render_view_component_collection?(node) end end