Skip to content

Conversation

@charlespwd
Copy link
Contributor

What are you adding in this PR?

We were visiting those nodes as though they were part of the execution of the file when in fact those are not parsed by the backend but stripped away.

I first tried doing that at the parsing layer by putting the body as a TextNode (the same way {% raw %} does it) but quickly discovered that we do depend on it being parsed for the StaticStylesheetAndJavascriptTags check.

So instead, I just added a helper that both UndefinedObject and UnusedAssign use to skip visiting of nodes that are parent'ed by a "raw-like" tag

Fixes #685

Before you deploy

  • I included a patch bump changeset

@charlespwd charlespwd requested a review from a team as a code owner September 24, 2025 13:19

it('should not report unused assigns for things used in a raw-like tag', async () => {
const tags = ['style', 'javascript', 'stylesheet'];
const tags = ['style'];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

that was wrong.

Liquid isn't rendered in {% javascript %} or {% stylesheet %} tags. Including Liquid code in these tags can cause syntax errors, or prevent styles from being applied to the theme.

source

@charlespwd charlespwd force-pushed the fix-685-do-not-visit-schema-liquid branch from 684c07f to f96d13f Compare September 24, 2025 13:22
Copy link
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

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

Thank you, @charlespwd! I've left only two minor questions, please let me know your thoughts 🙏

@charlespwd charlespwd force-pushed the fix-685-do-not-visit-schema-liquid branch from f96d13f to bbf2ba1 Compare September 24, 2025 13:44
async LiquidVariableOutput(node) {
async LiquidVariableOutput(node, ancestors) {
// Do not report {{ foo == bar }} errors inside {% schema %} where they are supported
if (isWithinRawTagThatDoesNotParseItsContents(ancestors)) return;
Copy link
Contributor Author

@charlespwd charlespwd Sep 24, 2025

Choose a reason for hiding this comment

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

Image

That's a false positive, since we do support those

@charlespwd charlespwd force-pushed the fix-685-do-not-visit-schema-liquid branch from bbf2ba1 to d7b7796 Compare September 24, 2025 13:55
Copy link
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

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

Thank you, @charlespwd!

We were visiting those nodes as though they were part of the execution
of the file when in fact those are not parsed by the backend but
stripped away.

I first tried doing that at the parsing layer by putting the body as a
TextNode (the same way `{% raw %}` does it) but quickly discovered that
we do depend on it being parsed for the StaticStylesheetAndJavascriptTags
check.

So instead, I just added a helper that both UndefinedObject and
UnusedAssign use to skip visiting of nodes that are parent'ed by a
"raw-like" tag

Fixes #685
@charlespwd charlespwd force-pushed the fix-685-do-not-visit-schema-liquid branch from d7b7796 to 294e604 Compare September 24, 2025 14:19
@charlespwd charlespwd merged commit dd1f4c8 into main Sep 24, 2025
7 checks passed
@charlespwd charlespwd deleted the fix-685-do-not-visit-schema-liquid branch September 24, 2025 15:11
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.

Liquid inside {% schema %} should not be visited by theme-check.

3 participants