formatter: allow custom switch-case indentation
See original GitHub issueTypeScript Version: 2.5.2
Code
Format the following
switch (foo) {
case 'bar':
break;
}
Expected behavior:
Keep it the same.
Actual behavior:
case
is indented.
switch (foo) {
case 'bar':
break;
}
This becomes more problematic when used with tslint or javascript code with eslint, because on different systems we can see one winning over the other randomly i.e. sometimes the case is indented, sometimes it’s not (eslint rule says do not indent).
Issue Analytics
- State:
- Created 6 years ago
- Reactions:50
- Comments:21 (2 by maintainers)
Top Results From Across the Web
What is the preferred way to indent cases in a switch? [closed]
I find this to be the most readable format for the switch case construct. ... The first is the standard switch case indentation....
Read more >D43183 clang-format: introduce `CaseBlockIndent` to ... - LLVM
When a block is started after a case label, clang-format does add extra indent to the content of this block: the block content...
Read more >problem with code formatter and case indent
You can configure IntelliJ to format case statements with or withoutindentation.This works fine so long as you don't enclose your case...
Read more >astyle - indentation and reformatting filters for C, C++, C#, Java
Artistic Style (or astyle) is a source code indenter, formatter, and beautifier for ... Switches are indented to allow a run-in to the...
Read more >Google C++ Style Guide
Consistency also allows for automation: tools that format your code or adjust your ... in the common case, the loop or switch statement...
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
Hi guys, any news on this?
This is really a severe issue for me using autoformat in VS Code, so I cannot use autoformat due to this bug. And for me, one of the main tasks of IDE is to do code autoformat. IMO it’s a major failure of VS Code. All mature IDEs have configurable indentations.