Skip to content

Metadata params checks and undefined object checks changes#54

Open
wgrzeszczak wants to merge 3 commits intomasterfrom
metadata-undefined-object-checks-reworked
Open

Metadata params checks and undefined object checks changes#54
wgrzeszczak wants to merge 3 commits intomasterfrom
metadata-undefined-object-checks-reworked

Conversation

@wgrzeszczak
Copy link
Copy Markdown
Contributor

Modified checks to treat all undefined variables as parameters passed to partial except cases when there is a defined doc tag for all liquid files except pages.

@wgrzeszczak wgrzeszczak requested a review from Slashek March 30, 2026 07:29
});

it('should handle hash_assign as definition', () => {
const source = `{% hash_assign h['key'] = 'val' %}{{ h }}`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is not a valid code; this will throw an exception when you try to execute it

`;
const result = extractUndefinedVariables(source);
expect(result).to.deep.equal(['name']);
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we can also add a test for inline graphql aka {% graphql res %}...{% endgraphql %}, for background tag - both as a function and inline

const file = `
{% doc %}
@param {String} a - required param
@param {String} unused - required but not used in source
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In this scenario, should we have another check that would tell us that we defined unused parameter, but we never use it in the code?

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.

2 participants