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.

formatter: allow custom switch-case indentation

See original GitHub issue

TypeScript Version: 2.5.2


Format the following

switch (foo) {
case 'bar':

Expected behavior:

Keep it the same.

Actual behavior:

case is indented.

switch (foo) {
  case 'bar':

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:open
  • Created 6 years ago
  • Reactions:50
  • Comments:21 (2 by maintainers)

github_iconTop GitHub Comments

vincenzovitalecommented, Feb 21, 2018

Hi guys, any news on this?

xmedekocommented, Apr 6, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

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 Post

No results found

github_iconTop Related Hashnode Post

No results found