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 ?
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.
Use . prettierignore to ignore (i.e. not reformat) certain files and folders completely. Use “prettier-ignore” comments to ignore parts of files.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With