Sha256: 83263edff0e810e229fa8a3c1df8584c37204910bd98b844620272d9fedcbdc1

Contents?: true

Size: 877 Bytes

Versions: 4

Compression:

Stored size: 877 Bytes

Contents

module SCSSLint
  class Linter::PropertyFormat < 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*[^:]+(?<!\s):\s       # property name, colon not preceded by a space, 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

4 entries across 4 versions & 1 rubygems

Version Path
scss-lint-0.11.1 lib/scss_lint/linter/property_format.rb
scss-lint-0.10.1 lib/scss_lint/linter/property_format.rb
scss-lint-0.10.0 lib/scss_lint/linter/property_format.rb
scss-lint-0.9.0 lib/scss_lint/linter/property_format.rb