Sha256: f76cb830c6f58eec49e74de5a31678f5d1572683eb90c967cc063c4ab985be0d

Contents?: true

Size: 555 Bytes

Versions: 5

Compression:

Stored size: 555 Bytes

Contents

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

    MESSAGE = '`div` is redundant when %s attribute shortcut is present'

    on [:html, :tag, 'div',
         [:html, :attrs,
           [:html, :attr,
             capture(:attr_name, anything),
             [:static]]]] do |sexp|
      attr = captures[:attr_name]
      next unless %w[class id].include?(attr)

      report_lint(sexp, MESSAGE % attr)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slim_lint-0.6.1 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.6.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.5.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.4.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.3.0 lib/slim_lint/linter/redundant_div.rb