Sha256: 5e79f434f7b3539a1f3b88aa9468c6905d4eeb9ef11a2d2460a4cc39734af6ff

Contents?: true

Size: 545 Bytes

Versions: 10

Compression:

Stored size: 545 Bytes

Contents

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

    def on_variable(node)
      used_filters = node.value.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-0.4.0 lib/theme_check/checks/unknown_filter.rb
theme-check-0.3.3 lib/theme_check/checks/unknown_filter.rb
theme-check-0.3.2 lib/theme_check/checks/unknown_filter.rb
theme-check-0.3.1 lib/theme_check/checks/unknown_filter.rb
theme-check-0.3.0 lib/theme_check/checks/unknown_filter.rb
theme-check-0.2.2 lib/theme_check/checks/unknown_filter.rb
theme-check-0.2.0 lib/theme_check/checks/unknown_filter.rb
theme-check-0.1.2 lib/theme_check/checks/unknown_filter.rb
theme-check-0.1.1 lib/theme_check/checks/unknown_filter.rb
theme-check-0.1.0 lib/theme_check/checks/unknown_filter.rb