Sha256: b6ea75bac46d82872d76c199f7a82e1046c743d63ebe8f8f84df92f30814d55e

Contents?: true

Size: 921 Bytes

Versions: 11

Compression:

Stored size: 921 Bytes

Contents

module SCSSLint
  # Enforce a particular value for empty borders.
  class Linter::BorderZero < Linter
    include LinterRegistry

    CONVENTION_TO_PREFERENCE = {
      'zero' => %w[0 none],
      'none' => %w[none 0],
    }

    BORDER_PROPERTIES = %w[
      border
      border-top
      border-right
      border-bottom
      border-left
    ]

    def visit_root(_node)
      @preference = CONVENTION_TO_PREFERENCE[config['convention']]
      yield # Continue linting children
    end

    def visit_prop(node)
      return unless BORDER_PROPERTIES.include?(node.name.first.to_s)
      check_border(node, node.value.to_sass.strip)
    end

  private

    def check_border(node, border)
      return unless %w[0 none].include?(border)
      return if @preference[0] == border

      add_lint(node, "`border: #{@preference[0]} is preferred over " \
                     "`border: #{@preference[1]}`")
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
scss_lint-0.40.1 lib/scss_lint/linter/border_zero.rb
scss_lint-0.40.0 lib/scss_lint/linter/border_zero.rb
scss_lint-0.39.0 lib/scss_lint/linter/border_zero.rb
scss_lint-0.38.0 lib/scss_lint/linter/border_zero.rb
scss-lint-0.38.0 lib/scss_lint/linter/border_zero.rb
scss-lint-bliss-1.0.0 lib/scss_lint/linter/border_zero.rb
scss-lint-0.37.0 lib/scss_lint/linter/border_zero.rb
scss-lint-0.36.1 lib/scss_lint/linter/border_zero.rb
scss-lint-0.36.0 lib/scss_lint/linter/border_zero.rb
scss-lint-0.35.0 lib/scss_lint/linter/border_zero.rb
scss-lint-0.34.0 lib/scss_lint/linter/border_zero.rb