Shopify / prettier-plugin-liquid

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

Prettier v3 doesn't run on .liquid files unless specified #208

Closed andershagbard closed 1 year ago

andershagbard commented 1 year ago

Describe the bug In Prettier v2, it was possible to just use prettier ., and it would run on on all files, including .liquid files. In Prettier v3, you have to use prettier --write '**/*.liquid' to make it run on .liquid files.

Debugging information

charlespwd commented 1 year ago

Yep that's a v3 breaking change from prettier unfortunately. I'm not happy with how they communicated it.

Try adding this to your .prettierrc.json

{
  "plugins": ["@shopify/prettier-plugin-liquid"]
}

https://github.com/prettier/prettier/issues/15088

andershagbard commented 1 year ago

Already have it in my config.

{
  "$schema": "https://json.schemastore.org/prettierrc.json",
  "printWidth": 100,
  "singleQuote": true,
  "plugins": ["@shopify/prettier-plugin-liquid", "prettier-plugin-tailwindcss"],
  "overrides": [
    {
      "files": ["**/*.liquid"],
      "options": {
        "singleQuote": false
      }
    }
  ]
}
charlespwd commented 1 year ago

I otherwise have no idea. Couldn't find a meaningful API change from their docs that says we should be doing something different on our end. Did they hardcode a default pattern in v3? Doesn't seem to be anything about that in the migration docs either...

andershagbard commented 1 year ago

Seems like a bug in Prettier. It semi-ignores my config file.

Running prettier using yarn prettier . --write --plugin="@shopify/prettier-plugin-liquid" --plugin="prettier-plugin-tailwindcss" works as expected.

andershagbard commented 1 year ago

Confirmed bug in prettier. Progress can be followed in this issue: https://github.com/prettier/prettier/issues/15079

emilqva commented 6 months ago

Just add this to settings.json in vscode:

{
"[liquid]": {
    "editor.defaultFormatter": "Shopify.theme-check-vscode",
    "editor.formatOnSave": true
  },
}

This will also enable format on save.

Velkamhell97 commented 5 months ago

Any solution ?

andershagbard commented 5 months ago

Any solution ?

Should be working now. Just update your packages