Sha256: 55fc932b50d80b057cd5bad8f8ef6d8689251fb255dcd1692f55969e754b6280

Contents?: true

Size: 919 Bytes

Versions: 23

Compression:

Stored size: 919 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) if match[2]
        end
      end
    end

  private

    def check(str, index)
      spaces = str.count ' '
      return if spaces == @spaces

      location = Location.new(index + 1)
      message = "Expected #{pluralize(@spaces, 'space')} " \
                "between parentheses instead of #{spaces}"
      add_lint(location, message)
    end
  end
end

Version data entries

23 entries across 23 versions & 3 rubygems

Version Path
scss_lint-0.39.0 lib/scss_lint/linter/space_between_parens.rb
scss_lint-0.38.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.38.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-bliss-1.0.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.37.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.36.1 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.36.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.35.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.34.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.33.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.32.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.31.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.30.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.29.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.28.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.27.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.26.2 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.26.1 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.26.0 lib/scss_lint/linter/space_between_parens.rb
scss-lint-0.25.1 lib/scss_lint/linter/space_between_parens.rb