Skip to content

fix: allow theme-check-disable-next-line to suppress checks inside doc tags#1189

Open
SinhSinhAn wants to merge 1 commit into
Shopify:mainfrom
SinhSinhAn:fix/disable-next-line-doc-tag
Open

fix: allow theme-check-disable-next-line to suppress checks inside doc tags#1189
SinhSinhAn wants to merge 1 commit into
Shopify:mainfrom
SinhSinhAn:fix/disable-next-line-doc-tag

Conversation

@SinhSinhAn
Copy link
Copy Markdown
Contributor

@SinhSinhAn SinhSinhAn commented Apr 21, 2026

What are you adding in this PR?

Fixes the case where {% # theme-check-disable-next-line %} placed before a {% doc %} tag does not actually suppress the checks that run against the doc tag's contents.

Today, when a snippet has a duplicate @param you intentionally want to keep, the only workaround is wrapping the whole tag in a disable/enable pair:

{% # theme-check-disable-next-line UniqueDocParamNames %}
{% doc %}
  @param prods - products
  @param prods - intentional duplicate
{% enddoc %}

This is verbose. The single-line disable-next-line should just work.

Root cause: findNextLinePosition in disabled-checks/index.ts has a guard for block tags. When the next node has a blockStartPosition (like {% if %}, {% for %}, {% doc %}), it returns only blockStartPosition instead of the full position. That guard is there so disable-next-line does not accidentally suppress checks on nested children of control flow tags. But doc tag checks (UniqueDocParamNames, ValidDocParamTypes, ReservedDocParamNames) report offenses at positions inside the doc body, so they fall outside blockStartPosition and are never suppressed.

Fix: when the next node is a LiquidRawTag with name === 'doc', return the full position span instead of blockStartPosition. Safe because doc tag bodies are parsed by a separate grammar (LiquidDocGrammar) that only produces doc-specific nodes (@param, @description, @example), so there is no risk of accidentally silencing unrelated checks on nested control flow.

The change is a 4-line conditional in findNextLinePosition.

Three new test cases were added to disabled-checks/index.spec.ts:

  • disable-next-line UniqueDocParamNames before a doc tag with a duplicate param suppresses the offense
  • disable-next-line (no specific check) suppresses all checks inside the doc tag
  • Without the disable comment, the offense still fires (regression guard)

All 18 tests pass (15 existing + 3 new).

Closes #945

What's next? Any followup issues?

None planned. The narrow scope here (only {% doc %}, only when matched as the "next node") avoids the larger question of how to support disable-next-line inside a doc tag body, which is a separate problem because LiquidDocGrammar does not parse Liquid tags at all, so the comment would never appear as a LiquidTag node in the first place. That's out of scope for this PR.

What did you learn?

The blockStartPosition guard in findNextLinePosition is correct for control flow tags ({% if %}, {% for %}) and the wrong default for "leaf-ish" block tags like {% doc %} whose children are themselves the thing being checked. Worth keeping in mind if other block tags in the future also report offenses on their inner nodes rather than on their wrappers.

Tophatting

In a theme with a snippet that intentionally duplicates a @param for documentation purposes:

{% # theme-check-disable-next-line UniqueDocParamNames %}
{% doc %}
  @param prods - products
  @param prods - intentional duplicate
{% enddoc %}
  • Before this PR: UniqueDocParamNames still reports an offense.
  • After this PR: the offense is suppressed.

Also confirm that disable-next-line before a regular block (e.g. {% if %}) still only disables the opening line, not the children inside.

Before you deploy

  • I included a patch bump `changeset` (`@shopify/theme-check-common: patch`)

…c tags

When `{% # theme-check-disable-next-line %}` was placed before a
`{% doc %}` tag, it only covered the opening `{% doc %}` marker itself
(via `blockStartPosition`), not the body. Checks like
UniqueDocParamNames, ValidDocParamTypes, and ReservedDocParamNames
report offenses at positions inside the doc body, so they were never
suppressed.

The fix: when the next node is a `{% doc %}` LiquidRawTag, use the
full `position` span (covering the entire tag including its body)
instead of just `blockStartPosition`. This is safe because doc tags
contain a flat list of doc-specific nodes (params, descriptions),
not nested Liquid control flow that should remain independently
checkable.

Closes Shopify#945
@SinhSinhAn SinhSinhAn requested a review from a team as a code owner April 21, 2026 15:57
Copy link
Copy Markdown
Contributor

@aswamy aswamy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @SinhSinhAn Thanks for another PR. The code looks fine.

Could you ensure your PR descriptions for all your PRs follow the PR template recommended by this repo?

https://github.com/Shopify/theme-tools/blob/main/.github/PULL_REQUEST_TEMPLATE.md

@SinhSinhAn
Copy link
Copy Markdown
Contributor Author

Of course, I can make edits after this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Theme check disable next line does not work for doc tag

2 participants