Sha256: 3a6cd63f716a72dcd782ba9d0ef877738ff3ff7e6b652cfef148048f6c98d743

Contents?: true

Size: 775 Bytes

Versions: 3

Compression:

Stored size: 775 Bytes

Contents

# frozen_string_literal: true
module ThemeCheck
  class DeprecateLazysizes < HtmlCheck
    severity :suggestion
    category :html, :performance
    doc docs_url(__FILE__)

    def on_img(node)
      class_list = node.attributes["class"]&.value&.split(" ")
      add_offense("Use the native loading=\"lazy\" attribute instead of lazysizes", node: node) if class_list&.include?("lazyload")
      add_offense("Use the native srcset attribute instead of data-srcset", node: node) if node.attributes["data-srcset"]
      add_offense("Use the native sizes attribute instead of data-sizes", node: node) if node.attributes["data-sizes"]
      add_offense("Do not set the data-sizes attribute to auto", node: node) if node.attributes["data-sizes"]&.value == "auto"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
theme-check-1.2.0 lib/theme_check/checks/deprecate_lazysizes.rb
theme-check-1.1.0 lib/theme_check/checks/deprecate_lazysizes.rb
theme-check-1.0.0 lib/theme_check/checks/deprecate_lazysizes.rb