single line if without else is put on one line
See original GitHub issuePrettier 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:
- Created 7 years ago
- Reactions:2
- Comments:16 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
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.