class SCSSLint::Linter::SpaceAfterPropertyName

Checks for spaces following the name of a property and before the colon separating the property’s name from its value.

Public Instance Methods

visit_prop(node) click to toggle source
# File lib/scss_lint/linter/space_after_property_name.rb, line 7
def visit_prop(node)
  offset = property_name_colon_offset(node)
  return unless character_at(node.name_source_range.start_pos, offset - 1) == ' '
  add_lint node, 'Property name should be immediately followed by a colon'
end

Private Instance Methods

property_name_colon_offset(node) click to toggle source

Deals with a weird Sass bug where the name_source_range of a PropNode does not start at the beginning of the property name.

# File lib/scss_lint/linter/space_after_property_name.rb, line 17
def property_name_colon_offset(node)
  offset = 0

  while character_at(node.name_source_range.start_pos, offset) != ':'
    offset += 1
  end

  offset
end