Sha256: 44a88459125f27f85ca24cce1d10cb799b1dd1be74a866534d0c30c9ea2a906e

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

module SCSSLint
  # Checks for the presence of spaces between parentheses.
  class Linter::SpaceBetweenParens < Linter
    include LinterRegistry

    def visit_root(node)
      @spaces = config['spaces']
      engine.lines.each_with_index do |line, index|
        line.scan(/
          (^(\t|\s)*\))?  # Capture leading spaces and tabs followed by a `)`
          (
            \([ ]*(?!$)   # Find `( ` as long as its not EOL )
            |
            [ ]*\)
          )?
        /x) do |match|
          check(match[2], index, engine) if match[2]
        end
      end
    end

    #def visit_script_number(node)
      #puts node.class
      #puts node.node_parent.class
      #puts node.node_parent.node_parent.class
      #puts node.inspect
      #yield
    #end

    #def visit_script_operation(node)
      #puts node.node_parent.class
      #puts node.inspect
      #puts node.source_range.inspect
      #yield
    #end

  private

    def check(str, index, engine)
      spaces = str.count ' '

      if spaces != @spaces
        @lints << Lint.new(engine.filename, index + 1, "Expected #{pluralize(@spaces, 'space')}" <<
                                                       " between parentheses instead of #{spaces}")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scss-lint-0.16.1 lib/scss_lint/linter/space_between_parens.rb