Class: ERBLint::Linters::LocoMotionComponentUsage
- Inherits:
-
Linter
- Object
- Linter
- ERBLint::Linters::LocoMotionComponentUsage
- Includes:
- LinterRegistry
- Defined in:
- lib/loco_motion/lint/erb_lint/component_usage.rb
Overview
The ERB counterpart of the haml_lint rule: flags views hand-rolling
DaisyUI markup instead of calling the LocoMotion helper that owns it —
class="card" where daisy_card belongs.
Both linters read the SAME derived map (LocoMotion::Lint::ComponentMap), so the two template languages cannot enforce different rules. That was the practical failure of the hand-written list this replaces: it covered both languages with one regex and drifted from the library in both at once.
Consumers load this from a .erb_linters/ shim — see the README.
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.
44 45 46 |
# File 'lib/loco_motion/lint/erb_lint/component_usage.rb', line 44 def cached_map @cached_map end |
Instance Method Details
#run(processed_source) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/loco_motion/lint/erb_lint/component_usage.rb', line 22 def run(processed_source) each_class(processed_source) do |css_class, tag| helper = component_map[css_class] next unless helper add_offense( processed_source.to_source_range(tag.loc), "`#{css_class}` is LocoMotion's #{helper} — " \ "call the helper instead of hand-rolling the markup" ) end end |