Sha256: 52d36d8040244232acb9e85ff980bc24b08ed4bd131dc9671eb3905289c0b8d9

Contents?: true

Size: 661 Bytes

Versions: 13

Compression:

Stored size: 661 Bytes

Contents

module SCSSLint
  # Checks for rule sets nested deeper than a specified maximum depth.
  class Linter::NestingDepth < Linter
    include LinterRegistry

    def visit_root(_node)
      @max_depth = config['max_depth']
      @depth = 1
      yield # Continue linting children
    end

    def visit_rule(node)
      if @depth > @max_depth
        add_lint(node, "Nesting should be no greater than #{@max_depth}, but was #{@depth}")
      else
        # Only continue if we didn't exceed the max depth already (this makes
        # the lint less noisy)
        @depth += 1
        yield # Continue linting children
        @depth -= 1
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
scss_lint-0.39.0 lib/scss_lint/linter/nesting_depth.rb
scss_lint-0.38.0 lib/scss_lint/linter/nesting_depth.rb
scss-lint-0.38.0 lib/scss_lint/linter/nesting_depth.rb
scss-lint-bliss-1.0.0 lib/scss_lint/linter/nesting_depth.rb
scss-lint-0.37.0 lib/scss_lint/linter/nesting_depth.rb
scss-lint-0.36.1 lib/scss_lint/linter/nesting_depth.rb
scss-lint-0.36.0 lib/scss_lint/linter/nesting_depth.rb
scss-lint-0.35.0 lib/scss_lint/linter/nesting_depth.rb
scss-lint-0.34.0 lib/scss_lint/linter/nesting_depth.rb
scss-lint-0.33.0 lib/scss_lint/linter/nesting_depth.rb
scss-lint-0.32.0 lib/scss_lint/linter/nesting_depth.rb
scss-lint-0.31.0 lib/scss_lint/linter/nesting_depth.rb
scss-lint-0.30.0 lib/scss_lint/linter/nesting_depth.rb