Sha256: ab64030cda2662374f8796668555942c6c3ce26fde10b407b185988b2159e866

Contents?: true

Size: 808 Bytes

Versions: 19

Compression:

Stored size: 808 Bytes

Contents

module SCSSLint
  # Checks for spaces following the name of a property and before the colon
  # separating the property's name from its value.
  class Linter::SpaceAfterPropertyName < Linter
    include LinterRegistry

    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

    # Deals with a weird Sass bug where the name_source_range of a PropNode does
    # not start at the beginning of the property name.
    def property_name_colon_offset(node)
      offset = 0

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

      offset
    end
  end
end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
scss_lint-0.42.2 lib/scss_lint/linter/space_after_property_name.rb
scss_lint-0.42.1 lib/scss_lint/linter/space_after_property_name.rb
scss_lint-0.42.0 lib/scss_lint/linter/space_after_property_name.rb
scss_lint-0.41.0 lib/scss_lint/linter/space_after_property_name.rb
scss_lint-0.40.1 lib/scss_lint/linter/space_after_property_name.rb
scss_lint-0.40.0 lib/scss_lint/linter/space_after_property_name.rb
scss_lint-0.39.0 lib/scss_lint/linter/space_after_property_name.rb
scss_lint-0.38.0 lib/scss_lint/linter/space_after_property_name.rb
scss-lint-0.38.0 lib/scss_lint/linter/space_after_property_name.rb
scss-lint-bliss-1.0.0 lib/scss_lint/linter/space_after_property_name.rb
scss-lint-0.37.0 lib/scss_lint/linter/space_after_property_name.rb
scss-lint-0.36.1 lib/scss_lint/linter/space_after_property_name.rb
scss-lint-0.36.0 lib/scss_lint/linter/space_after_property_name.rb
scss-lint-0.35.0 lib/scss_lint/linter/space_after_property_name.rb
scss-lint-0.34.0 lib/scss_lint/linter/space_after_property_name.rb
scss-lint-0.33.0 lib/scss_lint/linter/space_after_property_name.rb
scss-lint-0.32.0 lib/scss_lint/linter/space_after_property_name.rb
scss-lint-0.31.0 lib/scss_lint/linter/space_after_property_name.rb
scss-lint-0.30.0 lib/scss_lint/linter/space_after_property_name.rb