Class: RuboCop::Cop::ViewComponent::PreferSlots
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::ViewComponent::PreferSlots
- Includes:
- Base
- Defined in:
- lib/rubocop/cop/view_component/prefer_slots.rb
Overview
Detects parameters that accept HTML content and suggests using slots.
Constant Summary collapse
- MSG =
"Consider using `%<slot_method>s` instead of passing HTML " \ "as a parameter. This maintains Rails' automatic HTML escaping."
- HTML_PARAM_PATTERN =
/_html$/
Instance Method Summary collapse
Methods included from Base
#component_namespaces, #enclosing_class, #fully_qualified_name, #inside_view_component?, #view_component_class?, #view_component_parent?, #view_component_parent_class?
Instance Method Details
#html_safe_call?(node) ⇒ Object
35 |
# File 'lib/rubocop/cop/view_component/prefer_slots.rb', line 35 def_node_search :html_safe_call?, "(send _ :html_safe)" |
#on_class(node) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/rubocop/cop/view_component/prefer_slots.rb', line 37 def on_class(node) return unless view_component_class?(node) initialize_method = find_initialize(node) return unless initialize_method check_initialize_params(initialize_method) end |