Template JSON needs check for missing static block in Liquid file
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 234
- Forks
- 92
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 6
Description
Describe the bug
There's no error in a template JSON when a static block is referenced that the section/block never includes.
This type of check does exist in the SchemaPresetsStaticBlocks and ValidBlockTarget check; however, if a dev is not using presets, the issue won't be known.
Reproduction
Have a block that includes a static block with content_for 'block'; e.g. a _collection-card-image. And use it in a preset.
# blocks/collection-card.liquid
{% content_for 'block', type: '_collection-card-image', id: 'collection-card-image', %}
{% schema %}
{
"name": "t:names.collection_card",
"blocks": [...],
"settings": [...]
],
"presets": [
{
"name": "t:names.collection_card",
"blocks": {
"collection-card-image": {
"type": "_collection-card-image",
"static": true,
}
}
]
}
{% endschema %}
-
Have this block referenced in a template JSON, like
index.json. -
Delete the
content_for 'block'referenc
Expected behaviour
The SchemaPresetsStaticBlocks check successfully runs and warns me.
Static block
collection-card-imageis missing a corresponding content_for "block" tag.
The ValidBlockTarget is also helpful
Could not find a static block of type "_collection-card-image" with id "collection-card-image" in this file.theme-checkValidBlockTarget
I expect a similar warning in index.json
Actual behaviour
No warning in index.json
Having no presets illustrates that theme dev isn't given any warnings the contents of index.json are a problem.
Debugging information
- OS Mac
- Theme Check Version
3.16.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the existing SchemaPresetsStaticBlocks and ValidBlockTarget checks, then trace how template JSON files such as index.json are validated. Add equivalent detection for static blocks referenced from template JSON and verify that the missing content_for "block" case produces the expected warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100