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, #parser

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


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

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.match(/\A(\s*|\s+\S.*)$/)

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