Shopify / prettier-plugin-liquid

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

Add support for `.html` files #182

Closed khoait closed 5 months ago

khoait commented 1 year ago

Is your feature request related to a problem? Please describe.

I'm trying to use the plugin for .html containing liquid. and I get the error

Extension 'Shopify Liquid' is configured as formatted but it cannot format 'HTML'-files

It would be nice if the plugin can support .html in addition to .liquid files.

Describe the solution you'd like

the plugin can format .html files in the same manner as .liquid files.

Describe alternatives you've considered N/A

Checklist

Additional context I'm using VS Code on Windows.

aurelienbobenrieth commented 1 year ago

Have you tried changing your VS Code user settings with:

  "[html]": {
    "editor.defaultFormatter": "Shopify.theme-check-vscode",
  }

Didn't try it myself though, just an idea.

johnpuddephatt commented 5 months ago

I was able to do this by adding the following to my .prettierrc.json:

{
  "plugins": ["@shopify/prettier-plugin-liquid"],
  "overrides": [
    {
      "files": "*.html",
      "options": {
        "parser": "liquid-html"
      }
    }
  ]
}