'Editing Prettier options in Vscode

I need to enable .tpl files to be formatted like HTML by Prettier. I've found on GitHub this block of code who should do it :

 overrides: [
 {
   files: '*.html.tpl',
   options: { parser: 'html' },
 },
],

How should I implement it?



Solution 1:[1]

Go to File -> Preferences -> Settings.

In the search for box, search for "Associations" and then click on "Edit on settings.json".

Add the following to the JSON file:

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

Solution 2:[2]

You have multiple options as of the syntax you want to use.

Here is an exemple in JSON:

//.prettierrc.json
{
  "semi": false,
  "overrides": [
    {
      "files": "*.html.tpl",
      "options": { "parser": "html" },
    },
  ],
}

You have more exemples on the documentation.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Morta1
Solution 2 Baldráni