Skip to content

Fix theme-check-disable-next-line inside tags - #1266

Open
andershagbard wants to merge 1 commit into
Shopify:mainfrom
andershagbard:fix/disable-next-line-raw-html-tags
Open

Fix theme-check-disable-next-line inside tags#1266
andershagbard wants to merge 1 commit into
Shopify:mainfrom
andershagbard:fix/disable-next-line-raw-html-tags

Conversation

@andershagbard

Copy link
Copy Markdown
Contributor

Summary

  • theme-check-disable-next-line silently had no effect when the tag it targeted was nested inside a raw HTML tag (<style>, <script>, <svg>) — e.g. disabling PaginationSize on a {% paginate %} tag used to generate CSS custom properties inside a <style> block.
  • Root cause: getNextNode() in disabled-checks/index.ts looks for the disable comment's next sibling via a children array on the parent node. Liquid nodes nested inside raw HTML tags aren't stored under children — they live under RawMarkup.nodes (see HtmlRawNode.body: RawMarkup / RawMarkup.nodes in liquid-html-parser/src/ast.ts). Since 'children' in parentNode was false for a RawMarkup parent, getNextNode returned undefined, so findNextLinePosition never registered a disabled range at all, and the offense was reported as if no disable comment existed.
  • Fix: add a fallback branch that reads parentNode.nodes when present, mirroring the existing children/markup handling.

Reported by a user hitting this with:

<style>
  ...
  {%- # theme-check-disable-next-line PaginationSize -%}
  {%- paginate metaobjects.swatch.values by 9999 -%}
    ...
  {%- endpaginate -%}
</style>

Confirmed via shopify theme check --output json against a real theme file, then reduced to a minimal repro and traced to the AST-shape mismatch above.

Test plan

  • Added a regression test covering disable-next-line nested in both <style> and <script>.
  • disabled-checks/index.spec.ts — all 19 tests pass.
  • Full theme-check-common suite — 1251 tests pass.
  • tsc --noEmit clean.
  • Added a changeset (patch bump for @shopify/theme-check-common).

getNextNode() only looked for sibling nodes via a `children` array,
but Liquid nodes nested inside raw HTML tags (<style>, <script>, <svg>)
are stored under RawMarkup.nodes instead. This caused
findNextLinePosition() to silently fail to find the next node, so
`theme-check-disable-next-line` had no effect for any tag inside a
<style>/<script> block (e.g. disabling PaginationSize on a paginate
tag used to generate CSS).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q8U8PReyAciD8ck994vMHk
@andershagbard
andershagbard requested a review from a team as a code owner July 28, 2026 09:31
@andershagbard andershagbard changed the title Fix theme-check-disable-next-line inside <style>/<script> tags Fix theme-check-disable-next-line inside tags Jul 28, 2026
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.

1 participant