prettier-vscode icon indicating copy to clipboard operation
prettier-vscode copied to clipboard

Prettier-VSCode does not respect .prettierrc configuration for HTML formatting

Open yenoiwesa opened this issue 8 years ago • 8 comments

I am having similar issues to the ones that have been raised before, prettier-vscode does not seem to respect my project's .prettierrc.json configuration when formatting HTML files. The print width seems to be defaulted to 80 instead of our custom value of 100.

{
    "printWidth": 100,
    "tabWidth": 4,
    "singleQuote": true
}

My vscode is setup to format on save, and our project's package.json references "prettier": "1.15.2". The extension is up to date in vscode too. Our project does not have a print width setting in the .editorconfig file either.

I created a video reproduction of the issue where I save an AngularJS template file in vscode and it gets wrongly re-formated, and then apply the Prettier CLI on that file which puts it back to its correct format.

The video is available here (Dropbox - 2.1 MB).

yenoiwesa avatar Nov 14 '18 21:11 yenoiwesa

Can you share the repo shown in your video? (Not private) Can you debug it?

CiGit avatar Nov 15 '18 16:11 CiGit

I created the following repository with one html file that reproduces the issue: vscode-prettier-bug.zip

screen shot 2018-11-16 at 9 12 05 am

yenoiwesa avatar Nov 15 '18 22:11 yenoiwesa

I wanna use default vscode formatter for html. I guess perviously prettier doesn't have html formatter, but in 1.7.2, prettier tries to format html, so it doesn't respect vscode default html formatter. I also tried to set "prettier.disableLanguages": ["html"], but this disables default vscode formatter as well.

wghglory avatar Nov 16 '18 08:11 wghglory

same problem, install 1.6.1, it works .(this problem happened since ver1.7.0+ ) Also you can disable html in settings,"prettier.disableLanguages": ["html"] @wghglory .

levinit avatar Dec 24 '18 13:12 levinit

It seems we do not infer the same parser as prettier's cli. This extension uses angular parser where prettier uses html parser. CLI:

  • *.component.html -> angular
  • *.html -> html Extension:
  • html languageId -> angular parser

The extension doesn't take into account files' extensions, only vscode's languageId

To workaround this issue. You can specify explicitly the parser you want to use.

CiGit avatar Feb 01 '19 09:02 CiGit

In my case, another extension was causing this issue. I uninstalled "XML Tools" and it started working!

Santosh8055 avatar Feb 28 '19 08:02 Santosh8055

VS Code now prompts you to select which formatter to use when you have multiple on the same file type.

ntotten avatar Oct 22 '19 20:10 ntotten

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Apr 12 '20 18:04 github-actions[bot]