Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax Error in 'schema' - Valid syntax: schema #16

Open
tomaszs opened this issue Jan 25, 2022 · 4 comments
Open

Syntax Error in 'schema' - Valid syntax: schema #16

tomaszs opened this issue Jan 25, 2022 · 4 comments

Comments

@tomaszs
Copy link

tomaszs commented Jan 25, 2022

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?

@davidwarrington
Copy link
Owner

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.

@tomaszs
Copy link
Author

tomaszs commented Jan 25, 2022

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

@davidwarrington
Copy link
Owner

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?

@tomaszs
Copy link
Author

tomaszs commented Feb 1, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants