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 is still breaking HTML in 2019

See original GitHub issue

VSCode, macOS

"printWidth": 80

<h1 [ngStyle]="{
  'color': h1Style ? 'gray' : 'black',
  'font-size': !h1Style ? '1em' : '4em'
}">Home</h1>

save result = broken html

<h1
  [ngStyle]="{
    color: h1Style ? 'gray' : 'black',
    'font-size': !h1Style ? '1em' : '4em'
  }"
>
  Home
</h1>

if edit line length < 80

<h1 [ngStyle]="{color: h1Style ? 'gray' : 'black',
'font-size': !h1Style ? '1em' : '4em'}">Home</h1>

save result = still broken html

<h1
  [ngStyle]="{
    color: h1Style ? 'gray' : 'black',
    'font-size': !h1Style ? '1em' : '4em'
  }"
>
  Home
</h1>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
azzcommented, Feb 6, 2019

Not sure what specifically is broken there? Maybe you’re after html-whitespace-sensitivity=strict?

Prettier 1.16.4 Playground link

--html-whitespace-sensitivity strict
--parser html

Input:

<h1 [ngStyle]="{
  'color': h1Style ? 'gray' : 'black',
  'font-size': !h1Style ? '1em' : '4em'
}">Home</h1>

Output:

<h1
  [ngStyle]="{
  'color': h1Style ? 'gray' : 'black',
  'font-size': !h1Style ? '1em' : '4em'
}"
  >Home</h1
>

0reactions
azzcommented, Feb 8, 2019

Yeah that’s the expected behaviour.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prettier not formatting HTML files in VS Code
Note - TS files and SCSS files are being formatted properly. It is breaking only for HTML files. Below is my HTML language...
Read more >
Prettier 1.16: HTML improvements and better CRLF handling
This release improves HTML formatting and contains better CRLF handling, new syntax features, and fixes several bugs.
Read more >
How to Setup Vue.js with VS Code and Fix Formatting and ES ...
When you create a Vue.js project with the Vue CLI or UI and select Prettier - you'll have a bunch of ES Lint...
Read more >
VS Code - You don't need a formatting extension (Prettier ...
VS Code has builtin formatters for HTML, JavaScript, TypeScript, ... I still avoid Prettier like hell, because working for an agency i have ......
Read more >
How I Resolved Vue.js, VSCode, Vetur, Prettyhtml, and ...
From what I could find, there's no way to tell Prettier to not wrap. ... option is js-beautify-html instead of Prettyhtml or Prettier....
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