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.

single line if without else is put on one line

See original GitHub issue

Prettier changes

if (this.state.url !== url)
  this.toggleLoading(true);

to

if (this.state.url !== url) this.toggleLoading(true);

This is a style I don’t like. Is there any way to customize the prettier defaults?

I also find

this.state = { 
  theUrl: null, 
  myTitle: null, 
  loaded: false 
};

changed to

this.state = {theUrl: null, myTitle: null, loaded: false };

which is less readable imho

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
pstantoncommented, Nov 14, 2017

i disagree with this decision for the objective reason that it is harder to debug! you cannot step on-to or breakpoint the “then” line in a debugger if it is on the same line as the “if”. subjectively i feel it is harder to read as well, but the first reason should trump all others.

it should at least be configurable

2reactions
vjeuxcommented, May 21, 2017

We are now past 1.0 and we’re not going to change core printing like this one anymore. Sorry!

If you want code to be printed on the next line, you can add {}. Feel free to fork prettier if you really want this behavior.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python One Line If Without Else - Finxter
The first is also the most straightforward method: if you want a one-liner without an else statement, just write the if statement in...
Read more >
Python one line if without else | Example code - EyeHunts
You can write Python one line if without else statement by just avoiding an else. For it just writes the if statement in...
Read more >
c# - Single line If condition without else clause - Stack Overflow
1. You can't. Just use an if statement. · 4. The if (count==0) { count=2; } you started with is "a single line...
Read more >
Python If-Else Statement in One Line - Ternary Operator ...
One -Line If Statement (Without Else). A single-line if statement just means you're deleting the new line and indentation. You're still writing ...
Read more >
Single line if statement without else - MSDN - Microsoft
You don't. The conditional operator cannot be used for a single `if` statement. The closest you could do would be to set 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