Sha256: 103f8894363f0493e0b4fc1953afca7000d16149c972aaa009c6aac51c8c1b47

Contents?: true

Size: 857 Bytes

Versions: 18

Compression:

Stored size: 857 Bytes

Contents

module SCSSLint
  # Checks properties for a trailing semicolon (unless that property is a
  # namespace which has nested properties).
  class Linter::TrailingSemicolonAfterPropertyValue < Linter
    include LinterRegistry

    def visit_prop(node)
      has_nested_props = has_nested_properties?(node)

      if !has_nested_props && !ends_with_semicolon?(node)
        add_lint node.line, 'Property declaration should end with a semicolon'
      end

      yield if has_nested_props
    end

  private

    def has_nested_properties?(node)
      node.children.any? { |n| n.is_a?(Sass::Tree::PropNode) }
    end

    # Checks that the property is ended by a semicolon (with no whitespace)
    def ends_with_semicolon?(node)
      character_at(node.source_range.end_pos) == ';' &&
        character_at(node.source_range.end_pos, -1) !~ /\s/
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
scss-lint-0.21.0 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.20.3 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.20.2 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.20.1 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.20.0 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.19.0 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.18.0 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.17.3 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.17.2 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.17.1 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.17.0 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.16.1 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.16.0 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.15.0 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.14.0 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.13.0 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.12.1 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
scss-lint-0.12.0 lib/scss_lint/linter/trailing_semicolon_after_property_value.rb