question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
CiGitcommented, 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.

1reaction
Santosh8055commented, Feb 28, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prettier does not consistently respect .prettierrc, .eslintrc nor ...
I have a .prettierrc file, a .eslintrc file and even vscode settings with the same 80 print-width settings, but the extension just doesn't...
Read more >
Prettier vscode extension ignoring config files - Stack Overflow
In VS Code Press open Command Palette (Ctrl + Shift + P) · Search and select this: Format Document With... · After selecting...
Read more >
How to configure Prettier and VSCode - Gleb Bahmutov
This blog post shows how to configure Prettier to work from command line, from VSCode and from Git hooks.
Read more >
Options - Prettier
Prettier ships with a handful of format options. ... Prettier's printWidth option does not work the same way. It is not the hard...
Read more >
Prettier Code Formatter | Salesforce for VSCode
Prettier code formatter supports Aura and Lightning Web Components (LWC) as well as standard file formats such as JSON, Markdown, HTML, and JavaScript....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found