Sha256: acd283a130ceb550824760eca76b5d7f2da994647646c648f8d9d165220b1e8e

Contents?: true

Size: 864 Bytes

Versions: 3

Compression:

Stored size: 864 Bytes

Contents

require 'sass'

module SCSSLint
  class Linter::PropertyFormatLinter < Linter
    include LinterRegistry

    def visit_prop(node)
      line = engine.lines[node.line - 1] if node.line
      add_lint(node) unless line =~ PROPERTY_RE
    end

    def description
      'Property declarations should always be on one line of the form ' <<
      '`name: value;` or `name: [value] {` ' <<
      '(are you missing a trailing semi-colon?)'
    end

  private

    VALUE_RE = %r{(\S+\s)*\S+} # eg. "10px", "10px normal"
    PROPERTY_RE = %r{
      ^\s*[\w-]+:\s           # property name, colon, one space
        (                     # followed by
        #{VALUE_RE};          # property and terminating semi-colon eg. a b c;
        |                     # or
        ((#{VALUE_RE}\s)?\{)  # nested property, optional value, trailing curly
        )
    }x
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scss-lint-0.6.7 lib/scss_lint/linter/property_format_linter.rb
scss-lint-0.6.6 lib/scss_lint/linter/property_format_linter.rb
scss-lint-0.6.5 lib/scss_lint/linter/property_format_linter.rb