Class: Linter::LocoMotionComponentUsage
- Inherits:
-
Linter
- Object
- Linter
- Linter::LocoMotionComponentUsage
- Includes:
- LinterRegistry
- Defined in:
- lib/loco_motion/lint/haml_lint/component_usage.rb
Overview
Flags views that hand-roll DaisyUI component markup instead of calling the
LocoMotion helper that owns it — .card where daisy_card belongs.
The class list is DERIVED from the component registry at load time (see LocoMotion::Lint::ComponentMap), so it cannot fall behind the library the way a hand-maintained list does. The list this replaces covered 25 of 70 components; every component added since it was written was unenforced.
Views compose components; components own markup. LocoMotion's own component templates are therefore the one place raw DaisyUI classes belong, and should be excluded in .haml-lint.yml.
Tailwind utilities (flex, p-4, hover:*) are never flagged — utilities in a view are correct usage.
Constant Summary collapse
- STATIC_TYPES =
i[str sym].freeze
Class Attribute Summary collapse
-
.cached_map ⇒ Object
Returns the value of attribute cached_map.
Instance Method Summary collapse
Class Attribute Details
.cached_map ⇒ Object
Returns the value of attribute cached_map.
46 47 48 |
# File 'lib/loco_motion/lint/haml_lint/component_usage.rb', line 46 def cached_map @cached_map end |
Instance Method Details
#visit_tag(node) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/loco_motion/lint/haml_lint/component_usage.rb', line 25 def visit_tag(node) classes = node.static_classes.flatten + hash_classes(node) classes.uniq.each do |css_class| helper = component_map[css_class] next unless helper record_lint(node, "`.#{css_class}` is LocoMotion's #{helper} — " \ "call the helper instead of hand-rolling the markup") end end |