Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I stop prettier from formatting HTML files?

Tags:

html

prettier

So the problem is that prettier does not format html very well.

for instance if I have this angular template:

<some-component   some-attribute    [ang-binding1]='someExpr'   [ang-binding2]='someExpr'   (someEvent)='someFunc($event)'> </some-component> 

prettier will format it to something like this:

<some-component some-attribute [ang-binding1]='someExpr' [ang-binding2]='someExpr' (someEvent)='someFunc($event)'> </some-component> 

how do I disable prettier formating for html templates ?

like image 488
Rachid O Avatar asked May 09 '18 20:05

Rachid O


People also ask

How do I turn off prettier for a specific file?

To disable Prettier checks for a single file, we can add the path of the file we want Prettier to ignore into the . prettierignore file. We follow the . gitignore file syntax to add it.

How do you ignore prettier prettier?

Use . prettierignore to ignore (i.e. not reformat) certain files and folders completely. Use “prettier-ignore” comments to ignore parts of files.

How do you turn off prettier in a project?

Enable “Only format if prettier is found in your project's dependencies” or “Only format if a Prettier config is found” Disable format on save, save the file, then re-enable it again. Disable format on save and manually run format each time you want to format a file as desired from the command pallette.


1 Answers

If you are using VS Code, you can prevent Prettier from running on HTML (or other specific languages) by adding the following to your settings:

"prettier.disableLanguages": ["html"]

You can find other VS Code specific options at the prettier/prettier-vscode GitHub page.

like image 173
clintoncrick Avatar answered Sep 21 '22 13:09

clintoncrick