From c593cc53ccdd340b1d14fcfab293922da0736a23 Mon Sep 17 00:00:00 2001 From: stephanie chou Date: Tue, 13 Oct 2026 14:03:11 -0700 Subject: [PATCH 1/2] Accept visible_if on setting types that ignore it --- schemas/theme/setting.json | 42 +++++++++++++++------- tests/section.spec.ts | 5 ++- tests/test-constants.ts | 1 + tests/theme-settings/color_palette.spec.ts | 8 ++--- tests/theme_block.spec.ts | 9 +++-- 5 files changed, 39 insertions(+), 26 deletions(-) diff --git a/schemas/theme/setting.json b/schemas/theme/setting.json index 01ca8c1..ff440c8 100644 --- a/schemas/theme/setting.json +++ b/schemas/theme/setting.json @@ -201,7 +201,8 @@ "default": true, "label": true, "info": true, - "id": true + "id": true, + "visible_if": { "$ref": "#/definitions/ignoredConditionalSetting" } }, "additionalProperties": false }, @@ -221,7 +222,8 @@ "default": true, "label": true, "info": true, - "id": true + "id": true, + "visible_if": { "$ref": "#/definitions/ignoredConditionalSetting" } }, "additionalProperties": false }, @@ -237,7 +239,8 @@ "default": true, "label": true, "info": true, - "id": true + "id": true, + "visible_if": { "$ref": "#/definitions/ignoredConditionalSetting" } }, "additionalProperties": false }, @@ -273,7 +276,8 @@ "default": true, "label": true, "info": true, - "id": true + "id": true, + "visible_if": { "$ref": "#/definitions/ignoredConditionalSetting" } }, "additionalProperties": false }, @@ -293,7 +297,8 @@ "default": true, "label": true, "info": true, - "id": true + "id": true, + "visible_if": { "$ref": "#/definitions/ignoredConditionalSetting" } }, "additionalProperties": false }, @@ -368,7 +373,8 @@ "additionalProperties": { "type": "string" }, "description": "A map of palette color names to color values. Each key is an arbitrary name and each value is a CSS color.", "markdownDescription": "A map of palette color names to color values.\n\nEach **key** is an arbitrary name. Each **value** is a CSS color, typically a hex code.\n\n**Example:**\n```json\n\"default\": {\n \"background\": \"#ffffff\",\n \"foreground\": \"#000000\"\n}\n```\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/settings/input-settings#color_palette)" - } + }, + "visible_if": { "$ref": "#/definitions/ignoredConditionalSetting" } }, "additionalProperties": false }, @@ -495,7 +501,8 @@ ] }, "info": true, - "id": true + "id": true, + "visible_if": { "$ref": "#/definitions/ignoredConditionalSetting" } }, "required": ["definition", "role"], "additionalProperties": false @@ -647,7 +654,8 @@ "default": true, "label": true, "info": true, - "id": true + "id": true, + "visible_if": { "$ref": "#/definitions/ignoredConditionalSetting" } }, "required": ["metaobject_type"], "additionalProperties": false @@ -672,7 +680,8 @@ "default": true, "label": true, "info": true, - "id": true + "id": true, + "visible_if": { "$ref": "#/definitions/ignoredConditionalSetting" } }, "required": ["metaobject_type"], "additionalProperties": false @@ -726,7 +735,8 @@ "default": true, "label": true, "info": true, - "id": true + "id": true, + "visible_if": { "$ref": "#/definitions/ignoredConditionalSetting" } }, "additionalProperties": false }, @@ -742,7 +752,8 @@ "default": true, "label": true, "info": true, - "id": true + "id": true, + "visible_if": { "$ref": "#/definitions/ignoredConditionalSetting" } }, "additionalProperties": false }, @@ -762,7 +773,8 @@ "default": true, "label": true, "info": true, - "id": true + "id": true, + "visible_if": { "$ref": "#/definitions/ignoredConditionalSetting" } }, "additionalProperties": false }, @@ -1113,6 +1125,12 @@ } }, + "ignoredConditionalSetting": { + "$comment": "visible_if on setting types that don't support it. Accepted so the file saves, but ignored by the theme editor.", + "description": "visible_if isn't supported on this setting type. It's ignored and the setting is always visible in the theme editor.", + "markdownDescription": "`visible_if` isn't supported on this setting type. It's ignored and the setting is always visible in the theme editor.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/storefronts/themes/architecture/settings#conditional-settings)" + }, + "inputSettingsStandardAttributes": { "required": ["type", "id", "label"], "properties": { diff --git a/tests/section.spec.ts b/tests/section.spec.ts index fa5b970..f20ff19 100644 --- a/tests/section.spec.ts +++ b/tests/section.spec.ts @@ -251,7 +251,7 @@ describe('JSON Schema validation of Liquid theme section schema tags', () => { ); it.each(SETTINGS_TYPES_NOT_SUPPORTING_VISIBLE_IF)( - 'should not allow visible_if on %s setting type', + 'should accept (and ignore) visible_if on %s setting type', async (settingType) => { const schema = { settings: [ @@ -265,10 +265,9 @@ describe('JSON Schema validation of Liquid theme section schema tags', () => { }; const diagnostics = await validate('sections/section.liquid', schema); - expect(diagnostics).toContainEqual( + expect(diagnostics).not.toContainEqual( expect.objectContaining({ message: 'Property visible_if is not allowed.', - severity: 1, }), ); }, diff --git a/tests/test-constants.ts b/tests/test-constants.ts index e8b0dda..49fd0eb 100644 --- a/tests/test-constants.ts +++ b/tests/test-constants.ts @@ -1,3 +1,4 @@ +// visible_if is accepted on these types so files still save, but the theme editor ignores it. export const SETTINGS_TYPES_NOT_SUPPORTING_VISIBLE_IF = [ 'article', 'article_list', diff --git a/tests/theme-settings/color_palette.spec.ts b/tests/theme-settings/color_palette.spec.ts index 551736c..d2d2e82 100644 --- a/tests/theme-settings/color_palette.spec.ts +++ b/tests/theme-settings/color_palette.spec.ts @@ -52,16 +52,12 @@ describe('Module: theme settings validation (config/settings_schema.json)', () = ]); }); - it('refuses the visible_if property', async () => { + it('accepts (and ignores) the visible_if property', async () => { const diagnostics = await validate( 'config/settings_schema.json', settings({ visible_if: '{{ section.settings.show_palette }}' }), ); - expect(diagnostics).toStrictEqual([ - expect.objectContaining({ - message: 'Property visible_if is not allowed.', - }), - ]); + expect(diagnostics).toStrictEqual([]); }); it('requires the default property', async () => { diff --git a/tests/theme_block.spec.ts b/tests/theme_block.spec.ts index c419455..a5b571d 100644 --- a/tests/theme_block.spec.ts +++ b/tests/theme_block.spec.ts @@ -243,7 +243,7 @@ describe('JSON Schema validation of Liquid theme block schema tags', () => { expect(diagnostics).toStrictEqual([]); }); - it.each(SETTINGS_TYPES_NOT_SUPPORTING_VISIBLE_IF)('should not allow visible_if on %s setting type', async (settingType) => { + it.each(SETTINGS_TYPES_NOT_SUPPORTING_VISIBLE_IF)('should accept (and ignore) visible_if on %s setting type', async (settingType) => { const schema = { settings: [ { @@ -254,12 +254,11 @@ describe('JSON Schema validation of Liquid theme block schema tags', () => { } ] }; - + const diagnostics = await validate('blocks/block.liquid', schema); - expect(diagnostics).toContainEqual( + expect(diagnostics).not.toContainEqual( expect.objectContaining({ - message: 'Property visible_if is not allowed.', - severity: 1 + message: 'Property visible_if is not allowed.' }) ); }); From 5663e8998a6d5aefd5de9b44612a182ca8589500 Mon Sep 17 00:00:00 2001 From: stephanie chou Date: Thu, 15 Oct 2026 10:29:02 -0700 Subject: [PATCH 2/2] Require visible_if to be a string on setting types that ignore it --- schemas/theme/setting.json | 1 + tests/section.spec.ts | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/schemas/theme/setting.json b/schemas/theme/setting.json index ff440c8..e6a10c2 100644 --- a/schemas/theme/setting.json +++ b/schemas/theme/setting.json @@ -1127,6 +1127,7 @@ "ignoredConditionalSetting": { "$comment": "visible_if on setting types that don't support it. Accepted so the file saves, but ignored by the theme editor.", + "type": "string", "description": "visible_if isn't supported on this setting type. It's ignored and the setting is always visible in the theme editor.", "markdownDescription": "`visible_if` isn't supported on this setting type. It's ignored and the setting is always visible in the theme editor.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/storefronts/themes/architecture/settings#conditional-settings)" }, diff --git a/tests/section.spec.ts b/tests/section.spec.ts index f20ff19..87ef368 100644 --- a/tests/section.spec.ts +++ b/tests/section.spec.ts @@ -273,6 +273,29 @@ describe('JSON Schema validation of Liquid theme section schema tags', () => { }, ); + it.each(SETTINGS_TYPES_NOT_SUPPORTING_VISIBLE_IF)( + 'should still require visible_if to be a string on %s setting type', + async (settingType) => { + const schema = { + settings: [ + { + type: settingType, + id: 'test_setting', + label: 'Test Setting', + visible_if: 42, + }, + ], + }; + + const diagnostics = await validate('sections/section.liquid', schema); + expect(diagnostics).toContainEqual( + expect.objectContaining({ + message: 'Incorrect type. Expected "string".', + }), + ); + }, + ); + it('should complete the type property with the generic docs', async () => { const result = await complete( service,