fix: allow theme-check-disable-next-line to suppress checks inside doc tags#1189
Open
SinhSinhAn wants to merge 1 commit into
Open
fix: allow theme-check-disable-next-line to suppress checks inside doc tags#1189SinhSinhAn wants to merge 1 commit into
SinhSinhAn wants to merge 1 commit into
Conversation
…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
aswamy
reviewed
May 15, 2026
Contributor
aswamy
left a comment
There was a problem hiding this comment.
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
Contributor
Author
|
Of course, I can make edits after this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
@paramyou 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-lineshould just work.Root cause:
findNextLinePositionindisabled-checks/index.tshas a guard for block tags. When the next node has ablockStartPosition(like{% if %},{% for %},{% doc %}), it returns onlyblockStartPositioninstead of the fullposition. That guard is there sodisable-next-linedoes 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 outsideblockStartPositionand are never suppressed.Fix: when the next node is a
LiquidRawTagwithname === 'doc', return the fullpositionspan instead ofblockStartPosition. 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 UniqueDocParamNamesbefore a doc tag with a duplicate param suppresses the offensedisable-next-line(no specific check) suppresses all checks inside the doc tagAll 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 supportdisable-next-lineinside a doc tag body, which is a separate problem becauseLiquidDocGrammardoes not parse Liquid tags at all, so the comment would never appear as aLiquidTagnode in the first place. That's out of scope for this PR.What did you learn?
The
blockStartPositionguard infindNextLinePositionis 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
@paramfor documentation purposes:{% # theme-check-disable-next-line UniqueDocParamNames %} {% doc %} @param prods - products @param prods - intentional duplicate {% enddoc %}UniqueDocParamNamesstill reports an offense.Also confirm that
disable-next-linebefore a regular block (e.g.{% if %}) still only disables the opening line, not the children inside.Before you deploy