Shopify / prettier-plugin-liquid

Prettier Liquid/HTML plugin
https://npm.im/@shopify/prettier-plugin-liquid
MIT License
94 stars 15 forks source link

JSON output inconsistent with Theme Check #201

Closed nikitaourazbaev closed 11 months ago

nikitaourazbaev commented 11 months ago

Describe the bug The plugin formats the JSON inside a section’s schema, but the output differs from Theme Check so running both Prettier and Theme Check in a theme results in one formatter overwriting the other’s output.

Unformatted source

{% schema %}
{
  "name": "Test section",
  "disabled_on": {
    "groups": [
      "header",
      "footer"
    ]
  }
}
{% endschema %}

Expected output

{% schema %}
{
  "name": "Test section",
  "disabled_on": {
    "groups": [
      "header",
      "footer"
    ]
  }
}
{% endschema %}

Actual output

{% schema %}
{
  "name": "Test section",
  "disabled_on": {
    "groups": ["header", "footer"]
  }
}
{% endschema %}

Debugging information

Additional context I think this is due to this plugin using the json parser, maybe the json-stringify parser would produce results more in line with Theme Check? Example in a Prettier.io Playground.

Alternatively, a setting to disable JSON formatting and let Theme Check handle it would be nice to have.

Or is disabling Theme Check’s schema JSON formatting the better solution?

charlespwd commented 11 months ago

Acknowledged, but fixed in future version of theme-check (2.0) already running in the admin. The CLI/VS Code updates are coming soon, we're polishing things up.