Sha256: bf36766a31f2d871dcc5d664c33b9334b0a9615226489d5f5f933af78c955711

Contents?: true

Size: 627 Bytes

Versions: 2

Compression:

Stored size: 627 Bytes

Contents

# frozen_string_literal: true

module SlimLint
  # Checks for unnecessary uses of the `div` tag where a class name or ID
  # already implies a div.
  class Linter::RedundantDiv < Linter
    include LinterRegistry

    SHORTCUT_ATTRS = %w[id class]
    MESSAGE = "`div` is redundant when %s attribute shortcut is present"

    on [:html, :tag, "div", capture(:attrs, [:html, :attrs]), anything] do |sexp|
      _, _, name, value = captures[:attrs][2]
      next unless name
      next unless value[0] == :static
      next unless SHORTCUT_ATTRS.include?(name.value)

      report_lint(sexp[2], MESSAGE % name)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slim_lint_standard-0.0.1 lib/slim_lint/linter/redundant_div.rb
slim_lint_standard-0.0.0 lib/slim_lint/linter/redundant_div.rb