cases in switch statements not indented
See original GitHub issueprettier is printing cases at the same indentation level as their parent switch statement. I indent cases inside a switch statement.
Now:
switch (something) {
case "foo":
// ...
break;
case "bar":
// ...
break;
}
Ideally:
switch (something) {
case "foo":
// ...
break;
case "bar":
// ...
break;
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
java - Why the strange indentation on switch statements?
In Eclipse (Java) the default case of the switch is automatically indented, it is not "un-dented" like the cases are. I would think...
Read more >Reason for non-indented case statements in switch (go fmt)
I think the reason is that the current formatting already makes clear what's the switch scope and what are the scopes of the...
Read more >Swift's SWITCH indenting is driving me mad... any way to fix ...
One case for cases being at the same indentation would be that case statements aren't really code. it's more like multiple if statements,...
Read more >C++ Switch Statement Indentation - Visual Studio Feedback
Using Ctrl-K Ctrl-F to format a switch statement results in switch statement contents being cascaded, not indented by case. The example switch statement...
Read more >Allow case statement indentation to align with the switch
Create an option to align case statement with its parent switch. ... It is controlled by special option: "Setting -> Editor -> Code...
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
Just some additional insight into why it may be helpful to indent case statements:
My opinion is that due to
case
ending in a:
, it should be treated the same as a label, and not indented.