Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
yenoiwesa opened this issue Nov 14, 2018 · 8 comments
Labels
bug locked Please open a new issue and fill out the template instead of commenting.

Comments

@yenoiwesa
Copy link

yenoiwesa commented Nov 14, 2018

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).

@CiGit
Copy link
Member

CiGit commented Nov 15, 2018

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

@CiGit CiGit added the bug label Nov 15, 2018
@yenoiwesa
Copy link
Author

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

@wghglory
Copy link

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.

@levinit
Copy link

levinit commented Dec 24, 2018

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 .

@CiGit
Copy link
Member

CiGit commented Feb 1, 2019

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.

@Santosh8055
Copy link

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

@ntotten ntotten modified the milestone: Version 3.0 Oct 21, 2019
@ntotten
Copy link
Member

ntotten commented Oct 22, 2019

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

@ntotten ntotten closed this as completed Oct 22, 2019
@github-actions
Copy link

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 github-actions bot added the locked Please open a new issue and fill out the template instead of commenting. label Apr 12, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug locked Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

6 participants