Shopify/theme-tools

Unknown object "comment" used in sections/main-article.liquid - shopify theme check command multiple warnings shown

Closed this issue · 5 comments

Describe the bug

When I run commands "shopify theme check" in latest Shopify CLI >= 3.57.1, I am getting warning
unknown object "comment" is used.
Please fix this as we're targeting zero warnings for shopify theme check command.
Screenshot 2024-04-25 at 11 06 46 PM

Source

Expected behaviour

Warning should not be displayed for 'comment' object

Actual behaviour

Warning gets displayed as 'comment' object is unknown.

Debugging information

  • OS [e.g. Windows, Mac, Linux]
  • OS Version
  • Theme Check Version [e.g. 0.1.0]

Additional context
Add any other context about the problem here.

From the docs it looks like the comment object is only available as an array element. Are you sure your code is contained by a for loop iterating over article.comments?

{% for comment in article.comments %}
  {% # this is ok %}
  {{ comment }}
{% endfor %}

{% # this is not ok %}
{{ comment }}

image

https://shopify.dev/docs/api/liquid/objects/comment

HI @charlespwd , please see this dawn theme, https://github.com/Shopify/dawn , you can clone the repo and find the warnings. My concern is who will fix this as we're using the file sections/main-article.liquid.

Either I misunderstand the paginate tag, or there's a missing for loop in there:
https://github.com/Shopify/dawn/blob/main/sections/main-article.liquid#L106C11-L130C28

OK so just found out that this is indeed a documentation issue. We'll update our docs. The comment object is available on pages with the comment form posted.

The docs are kind of obtuse, but we do have a reference to this happening here