Sha256: 4bcffb42ef02331b5c1c0cef498ac041d176213d952a77f6b439d11eaf6237ff

Contents?: true

Size: 593 Bytes

Versions: 15

Compression:

Stored size: 593 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'.freeze

    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

15 entries across 15 versions & 1 rubygems

Version Path
slim_lint-0.15.1 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.15.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.14.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.13.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.12.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.11.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.10.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.9.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.8.3 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.8.2 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.8.1 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.8.0 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.7.2 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.7.1 lib/slim_lint/linter/redundant_div.rb
slim_lint-0.7.0 lib/slim_lint/linter/redundant_div.rb