liquid-schema-plugin icon indicating copy to clipboard operation
liquid-schema-plugin copied to clipboard

`Syntax Error in 'schema' - Valid syntax: schema`

Open tomaszs opened this issue 3 years ago • 4 comments

My webpack config looks like this:

new LiquidSchemaPlugin({
      from: {
          liquid: './src/sections',
          schema: './src/schema'
      },
      to: './dist/sections'
    }),

Inside schema folder I have put mycode.js file that looks like this:

module.exports = (filename, content) => {
  return content;
}

And i use it in a section located in sections folder that way:

{% schema 'mycode' %}

But I get error:

Syntax Error in 'schema' - Valid syntax: schema

And:

>>> ERR :: deployment failed undefined 1 null [development] Errors encountered: 
	[development] (sections/mysection.liquid) Liquid syntax error (line 39): Syntax Error in 'schema' - Valid syntax: schema
finished command with errors

I have tried adding to mysection this:

{% comment %}theme-check-disable ValidSchema,SyntaxError{% endcomment %}

And to my package.json file this:

theme-check --exclude-category liquid

But it does not work. How to make it work?

tomaszs avatar Jan 25 '22 12:01 tomaszs

Please could you share what the schema looks like in your dist/sections/mysection.liquid file?

If the schema in your section file is literally just {% schema 'mycode' %} the content variable in your mycode.js is probably null.

davidwarrington avatar Jan 25 '22 20:01 davidwarrington

Hello David,

It is whole schema, so there is schema tag like the one I wrote, than there is a valid JSON (validated and working) and then there is schema closing tag, something like this

{% schema 'mycode' %}
{
  "name": "Slideshow",
  "tag": "section",
  "class": "slideshow",
  "settings": [
    {
      "type": "text",
      "id": "title",
      "label": "Slideshow"
    }
  ],
  "blocks": [
     {
       "name": "Slide",
       "type": "slide",
       "settings": [
         {
           "type": "image_picker",
           "id": "image",
           "label": "Image"
         }
       ]
     }
   ]
}
{% endschema %}

When I remove mycode from the schema tag, everything works. It looks like the notation is not validated as a proper schema or something

tomaszs avatar Jan 25 '22 21:01 tomaszs

Hi @tomaszs, sorry for taking so long to get back to you.

Just to confirm, is the code block above from ./dist/sections/mysection.liquid or ./src/sections/mysection.liquid?

If it's the former it would seem my plugin isn't building your files properly but I've not been able to reproduce the issue. Would you be able to share a repo with the bare minimum required to replicate this issue?

As for your Theme Check error, it looks like Theme Check doesn't allow you to disable ValidSchema or SyntaxError rules with theme-check-disable comments. Depending on the other tools in your build this might be pointless, but you could perhaps try running Theme Check in your ./dist folder instead of ./src?

davidwarrington avatar Jan 31 '22 18:01 davidwarrington

Hello David,

It i from src file sorry. Missed that you wanted it from dist. Yeah. It seems like Theme Check. They should add a rule that handles your plugin

tomaszs avatar Feb 01 '22 10:02 tomaszs