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.

Strange linebreak with long arguments and callbacks

See original GitHub issue

When a function call has a callback but also has many and/or long arguments, for specific lengths the callback formatting is quite strange.

Input:

someFunctionCallWithBigArgumentsAndACallback(thisArgumentIsQuiteLong, function(cool) {
  return cool
})

Actual Output (strange line break in function):

someFunctionCallWithBigArgumentsAndACallback(thisArgumentIsQuiteLong, function(
  cool
) {
  return cool;
});

Expected Output:

someFunctionCallWithBigArgumentsAndACallback(
  thisArgumentIsQuiteLong,
  function(cool) {
    return cool;
  }
);

Note that if thisArgumentIsQuiteLong is a little bit longer, or you add more parameters, the expected output formatting happens. It’s only for specific lengths that this strange formatting appears.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
suchipicommented, Oct 8, 2017

Do we have snapshots for these cases? If not, we should add them, so that we don’t introduce an unintentional regression later (considering the cause of the fix is unknown)

0reactions
thorn0commented, Feb 9, 2021

Fixed by https://github.com/prettier/prettier/pull/9662 Let’s add a test from this issue and close it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Better Line Breaks for Long URLs - CSS-Tricks
Soft or “shy” hyphens are great for breaking words, but bad news for URLs. It's not as big a deal on screens, since...
Read more >
Chart js v2 tooltip callback line breaks - Stack Overflow
I'm using chart js v2.3.0 by the way. UPDATE. I've fixed the problem! Convert the tooltip text to array of string (I'm gonna...
Read more >
Promisification - The Modern JavaScript Tutorial
Here, promisify assumes that the original function expects a callback with exactly two arguments (err, result) . That's what we encounter most ...
Read more >
argparse — Parser for command-line options, arguments and ...
Source code: Lib/argparse.py Tutorial: This page contains the API reference information. For a more gentle introduction to Python command-line parsing, ...
Read more >
Breaking up long lines of code in Python
As long as we have an open square bracket ( [ ), parenthesis ( ( ), or an open curly brace ( {...
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