Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-disable-next-line-raw-tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/theme-check-common': patch
---

Fix `theme-check-disable-next-line` not suppressing offenses when the following tag is nested inside a raw HTML tag (`<style>`, `<script>`, `<svg>`). Previously, the sibling-node lookup only checked for a `children` array, but nodes inside raw HTML tags are stored under a `nodes` property on the `RawMarkup` body, so the disable comment was silently ineffective in that context.
14 changes: 14 additions & 0 deletions packages/theme-check-common/src/disabled-checks/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,20 @@ ${buildComment('theme-check-enable')}
expect(offenses).to.have.length(0);
});

it('should disable the next line when nested inside a raw HTML tag like <style> or <script>', async () => {
for (const rawTag of ['style', 'script']) {
const file = `<${rawTag}>
{% # theme-check-disable-next-line %}
{% render 'something' %}
{% render 'other-thing' %}
</${rawTag}>`;

const offenses = await check({ 'code.liquid': file }, checks);
expect(offenses).to.have.length(1);
expectRenderMarkupOffense(offenses, 'other-thing.liquid');
}
});

it('should still report offenses in doc tags when disable-next-line is not present', async () => {
const file = `{% doc %}
@param baz - first param
Expand Down
2 changes: 2 additions & 0 deletions packages/theme-check-common/src/disabled-checks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ function getNextNode(
siblingNodes = parentNode.markup;
} else if ('children' in parentNode) {
siblingNodes = parentNode.children || [];
} else if ('nodes' in parentNode) {
siblingNodes = parentNode.nodes || [];
}

const currentNodeIdx = siblingNodes.findIndex((c) => c === node);
Expand Down
Loading