Class: HamlLint::Linter::LeadingCommentSpace

Inherits:
HamlLint::Linter show all
Includes:
HamlLint::LinterRegistry
Defined in:
lib/haml_lint/linter/leading_comment_space.rb

Overview

Checks for comments that don't have a leading space.

Instance Attribute Summary

Attributes inherited from HamlLint::Linter

#lints

Instance Method Summary collapse

Methods included from HamlLint::LinterRegistry

extract_linters_from, included

Methods inherited from HamlLint::Linter

#initialize, #name, #run

Methods included from HamlVisitor

#visit, #visit_children

Constructor Details

This class inherits a constructor from HamlLint::Linter

Instance Method Details

#visit_haml_comment(node) ⇒ Object


8
9
10
11
12
13
14
# File 'lib/haml_lint/linter/leading_comment_space.rb', line 8

def visit_haml_comment(node)
  # Skip if the node spans multiple lines starting on the second line,
  # or starts with a space
  return if node.text =~ /\A#*(\s*|\s+\S.*)$/

  record_lint(node, 'Comment should have a space after the `#`')
end