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.

Option to never wrap single attributes and always wrap multiple attributes

See original GitHub issue

🚀 Feature Proposal

I don’t see a setting for attribute wrapping other than printWidth. This is surprisingly ok since with a pretty low printWidth, the default formatting is quite to my liking, but it ends up looking odd when wrapping single attribute elements. I would love a setting like this:

"wrapAttributesIgnoreSingle": true,
"wrapAttributesNumber": 2 // wrap all attributes when there are n or more 

or more simply but less flexible:

"wrapMultipleAttributes": true

Motivation

Approaching wrapping based on attribute number instead of length is fairly visually appealing, it makes it a little easier for humans to read, but so much easier for git to read, so it will reduce the number of git conflicts if multiple people change an element’s attributes. It is also in accordance with the official Vue.js styleguide

Example

Current output:

  <InputItem :input="inputs.currentAge"/>
  <InputItem
    :input="inputs.theRetirementAgeOfYourGreatestGrandMother"
  />
  <a href="#" class="a" rel="tag">A</a>

I would want a combination of settings that would get me this output:

  <InputItem :input="inputs.currentAge"/>
  <InputItem :input="inputs.theRetirementAgeOfYourGreatestGrandMother"/>
  <a 
    href="#" 
    class="a" 
    rel="tag"
  >A</a>

Vote

If you agree with my proposal vote with a 👍

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
StarpTechcommented, Nov 8, 2018

I decided to add a new option called wrapAttributes when true it will always wrap attributes when the element has more than one.

3reactions
StarpTechcommented, Oct 18, 2018

Hi @thedamon thanks for your proposal! I understand your reasons but I’m not convinced from your examples. Wrapping attributes based on the printWidth work for most of the use cases. I don’t want to add another option when they aren’t really required.

If you want to archive this formatting with the current solution you can use the ignore flag:

<InputItem :input="inputs.currentAge"/>
<!-- prettyhtml-ignore-->
<InputItem :input="inputs.theRetirementAgeOfYourGreatestGrandMother"/>
<!-- prettyhtml-ignore-->
<a href="#" class="a" rel="tag">A</a>
Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
flex-wrap - CSS: Cascading Style Sheets - MDN Web Docs
The flex-wrap CSS property sets whether flex items are forced onto one line or can wrap onto multiple lines. If wrapping is allowed,...
Read more >
Wrapping Attribute Text in SOLIDWORKS Electrical
To wrap attribute text in SOLIDWORKS Electrical, use the Multiple Attribute command in the Symbol Editor.
Read more >
Options - Prettier
Prose Wrap​​ Valid options: "always" - Wrap prose if it exceeds the print width. "never" - Un-wrap each block of prose into one...
Read more >
Content formatting options | Docs - TinyMCE
To replace existing classes, use the class attribute. ... formats: { // A custom format that wraps blocks into a div with the...
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