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.

Line comment between function an opening brace

See original GitHub issue

If you have the opening brace of a function on its own line, and a line comment after the function signature, the output of prettier is different if you run it once or twice.

Prettier 1.14.3 Playground link

--parser babylon

Input:

function foo() // this is a function
{
  return 42
}

Output:

function foo() { // this is a function
  return 42;
}

Second Output:

function foo() {
  // this is a function
  return 42;
}

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jaideng123commented, Oct 10, 2018

I can work on this

0reactions
alexander-akaitcommented, Oct 11, 2018

@jaideng123 Just handle 1 and 2 variants

Read more comments on GitHub >

github_iconTop Results From Across the Web

What do you think of opening brace comments in source code?
I have developed a habit of writing comments in my code by putting the comments on the same line as the opening brace,...
Read more >
What's the purpose of using braces (i.e. {}) for a single-line if or ...
The first code is concise; the second code is bloated. And yes, this can be mitigated to some extent by putting the opening...
Read more >
Function opening brace is moved to the next line ... - YouTrack
Function opening brace is moved to the next line when arguments span multiple lines an a return type (PHP 7) is specified.
Read more >
Where Do Curly Braces Belong? - Jeremy Bytes
But for other blocks (such as the "if" statement), the curly brace is on the same line.
Read more >
Why are curly braces in programming languages important?
Curly braces play a big role in code structure within popular programming languages such as Java, C++ and more. Here's how to properly...
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