Sha256: dd890aedb71b11cbfeaf4ddcb0409c99010be10142b58fe79713c3624965cce9

Contents?: true

Size: 942 Bytes

Versions: 6

Compression:

Stored size: 942 Bytes

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.gsub(%r{((//|/\*).*$)}, '').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

  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

6 entries across 6 versions & 1 rubygems

Version Path
scss-lint-0.22.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.21.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.20.3 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.20.2 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.20.1 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.20.0 lib/scss_lint/linter/space_between_parens.rb