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.

Bracket and Brace Together and Keep Multiline

See original GitHub issue

Hi, in my case, prettier formats a typescript code from:

Input (wanted)

this.messageService
  .prompt(this.name, [{
      name: 'value',
      type: 'number'
    }])

Output (formatted)

this.messageService
  .prompt(this.name, [
    {
      name: 'value',
      type: 'number'
    }
  ])

I expected keep bracket and braces together. (the first one) [{ ... not [\n\t{ ... Is there a option for e.g. .prettierrc

“prettier”: “^1.15.3”,

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Domvelcommented, Dec 12, 2018

I understand. I do agree the option philosophy. Not with all formats. But this is Prettier.

Conclusion: Options are generally forbidden. Prettier format style should be unified but the community can vote for changes.

In my case:

This (I prefer, compact)

[{
  one: 1
}, {
  two: 2
}, {
  three: 3
}]

vs Prettier (Easier to add / remove objects.)

[
  {
    one: 1
  },
  {
    two: 2
  }, 
  {
    three: 3
  }
]

Right? It’s ok. I can live with that. 😄

1reaction
Domvelcommented, Dec 12, 2018

Also another issue.

Input (wanted)

constructor(
  protected one: One,
  protected two: Two
) {}

Output (formatted)

constructor(protected one: One, protected two: Two) {}

Expceted

Keep multilines. This happend on other places too. Not only contructor. e.g. arguments in a method. Or multiple operator. like one && two && three (the line break after && is removed.)

Is there already a option? If not, this is a feature request.

I think Prettier counts the number of arguments for decision of single or multiline, right? Because other parts of my code is converted from single to multiline. This is great. But this should also happen to few arguments.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple lines one side of equation with a Curly Bracket - TeX
Multiple lines one side of equation with a Curly Bracket ... Large braces for specifying values of variables by condition (5 answers).
Read more >
How to bracket over multiple lines of text in Word document?
1. Click Insert > Shapes, then select a left or right brace shape from the drop-down list. · 2. Then draw a brace...
Read more >
When are curly braces not required for multi-line loop bodies?
You need curly braces when using multiple statements (not multiple lines). However it is good practise to always use the curly braces.
Read more >
How to make left curly bracket encompass multiple lines MS ...
make a left curly bracket enclose more than three lines to the right of it.Best Way to Type/Insert Parenthesis, Brackets.
Read more >
How to add a big curly bracket in Microsoft Word - YouTube
How to add a big curly bracket to multiple lines in Microsoft WordA big curly bracket is used normally in the situation of...
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