-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LiquidDoc][Theme Check] Check for duplicated params passed to {% render %}
tag
#834
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
de9ee25
to
7fa2d56
Compare
{% render %}
tag
7fa2d56
to
4c820c4
Compare
suggest: [ | ||
{ | ||
message: `Remove duplicate parameter '${paramName}'`, | ||
fix: (fixer) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part has me feeling icky, I haven't landed on an approach yet. I'm considering many.
I want to be pragmatic here. I don't think this code will change soon, and if it does I'm hoping that we can simplify this logic by potentially getting more information during the parse step instead.
Not sure how much time I want to invest as a result.
Ideas
- Leaving this comment here to indicate duplication
- Extracting to a shared utility but testing in the tests for individual checks
- Extracting a utility that just provides indexes
Factors
- The code is 1-1 duplicated, so I do want to call out duplication
- This code IS tested through the individual theme checks.
- I tried extracting this to a utility and didn't like the way I had to write tests. Probably a skill issue. Will take time either way.
- I feel like the better approach is to do this programatically via modifying parsing logic.
@aswamy WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paired on this. Not ideal, but we're going to leave this as is as it's the more pragmatic approach.
We should reconsider the next time we touch this code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor changes
packages/theme-check-common/src/checks/duplicate-render-snippet-params/index.ts
Outdated
Show resolved
Hide resolved
packages/theme-check-common/src/checks/duplicate-render-snippet-params/index.ts
Outdated
Show resolved
Hide resolved
packages/theme-check-common/src/checks/duplicate-render-snippet-params/index.ts
Outdated
Show resolved
Hide resolved
packages/theme-check-common/src/checks/duplicate-render-snippet-params/index.ts
Outdated
Show resolved
Hide resolved
Introduces a new theme check to detect and report duplicate parameters in Liquid render tags. The check: - Identifies duplicate parameter names in render snippets - Provides suggestions to remove redundant parameters
4c820c4
to
6973bec
Compare
- Extract `isLastParam` function to shared utility - Improve source slicing and comma matching for parameter removal - Ensure consistent parameter removal across different checks
6973bec
to
a3d9762
Compare
What are you adding in this PR?
Closes https://github.com/Shopify/developer-tools-team/issues/539
Add a theme check to check for duplicated param passed into a
{% render %}
tagIncludes:
{% render 'snippet-name' with 'test' as param, param: 'test' %}
Before you deploy
changeset
allChecks
array insrc/checks/index.ts
yarn build
and committed the updated configuration filestheme-app-extension.yml
config