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
#enclosing_class, #inside_view_component?, #view_component_class?, #view_component_parent?
Instance Method Details
#on_class(node) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/rubocop/cop/view_component/prefer_slots.rb', line 36 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 |