Class: RubomaticHtml::Cop::Style::NoOnAttribute
- Defined in:
- lib/rubomatic-html/cop/style/no_on_attribute.rb
Direct Known Subclasses
NoOnBeforeUnload, NoOnClick, NoOnDrag, NoOnLoad, NoOnUnload, NoOnWheel
Instance Attribute Summary collapse
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Methods inherited from Base
abstract_cop?, allowed_config_transform, #initialize, name
Constructor Details
This class inherits a constructor from RubomaticHtml::Cop::Base
Instance Attribute Details
#html_attr ⇒ String
8 9 10 |
# File 'lib/rubomatic-html/cop/style/no_on_attribute.rb', line 8 def html_attr @html_attr end |
Instance Method Details
#run_for_line(line, index) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubomatic-html/cop/style/no_on_attribute.rb', line 11 def run_for_line(line, index) # `onclick:` or `onclick=` has_on_click = line.match?(/#{html_attr}[:=]/i) # `:onclick=>` or `:onclick =>` has_on_click ||= line.match?(/:#{html_attr} ?=>/i) # `'onclick'=>` or `'onclick' =>` has_on_click ||= line.match?(/'#{html_attr}' ?=>/i) # `"onclick"=>` or `"onclick" =>` has_on_click ||= line.match?(/"#{html_attr}" ?=>/i) return unless has_on_click puts("#{file}:#{index}: might use an #{html_attr} attribute") end |