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

Use optional jsonc on schema tags #815

Open
1 task done
eloyesp opened this issue Feb 24, 2025 · 4 comments
Open
1 task done

Use optional jsonc on schema tags #815

eloyesp opened this issue Feb 24, 2025 · 4 comments

Comments

@eloyesp
Copy link

eloyesp commented Feb 24, 2025

Shopify added support for comments and trailing commas for the theme files. Prettier have support for those using JSON5 JSONC parser and prettier can use that format on the *.json files (with some config), but the liquid plugin does not permit using that format on the json embedded on liquid files (on the schema tag).

As far as I could test, shopify accepts the prettier output for jsonc format, so it would make the prettier plugin output easier to review, so adding support there would match the principles.

That said, this feature cannot be implemented directly, because it would introduce an unexpected failure, as it would make code that was correct, now be incorrect. So we would need to add a setting (false by default until the next mayor version) to use jsonc format for the json embedded on the liquid files. With the setting, developers could choose when to migrate to JSONC format on the files.

Checklist

  • I have checked and made sure that the proposal adheres to this plugin's principles
@eloyesp
Copy link
Author

eloyesp commented Feb 25, 2025

JSON5 is not supported as formatted by prettier, because it does not allow identifiers as object keys.

@eloyesp eloyesp closed this as completed Feb 25, 2025
@eloyesp
Copy link
Author

eloyesp commented Feb 25, 2025

I've been testing and it seems that shopify accepts the output for jsonc files perfectly, so I've updated the issue and it can be reopen.

@eloyesp
Copy link
Author

eloyesp commented Feb 25, 2025

This is the output of using jsonc:

{% schema %}
{
  /* coment */
  "name": "Slideshow",
  "tag": "section",
  "class": "slideshow",
  "limit": 1, // comment
  "settings": [
    {
      "type": "text",
      "id": "title",
      "label": "Slideshow",
    },
  ],
  "max_blocks": 5,
  "blocks": [
    {
      "name": "Slide",
      "type": "slide",
      "settings": [
        {
          "type": "image_picker",
          "id": "image",
          "label": "Image",
        },
      ],
    },
  ],
  "presets": [
    {
      "name": "Slideshow",
      "settings": {
        "title": "Slideshow",
      },
      "blocks": [
        {
          "type": "slide",
        },
        {
          "type": "slide",
        },
      ],
    },
  ],
  "locales": {
    "en": {
      "title": "Slideshow",
    },
    "fr": {
      "title": "Diaporama",
    },
  },
  "enabled_on": {
    "templates": ["*"],
    "groups": ["footer"],
  },
}
{% endschema %}

@eloyesp eloyesp reopened this Feb 25, 2025
@eloyesp eloyesp changed the title Use optional JSON5 on schema tags Use optional jsonc on schema tags Feb 25, 2025
@eloyesp
Copy link
Author

eloyesp commented Feb 25, 2025

It seems that jsonc support were just added on prettier v3.2, so this option won't work with prettier v2

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

1 participant