Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: jsx indentation with 'switch' statements #597

Closed
cgong-strade opened this issue Oct 8, 2015 · 11 comments
Closed

Bug: jsx indentation with 'switch' statements #597

cgong-strade opened this issue Oct 8, 2015 · 11 comments

Comments

@cgong-strade
Copy link

@prettydiff ,
The indentations starting from line 3 are not quite right, please look into this.

before:

function getDisplay(value) {
  switch (value) {
    case 12 :
      return 'Within 1 year';
    case 24 :
      return 'Within 2 years';
    case 999 :
      return 'Any';
  }
}

after:

function getDisplay(value) {
  switch (value) {
  case 12 :
    return 'Within 1 year';
  case 24 :
    return 'Within 2 years';
  case 999 :
    return 'Any';
  }
}
@prettydiff
Copy link
Collaborator

No, this is intentional. Originally when I started building JavaScript beautifiers they were primarily tooled towards the JSLint style guide, because at the time it was the complete and easily testable style guide around for JavaScript. This is what JSLint recommends.

I could put an option to indent the case sections as nested blocks, but most of the style guides are moving towards guidance of strong opposition to switch/case.

@cgong-strade
Copy link
Author

Thanks for the reply. I have noticed that in js files atom-beautify would actually indent the case by two space from switch. We are currently using jsx and js files together and experiencing eslint conflicts between the two. Can you reconcile them or advice. Thanks

@prettydiff
Copy link
Collaborator

I can hide the default behavior behind an option.

@cgong-strade
Copy link
Author

yeah, it would be great if you can provide the option.

@axelson
Copy link

axelson commented Oct 15, 2015

+1 for the ability to configure the switch/case indentation behavior in Javascript.

@calidion
Copy link

it is problem solved? i run into this problem too.

@prettydiff
Copy link
Collaborator

@calidion Could you create a debug.md file using Atom Beautify and paste that into a gist? It will provide me all the details I need to reproduce the problem.

@nakamorichi
Copy link

Still no possibility to set switch/case indentation in JavaScript (or even better, autoload the SwitchCase setting from .eslintrc) ?

@Glavin001
Copy link
Owner

Does the Js Beautify also have this issue? If so, please create an issue over at https://github.com/beautify-web/js-beautify and reference back to this Issue. Thanks.

@nakamorichi
Copy link

nakamorichi commented Jul 20, 2016

Just realized that the jslint-happy setting was the culprit. Turned it off and the indentation got fixed. However, would still be nice to have possibility to set this directly from .eslintrc, as suggested in #897 .

@stale
Copy link

stale bot commented Nov 4, 2017

This issue has been automatically marked as stale because it has not had recent activity. If this is still an issue, please add a comment. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 4, 2017
@stale stale bot closed this as completed Nov 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants