Fix theme-check-disable-next-line inside tags - #1266
Open
andershagbard wants to merge 1 commit into
Open
Conversation
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
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.
Summary
theme-check-disable-next-linesilently had no effect when the tag it targeted was nested inside a raw HTML tag (<style>,<script>,<svg>) — e.g. disablingPaginationSizeon a{% paginate %}tag used to generate CSS custom properties inside a<style>block.getNextNode()indisabled-checks/index.tslooks for the disable comment's next sibling via achildrenarray on the parent node. Liquid nodes nested inside raw HTML tags aren't stored underchildren— they live underRawMarkup.nodes(seeHtmlRawNode.body: RawMarkup/RawMarkup.nodesinliquid-html-parser/src/ast.ts). Since'children' in parentNodewasfalsefor aRawMarkupparent,getNextNodereturnedundefined, sofindNextLinePositionnever registered a disabled range at all, and the offense was reported as if no disable comment existed.parentNode.nodeswhen present, mirroring the existingchildren/markuphandling.Reported by a user hitting this with:
Confirmed via
shopify theme check --output jsonagainst a real theme file, then reduced to a minimal repro and traced to the AST-shape mismatch above.Test plan
disable-next-linenested in both<style>and<script>.disabled-checks/index.spec.ts— all 19 tests pass.theme-check-commonsuite — 1251 tests pass.tsc --noEmitclean.patchbump for@shopify/theme-check-common).