Sha256: 6790689cefe477cf7af9a7e2bac7c2bfc95b62b3f85552ebacfc3962b1d898fc

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module ThemeCheck
  # Reports missing shopify required theme files
  # required templates: https://shopify.dev/tutorials/review-theme-store-requirements-files

  class MissingRequiredTemplateFiles < LiquidCheck
    severity :error
    category :liquid
    doc "https://shopify.dev/docs/themes/theme-templates"

    LAYOUT_FILENAME = "layout/theme"
    REQUIRED_TEMPLATES_FILES = %w(index product collection cart blog article page list-collections search 404
                                  gift_card customers/account customers/activate_account customers/addresses
                                  customers/login customers/order customers/register customers/reset_password password)
      .map { |file| "templates/#{file}" }

    def on_end
      missing_files = (REQUIRED_TEMPLATES_FILES + [LAYOUT_FILENAME]) - theme.liquid.map(&:name)
      missing_files.each { |file| add_missing_file_offense(file) }
    end

    private

    def add_missing_file_offense(file)
      add_offense("Theme is missing '#{file}.liquid' file")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
theme-check-0.1.1 lib/theme_check/checks/missing_required_template_files.rb
theme-check-0.1.0 lib/theme_check/checks/missing_required_template_files.rb