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 prints 1 attribute per line

See original GitHub issue

Input:

<div class="main__image-list main-image-list--margin main__image-list-one"></div>

Output:

<div
      class="main__image-list main-image-list--margin main__image-list-one"
    ></div>

Another example Input:

   <link
      rel="stylesheet"href="https://use.fontawesome.com/releases/v5.6.3/css/all.css"  integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous" />

Output:

   <link
      rel="stylesheet"
      href="https://use.fontawesome.com/releases/v5.6.3/css/all.css"
      integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/"
      crossorigin="anonymous"
    />

And more others tags (img…)

this is a bug or a trick? What do you think about ?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:28 (11 by maintainers)

github_iconTop GitHub Comments

23reactions
mpro7commented, Jan 16, 2019

Not sure if my case refers to this issue, but it seems kinda similar. I’ve set Prettier VSC extension html.format.wrapLineLength and prettier.printWidth properties to the same value. Every time the line length is larger that defined, it causes not needed formatting - each property goes into the new line:

<grid-column
	field="formatCode"
	title="Format"
	width="65"
	class="status-column cell-with-button"
	*ngIf="width > 1"
	[class]="{ codeColumn: true }"
	[hidden]="columns[7].hidden"
></grid-column>

I would like to have the line wrapped only to necessary number of lines, which means the next property which exceed the line length goes to next line etc.:

<grid-column field="incoTermCode" title="Incoterm" width="65"
	class="status-column cell-with-button" *ngIf="width > 1"
	[class]="{ codeColumn: true }" [hidden]="columns[7].hidden"
></grid-column>

I’m not sure if this feature already exists, but it would be nice to have it.

14reactions
mhamricommented, Jan 9, 2020

+1, breaking 100 attribute to 100 line doesn’t make sense. the printWidth rule should be respected and when there is still room to fill in one line, why break things in a new line?

image

here for a small text like icon=something & size="m" spared one line each?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prettier 2.6: new singleAttributePerLine option and new ...
This release includes a new singleAttributePerLine option. This is an option to print only one attribute per line in Vue SFC templates, ...
Read more >
Prettier: Single Attribute Per Line : r/reactjs - Reddit
Prettier will only switch to one attribute per line if you approach the target print width. You can increase the print width to...
Read more >
How do you stop Prettier in VS code splitting attributes onto ...
A quick fix is to go to Prettier Extension Settings (ctrl + shift + X) and in Prettier Extension Settings search for "Print...
Read more >
Prettier on Twitter: "We just released Prettier 2.6, featuring new ...
This release includes a new `singleAttributePerLine` option. This is an option to print only one attribute per line in Vue SFC templates, HTML, ......
Read more >
What Did Prettier Do to My HTML? - WalkingRiver.com
Prettier's decision of displaying one-attribute-per line means that each change affects exactly one line. Changes are easy to spot; they clearly ...
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