feat(theme-check-common): warn when select default isn't a valid option#1185
Open
SinhSinhAn wants to merge 1 commit into
Open
feat(theme-check-common): warn when select default isn't a valid option#1185SinhSinhAn wants to merge 1 commit into
SinhSinhAn wants to merge 1 commit into
Conversation
ee0c3f2 to
e5c9de8
Compare
aswamy
reviewed
Jun 12, 2026
aswamy
left a comment
Contributor
There was a problem hiding this comment.
Hey @SinhSinhAn, thanks for another PR. Please ensure all of your PRs (including this one) follows our PR template to ensure everything is tested properly before submitting it:
https://github.com/Shopify/theme-tools/blob/main/.github/PULL_REQUEST_TEMPLATE.md
I've also written some review comments below.
Warns when a select/radio setting's default value, a preset's setting
value, or a section default.settings value is not one of the setting's
declared options. Covers {% schema %} in sections/blocks and
config/settings_schema.json.
Closes Shopify#943
e5c9de8 to
0f68bc0
Compare
Contributor
Author
|
Thanks for the review @aswamy! Addressed everything:
The branch is rebased to a single commit on top of latest |
Contributor
|
@SinhSinhAn please include a screenshot to ensure this VSCode extension was actually tested when running theme-tools. Not just unit tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are you adding in this PR?
This adds a new theme-check,
ValidSelectDefault, that warns when aselectorradiosetting'sdefaultvalue isn't one of the values declared in itsoptions. Today you can ship a schema whosedefaultdoesn't exist inoptionsand theme-check stays silent. The merchant then sees the editor silently fall back to the first option (or no selection), which is confusing and easy to miss in review.solves #943The check validates three places:
defaultvalue.settingsvalues (presets[i].settings).default.settingsvalues.It runs in two variants, mirroring
ValidVisibleIf:ValidSelectDefault(LiquidCheck) →{% schema %}insections/*.liquidandblocks/*.liquid.ValidSelectDefaultSettingsSchema(JSONCheck) →config/settings_schema.json.Severity is
WARNINGand it'srecommended: true, so it surfaces out of the box without blocking themes that have legacy schemas.Example
{ "type": "select", "id": "alignment", "default": "this-is-not-an-option", "options": [ { "value": "flex-start", "label": "t:options.alignment.left" }, { "value": "center", "label": "t:options.alignment.center" }, { "value": "flex-end", "label": "t:options.alignment.right" } ] }Now warns:
Default value "this-is-not-an-option" for setting "alignment" is not one of the valid options: "flex-start", "center", "flex-end".The preset case from the issue gets a warning pointing right at the offending value inside
presets[i].settings.What's next? Any followup issues?
None planned. The check leaves non-scalar mismatches to JSON schema validation, so it stays focused on the select/radio option case.
What did you learn?
The factory configs (
all.yml/recommended.yml) are generated frommeta.code, so two checks sharing the samecode(the Liquid + JSON variants, likeValidVisibleIf) collapse to a single config entry.Tophatting
Tested via unit tests rather than screenshots (this is a non-visual lint check). 13 new tests in
valid-select-default/index.spec.tscover:defaultforselectandradiodefault(no-op)default.settingsinvalid valueconfig/settings_schema.jsonvia theJSONCheckvariant (valid, invalid, wrong-file path)The full
theme-check-commonchecks suite stays green (780 tests across 79 files), andtsc --noEmitpasses.Before you deploy
This PR includes a new check
changesetpnpm buildand committed the updated configuration files (all.yml,recommended.yml)theme-app-extension.ymlconfig — not applicable; the check is generally relevant and isn't theme-app-extension specific.My feature is backward compatible