Sha256: 9f9c3f464b7f5e133c782d3fc545d8883b982c8ba387a835b333349b15472753
Contents?: true
Size: 1.06 KB
Versions: 5
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module ThemeCheck # Reports missing include/render/section liquid file class MissingTemplate < LiquidCheck severity :suggestion category :liquid doc docs_url(__FILE__) single_file false def initialize(ignore_missing: []) @ignore_missing = ignore_missing end def on_include(node) snippet = node.value.template_name_expr if snippet.is_a?(String) add_missing_offense("snippets/#{snippet}", node: node) end end alias_method :on_render, :on_include def on_section(node) section = node.value.section_name add_missing_offense("sections/#{section}", node: node) end private def ignore?(path) @ignore_missing.any? { |pattern| File.fnmatch?(pattern, path) } end def add_missing_offense(name, node:) path = "#{name}.liquid" unless ignore?(path) || theme[name] add_offense("'#{path}' is not found", node: node) do |corrector| corrector.create(@theme, "#{name}.liquid", "") end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems