@@ -40,21 +40,27 @@ export const LiquidFreeSettings: LiquidCheckDefinition = {
4040
4141 visit < SourceCodeType . JSON , void > ( jsonFile , {
4242 Property ( schemaNode , ancestors ) {
43- if ( isInArrayWithParentKey ( ancestors , 'settings' ) && isLiteralNode ( schemaNode . value ) ) {
44- const { value, loc } = schemaNode . value ;
45- const propertyValue = schemaNode . key . value ;
46- if (
47- typeof value === 'string' &&
48- propertyValue !== 'visible_if' &&
49- value . includes ( '{%' ) &&
50- value . includes ( '%}' )
51- ) {
52- context . report ( {
53- message : 'Settings values cannot contain liquid logic.' ,
54- startIndex : node . blockStartPosition . end + loc ! . start . offset ,
55- endIndex : node . blockStartPosition . end + loc ! . end . offset ,
56- } ) ;
57- }
43+ if (
44+ ! isInArrayWithParentKey ( ancestors , 'settings' ) ||
45+ ! isLiteralNode ( schemaNode . value ) ||
46+ isLiquidType ( ancestors )
47+ ) {
48+ return ;
49+ }
50+
51+ const { value, loc } = schemaNode . value ;
52+ const propertyValue = schemaNode . key . value ;
53+ if (
54+ typeof value === 'string' &&
55+ propertyValue !== 'visible_if' &&
56+ value . includes ( '{%' ) &&
57+ value . includes ( '%}' )
58+ ) {
59+ context . report ( {
60+ message : 'Settings values cannot contain liquid logic.' ,
61+ startIndex : node . blockStartPosition . end + loc ! . start . offset ,
62+ endIndex : node . blockStartPosition . end + loc ! . end . offset ,
63+ } ) ;
5864 }
5965 } ,
6066 } ) ;
@@ -67,6 +73,22 @@ function isLiteralNode(node: JSONNode): node is LiteralNode {
6773 return node . type === 'Literal' ;
6874}
6975
76+ function isLiquidType ( ancestors : JSONNode [ ] ) : boolean {
77+ const parentJsonNode = ancestors . at ( - 1 )
78+
79+ if ( ! parentJsonNode || parentJsonNode . type !== 'Object' ) {
80+ return false ;
81+ }
82+
83+ return parentJsonNode . children . some ( ( { key, value } ) => {
84+ if ( key . value !== 'type' || ! isLiteralNode ( value ) ) {
85+ return false ;
86+ }
87+
88+ return value . value === 'liquid' ;
89+ } ) ;
90+ }
91+
7092function isInArrayWithParentKey ( ancestors : JSONNode [ ] , parentKey : string ) : boolean {
7193 return ancestors . some ( ( ancestor , index ) => {
7294 const parent = ancestors [ index - 1 ] ;
0 commit comments