11ty / eleventy-plugin-webc

Adds support for WebC *.webc files to Eleventy
https://www.11ty.dev/docs/languages/webc/
119 stars 10 forks source link

.webc does not work with prettier #88

Open iamdench opened 1 year ago

iamdench commented 1 year ago

Hello, I like prettier and i want to use it not only with ".html" but also with ".webc". But now I have this problem:

image

My versions of devDependencies:

    "@11ty/eleventy": "2.0.1",
    "@11ty/eleventy-plugin-webc": "0.11.1",
    "prettier": "2.5.1"

My .prettierrc.json:

{
  "overrides": [
    {
      "files": "*.webc",
      "options": {
        "parser": "html"
      }
    }
  ]
}

Can I solve this problem?

georgedoescode commented 10 months ago

I know this isn't a direct solution to your problem, but, if you happen to use VSCode...

Try adding:

  "files.associations": {
    "*.webc": "html"
  }

To your .vscode/settings.json (or wherever you store your config!)

This should hopefully make Prettier play nicely with .webc files.

I imagine a similar approach may work for other editors, but I couldn't say for sure!

urob commented 2 months ago

Running prettier with the CLI argument --parser html works for me. E.g.

npx prettier --parser html src/index.webc

For anyone using neovim, there is an excellent universal formatter plugin, conform, that automates this using the following config:

require("conform").formatters.prettier = {
    options = {
        ext_parsers = {
            webc = "html",
        },
    },
}