Class: ERBLint::Linters::Agent::NoDirectSvgTag
- Inherits:
-
ERBLint::Linter
- Object
- ERBLint::Linter
- ERBLint::Linters::Agent::NoDirectSvgTag
- Includes:
- ERBLint::LinterRegistry, CustomHelpers
- Defined in:
- lib/erblint/agent/linters/agent/no_direct_svg_tag.rb
Overview
Linter that prohibits direct usage of <svg> tags in ERB templates.
Defined Under Namespace
Classes: ConfigSchema
Constant Summary collapse
- MESSAGE =
"Direct SVG tag usage is prohibited. " \ "Use Tailwind CSS Icons (i-bi-* classes) instead. " \ "Example: <span class=\"i-bi-people\"></span>"
- SELF_CLOSING_SVG_REGEX =
%r{<svg\b[^>]*/\s*>}mi
- PAIRED_SVG_REGEX =
%r{<svg\b[^>]*>.*?</svg\s*>}mi
Instance Method Summary collapse
Methods included from CustomHelpers
#generate_offense, #generate_offense_from_source_range, #simple_class_name, #tags
Instance Method Details
#run(processed_source) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/erblint/agent/linters/agent/no_direct_svg_tag.rb', line 31 def run(processed_source) file_content = processed_source.file_content scan_svg_pattern(processed_source, file_content, SELF_CLOSING_SVG_REGEX) scan_svg_pattern(processed_source, file_content, PAIRED_SVG_REGEX) end |