Sha256: fa76d07393d4f1f3f537b2a7bc41620d01dd75ee7abc12cab1a1cb283d8615b3

Contents?: true

Size: 566 Bytes

Versions: 10

Compression:

Stored size: 566 Bytes

Contents

# frozen_string_literal: true
module ThemeCheck
  #
  # Unwanted:
  #
  # {{ x | some_unknown_filter }}
  #
  # Wanted:
  #
  # {{ x | upcase }}
  #
  class UnknownFilter < LiquidCheck
    severity :error
    category :liquid
    doc docs_url(__FILE__)

    def on_variable(node)
      used_filters = node.filters.map { |name, *_rest| name }
      undefined_filters = used_filters - ShopifyLiquid::Filter.labels

      undefined_filters.each do |undefined_filter|
        add_offense("Undefined filter `#{undefined_filter}`", node: node)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
theme-check-1.15.0 lib/theme_check/checks/unknown_filter.rb
theme-check-1.14.0 lib/theme_check/checks/unknown_filter.rb
theme-check-1.13.0 lib/theme_check/checks/unknown_filter.rb
theme-check-1.12.1 lib/theme_check/checks/unknown_filter.rb
theme-check-1.12.0 lib/theme_check/checks/unknown_filter.rb
theme-check-1.11.0 lib/theme_check/checks/unknown_filter.rb
theme-check-1.10.3 lib/theme_check/checks/unknown_filter.rb
theme-check-1.10.2 lib/theme_check/checks/unknown_filter.rb
theme-check-1.10.1 lib/theme_check/checks/unknown_filter.rb
theme-check-1.10.0 lib/theme_check/checks/unknown_filter.rb