Sha256: 39cb716c05521603804a3825730be09289afbec238fd9b704296097e9b18688b
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true module SlimLint # Checks for uses of the `div` tag where a class name or ID shortcut was used. class Linter::RedundantDiv < Linter include LinterRegistry SHORTCUT_ATTRS = %w[id class] IMPLICIT_MESSAGE = "`div` is redundant when %s attribute shortcut is present" EXPLICIT_MESSAGE = "Use an explicit `div` rather than a standalone %s attribute shortcut" on [:html, :tag, anything, 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) case config["style"] when "implicit", "never", false, nil report_lint(sexp[2], IMPLICIT_MESSAGE % name) if sexp[2] == "div" when "explicit", "always", true report_lint(sexp[2], EXPLICIT_MESSAGE % name) unless sexp[2] == "div" else raise ArgumentError, "Unknown value for `style`; please use 'implicit' or 'explicit'" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slim_lint_standard-0.0.2 | lib/slim_lint/linter/redundant_div.rb |