Sha256: 56bb52c2e3a5586c69a72e56a32c13acdf75e928c524f174801fc30fffa1ffa8

Contents?: true

Size: 586 Bytes

Versions: 23

Compression:

Stored size: 586 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

    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

23 entries across 23 versions & 1 rubygems

Version Path
slim_lint-0.31.1 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.31.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.30.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.29.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.28.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.27.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.26.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.25.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.24.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.23.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.22.1 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.22.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.21.1 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.21.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.20.2 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.20.1 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.20.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.19.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.18.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.17.1 lib/slim_lint/linter/redundant_div.rb