-
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] Type validations on parameters passed to {% render %}
tag
#792
base: main
Are you sure you want to change the base?
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
9f3f606
to
d901997
Compare
9b840e6
to
9f76c3b
Compare
invalidValues: [ | ||
{ value: '123', expectedType: SupportedParamTypes.Number }, | ||
{ value: 'true', expectedType: SupportedParamTypes.Boolean }, | ||
{ value: 'product', expectedType: SupportedParamTypes.Object }, |
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.
todo: A VariableLookup should probably just default to valid
, since we can only validate this with the runtime value
], | ||
}, | ||
{ | ||
type: 'boolean', |
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.
@charlespwd Could you give me a sanity check here?
Truthy / Falsy handling for booleans
Given the documentation on types, I may need to revisit how we validate Boolean
to accept ANYTHING, since everything is truthy
or falsy
- link. This means that anything can be passed down as a boolean param - is that correct?
Complex Objects
I looked at types of LiquidNamedArgument.value.type
, and tried to map those to a "supported type". Any complex types, such as product
are just object
(I took inspiration from existing comments in Dawn on this)
9f76c3b
to
7d2e25a
Compare
7d2e25a
to
84222ac
Compare
9a2f51d
to
06b96c5
Compare
84222ac
to
d647ab4
Compare
d647ab4
to
3f08ba6
Compare
75ab8e0
to
f69929d
Compare
…ender snippets - Reports type mismatches - Suggests autofixes (replace with default or remove value) - Skips type checking for variable lookups - We would need to evaluate this dynamically, so we should accept this until we can do so - Skips type checking for unknown parameters - Skips type checking for unknown types
f69929d
to
a2686d6
Compare
{% render %}
tag
What are you adding in this PR?
Closes https://github.com/Shopify/developer-tools-team/issues/536
https://share.descript.com/view/i7Q9QsBv3tJ
Validates the type of a parameter provided to a snippet against the type outline in the
doc
header (if present)Rules / Exceptions
i.e. {boOlEAn}
is valid)booleans
will accept anything, because everything in Liquid is truthy / falsy - sourceVariableLookup
is provided, we don't validate the type. We just accept the value:{% render 'product-card', num_param: num_variable %}
<- we would need to evaluatenum_variable
Before you deploy
changeset
allChecks
array insrc/checks/index.ts
yarn build
and committed the updated configuration filestheme-app-extension.yml
config