Skip to main content

UndefinedObject

Identifies unknown variable references. Liquid variables must declared using assign tags, capture tags, or documented with @param inside of LiquidDoc. Some Liquid variables exist by default in a global scope. See Liquid objects.


The following examples contain code snippets that either fail or pass this check for different scenarios.

This check passes when properly calling global Liquid objects.

blocks/my-block.liquid

{{ collection }}
{{ product }}

This check fails when a variable is used in a block before it has been assigned using assign or capture. This check is skipped for snippet files unless it contains LiquidDoc. See examples below.

blocks/my-block.liquid

{{ my_variable }}

This check passes when a variable has been assigned in a block before use.

blocks/my-block.liquid

{% assign my_variable = "Hello" %}
{{ my_variable }}

This check fails when a variable is used within a snippet or block file, but is neither defined locally nor documented with @param within that file's {% doc %} tag.

snippets/my-snippet.liquid

{% doc %}
@param {string} my_variable - The variable to be used.
{% enddoc %}

{{ another_variable }}

This check passes when a variable used within a snippet or block is documented with @param.

snippets/my-snippet.liquid

{% doc %}
@param {string} my_variable - The variable to be used.
{% enddoc %}

{{ my_variable }}

UndefinedObject:
enabled: true
severity: warning
ParameterDescription
enabledWhether this check is enabled.
severityThe severity of the check.

Anchor to Disabling this checkDisabling this check

Disabling this check isn't recommended as it helps catch typos and potential runtime errors.


Was this page helpful?