Skip to content

Metadata params checks and undefined object checks changes#54

Merged
Slashek merged 6 commits intomasterfrom
metadata-undefined-object-checks-reworked
Apr 1, 2026
Merged

Metadata params checks and undefined object checks changes#54
Slashek merged 6 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed this test.

`;
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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We do have the UnusedDocParam check - it does exactly that. I modified the metadata-params check to stop requiring unused params instead.

@Slashek Slashek merged commit 412d266 into master Apr 1, 2026
5 checks passed
@Slashek Slashek deleted the metadata-undefined-object-checks-reworked branch April 1, 2026 09:52
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