I've been using atom-beautify to format my JavaScript files. Suddenly today (after a couple of atom-beautify updates) I tried to format a JavaScript file, and it uses tabs instead of spaces. I went into atom-beautify settings and there is an "Indent with tabs" setting that is turned on.
Is this "Indent with tabs" option new in atom-beautify 0.29.22? Did an update modify its value?
In fact I went in and turned off "Indent with tabs", and atom-beautify is still formatting my JavaScript file with tabs instead of spaces. What's going on? I'm confident that I made no setting changes recently regarding spaces and tabs.
I updated atom-beautify today to latest version (0.29.22). My atom-beautify is not working!
Edit:Sorry it was the problem with tab spaces, I corrected it and now it's working fine.
@garretwilson Could you please generate the debug.md file and paste it into a gist. It will provide extra evidence for us to investigate why this happened.
@prettydiff I'd love to but I'm extremely busy. If you can't figure it out I'll just revert to a previous version for the meantime. Good luck.
@garretwilson , the current version seem to detect .js as .jsx file. this means Atom-beautify will always use JSX configuration option instead of JS.
until this issue is resolved, you have to use this work around method.
Edit: it seem language-babel package is the one cause this issue in my case. I solved this issue by turning it off.
Please follow the issue template provided. More specifically, adding a link to the required debug.md Gist which includes debugging information that answers our most commonly asked questions.
Thank you.
@garretwilson : The release v0.29.22 contains the PR https://github.com/Glavin001/atom-beautify/pull/1598 which extracts the default values from Atom Editor config. This was a highly requested feature for quite a while, however this fix may initially cause some unexpected issues for other users, such as yourself.
The defaultIndentWithTabs is set to not softTabs: https://github.com/Glavin001/atom-beautify/pull/1598/files#diff-188bc9de2eeb58f46a4f48e1585324f7R124
And softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true: https://github.com/Glavin001/atom-beautify/pull/1598/files#diff-188bc9de2eeb58f46a4f48e1585324f7R121
So that means your editor.softTabs setting for Atom editor must be set to false to cause defaultIndentWithTabs = true.
You can either configure the softTabs for the language in Atom's editor settings (desired functionality from https://github.com/Glavin001/atom-beautify/issues/894 ) or configure it directly within Atom-Beautify by overriding the default values indent_with_tabs and/or indent_char which are extracted from Atom editor's default.
Unfortunately, this is one of those "it's a feature, not a bug" scenarios. The default values for Atom-Beautify were hardcoded in releases prior to v0.29.22. Now they are extracted from Atom editor itself, which other users have requested, and may initially appear like a breaking change to users who did not request this feature. The solution is simple: change the configuration to be what you want, then it will be set for the future and override Atom editor's default.
I apologize for the confusion from this release. Fortunately, it should be very quick and simple to resolve for your editor and will not experience the issue in the future.
the current version seem to detect .js as .jsx file. this means Atom-beautify will always use JSX configuration option instead of JS.
@deforder the selecting of a grammar is performed by Atom editor itself and not Atom-Beautify. Atom-Beautify asks Atom editor for the current grammar of the file and uses it. If this is an issue for you, I recommend making an issue over at https://github.com/atom/atom
For reference, the Soft Tabs option is found in Atom settings -> Editor:

For changing the indent_size within Atom for a specific language you have two options: 1) the language package itself, or 2) Atom-Beautify settings directly.
Option 1) Language packages' settings
Let's use JavaScript language as an example.



Option 2) Atom-Beautify package settings



Hope this helps! 馃槂
There are so many wrong things going on here I don't know where to start.
First of all, I have Atom set up with "Tab Type: auto". This means that Atom _will automatically detect which tab type to use_ based on the file! atom-beautify is not auto-detecting. So v0.29.22 has the honor not only of doing indentation different than earlier versions of atom-beautify, it also now does it different than Atom is configured to do. In other words, v0.29.22 goes out of its way to _not_ match any tab setting you're currently using or were using previous, both in atom-beautify and in Atom.
You mention "For changing the indent_size within Atom for a specific language you have two options: 1) the language package itself, or 2) Atom-Beautify settings directly." But I don't see any settings under language-javascript that are relevant. There is no "indent size" for language-javascript. In fact I don't see anything at all related to spaces vs tabs here.
As I already mentioned above, I already went into my atom-beautify settings, I found the "JavaScript: Indent with tabs" option, and turned it off. Now atom-beautify still uses tabs. It isn't following Atom, and it isn't even following its own settings.
You shouldn't do breaking settings in a patch release. Yes, I know you're getting around the "letter of the law" of semvar by sticking to a 0.x.x version forever and ever, which means you can do whatever you want. But it's not expected. atom-beautify is established enough and used by enough people that you should be following semantic versioning. People do not expect breaking changes in a patch release. Please release a 1.x.x and if you want to break things, change it to a 2.x.x release, etc.
Lastly if you want to ignore all that advice, please at least place notes for breaking changes in the changelog. When this change happened, I immediately went to https://github.com/Glavin001/atom-beautify/blob/master/CHANGELOG.md to see if there were notes on this change. There were not. That's why I filed a bug.
atom-beautify is _still_ using tabs without spaces, and I can't get it to stop. I'm not going to change my Atom settings; I like the way it auto-detects things.
There are so many wrong things going on here I don't know where to start.
Then please provide the debug.md file so that we have evidence to investigate. You claim you don't have time to submit this, but clearly have time to review the numerous detailed examples provided by Glavin and write a long wordy reply.
Lastly if you want to ignore all that advice
Please watch the attitude. Everybody here is a volunteer. You aren't paying anybody for the time invested here.
You aren't paying anybody for the time invested here.
But I am happy to. Having this big hiccup in my workflow is costing me money. Plus there are some big (no, huge) bugs in HTML formatting inherited from js-beautify that is taking up so much of my time. As I've offered elsewhere (e.g. https://github.com/beautify-web/js-beautify/issues/1033#issuecomment-294654602 ), I will pay people to fix stuff, even in their own software, as it will help us all.
So I'll put my money where my mouth is. Please contact me personally, tell me how much you want to do what, and hopefully support PayPal.
By the way, if neither of you are personally interested in getting paid, if you know a JavaScript developer who would like some experience, send them my way. I have various JavaScript things needing done (mostly fixing bugs in open-source projects such as this one) and I would be happy to pay them. They would get paid experience, I would have fewer bugs bugging me every day, and you would get help in your projects. We would all win. Please let me know if you know anyone. Thanks.
I think https://www.bountysource.com/issues/44206478-atom-beautify-0-29-22-javascript-suddenly-switches-to-tabs may be appropriate. I have never used Bountysource before however it sounds like along the lines of what is being discussed.
The change for https://github.com/Glavin001/atom-beautify/issues/894 was not intended as a breaking change. It was a bug fix. Prior to https://github.com/Glavin001/atom-beautify/pull/864 the default settings for Atom-Beautify were automatically extracted from the Atom editor. This is what #894 fixed. With https://github.com/Glavin001/atom-beautify/pull/864 the settings were cached in a file src/options.json. This would be considered the breaking change for users who actually used Atom's editor and language-specific (i.e. scope) settings. I am not one of those users, however I try my best to support all of the different usages. While this bug was created in #894, the cached options.json file was leveraged by both documentation generation and improving Atom-Beautify package loading time. Thus the benefits of #894 outweighed the costs, unfortunately for some. However, I had not forgotten about them.
Throughout this year I have been working full-time while taking the full-time course schedule at University. This does not leave much time for family and friends as is, and severely limited by ability to contribute to Atom-Beautify. However, I just finished my final exams recently and the first thing I did was contribute to major bugs and add new features to Atom-Beautify. Unfortunately, these changes are causing some problems for users such as @garretwilson. I plan on resolving them, with your help. Just like the other users who put up with Atom-Beautify not supporting Atom editor's options, now that we support them, I want to help those users who are affected by this change.
I really do not like abusing semver's rule for 0.x.x releases and this was not my intention. I hoped it would just work for users. So long as users use .jsbeautifyrc or Atom-Beautify package settings, then they would not see any changes. However, it appears @garretwilson 's configure is "default" which now uses Atom editor's setting, which is not controlled by Atom-Beautify and may be different from the previous defaults hardcoded within Atom-Beautify. The fix should be easy and there are many options to override the Atom editor defaults by: 1) changing Atom editor's language settings (I do not use this, it was features from contributors), 2) configuring Atom-Beautify directly via package settings (I use this, confirm it works), 3) configuring with .jsbeautifyrc file (I use this, confirm it works).
Regardless, to help anyone debug these issues, we require the debug.md Gist with your debugging information. If you are asking questions similar to "why is it tabs and not spaces?" then the debug.md actually shows exactly why! This is why I spent a significant amount of time adding the Help Debug Editor feature.
This is why I put a firm rule: Atom-Beautify contributors will not be able to debug an issue without an accompanying debug.md Gist.
Finally, the goal of Atom-Beautify right now is to prepare for Unibeautify. While we may make unintentional breaking changes to Atom-Beautify the goal is to learn what works for everyone. Once this has been settled, Unibeautify will be completed and released as v1.x.x and will follow semver. Unfortunately, it is obvious we are still learning. Users have conflicting usages of Atom-Beautify, such as some users using Atom's editor settings while this change breaks it for other users.
Thank you for reporting your issue to us so we can work together to fix these issues, learn from them, and develop Unibeautify.
I hesitate to even reply again today, but I'm a little lost. 鈽癸笍
I tried to downgrade to 0.29.21 just so I could format my .js files. I removed atom-beautify then used apm install [email protected]. When I restarted Atom and tried to format a file, it told me I needed to migrate my settings (saying something about .js and .json). I found the migrate command and migrated the settings (or so it said). No when I go into Atom Beautify settings there is only a "General" section --- nothing for the languages. And my JavaScript files are being formatted with a different number of spaces.
How can I just wipe Atom Beautify clean, remove all the settings, and just go back to how it was working before?
There was a problem with the v0.29.21 release: https://github.com/Glavin001/atom-beautify/issues/1601
Note to self: Am I able to delete that release? I worry if I do anything it would unpublish the whole Atom-Beautify package from apm registry, so I left it.
I recommend Atom-Beautify 0.29.20 or 0.29.19.
I removed the stuff atom-beautify had added to config.cson and installed atom-beautify 0.29.20. The JavaScript formatting now seems to work the way it did before.
So long as users use .jsbeautifyrc or Atom-Beautify package settings, then they would not see any changes. However, it appears @garretwilson 's configure is "default"...
Let me say that I have nothing against tabs --- in fact I _prefer_ tabs! I also have nothing against .jsbeautifyrc --- in fact I use it for my XHTML files to provide consistent formatting for my Java course materials.
I started a new JavaScript project for a client, and rather than imposing my formatting opinion, I instead just took Atom Beautify's default JavaScript settings, assuming that Atom Beautify would choose JavaScript best practices as the default. If it chose spaces, fine. If it chose tabs, fine. I wanted to make it easier for new developers to the project to just be consistent out of the box, without any further configuration. I trusted Atom Beautify's decision.
So the biggest issue here is that Atom Beautify just decided to change its mind about how it gets its settings. If there's going to be something big like that, really, @Glavin001 , I implore you to update the release notes. That's what they are there for. If an explanation of all this would have been in the release notes, I would have read them this morning, grumbled for five minutes, went and created a .jsbeautifyrc file, and that would have been the end of that. There would have been no reason to file a bug. There would have been no reason to create a debug.md file.
I'm excited about the Bountysource you indicated. I'm going to try it out. If it works, I have so many bugs I want to get fixed for several projects. Thanks for the recommendation.
In the meantime, I'll create a jsbeautifyrc file that can be shared in the repository by developers, and go forward. If I could just ask you: is the tab setting the only thing I should be looking for that this latest change in v0.29.22 broke? It didn't change settings related to general JavaScript syntax, did it? If I simply use jsbeautifyrc to set indent to a certain number of spaces, I should be back to what my default settings were, right?
What specific settings should I be using? I note that for my XHTML files I was using "indent_with_tabs": true to get tabs. If for JavaScript I don't want tabs and instead want, for example, four spaces, do I set "indent_with_tabs": false and along with "indent_size": 4? Is this documented somewhere, or do I just look at the settings and guess what the object keys are?
Thank you.
@smaran39 and @deforder, if you have any problems please let me know and provide the debug.md to help us help you. Thanks!
I meet the same problem and set breakpoints to debug it, found that the default beautifier is pretty diff, then I found editor.getGrammar() returns JavaScript with JSX.
The problem is caused by language-javascript-jsx, everything is back to normal after I disable language-javascript-jsx.
Notice the grammar in bottom right:

Thanks @guyskk
So after being made aware of the change in behavior, I was able to address the original problem I reported by creating the following .jsbeautifyrc configuration file in my project:
{
"indent_size": 4,
"indent_with_tabs": false,
"indent_char": " ",
}
(It is odd that I must not only specify an indent character but also turn off tabs, which seems redundant, but yes I understand this is a js-beautify issue and should not be reported here.)
As noted I had been using atom-beautify's default settings because I had assumed that it was using widespread conventions. It turns out that many JavaScript style guides (e.g. that of Google) recommend two spaces instead of four as an indent. So I probably shouldn't have been "trusting" atom-beautify's default settings from the beginning. You live and learn. Still, a note in the changelog would have been nice.
As far as I'm concerned the original issue I brought up has been addressed. I don't know about the "JavaScript with JSX" problem --- I feel that is probably a separate problem and should be reported separately. I'll leave this issue open though; feel free to close it when you like.
@Glavin001 - I had one issue that got added to BountySource. It got attention, the issue had PRs submitted by two people at the same time and resulted in my having to choose one who would get paid and one who would get nothing. The one I did not choose felt the need to insult me. So, I'm not sure it's a win for the annoyance it caused.
Interesting to hear about unibeautify. I was planning on heading that same direction with js-beautifier (though, I'm probably much further away). Perhaps we could chat sometime about pooling our efforts.
The one I did not choose felt the need to insult me. So, I'm not sure it's a win for the annoyance it caused.
This is very disappointing to hear, @bitwiseman . I have no personal experience with BountrySource and had not considered such a scenario, however this does concern me. At the current time Atom-Beautify has no "backers": https://www.bountysource.com/teams/atom-beautify
Perhaps we could chat sometime about pooling our efforts.
Would love to work together! I am only now getting back into my open-source work, with school, large work projects, and vacation behind me. Should be big changes to Unibeautify (i.e. Atom-Beautify) coming soon!
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.
Most helpful comment
There are so many wrong things going on here I don't know where to start.
First of all, I have Atom set up with "Tab Type: auto". This means that Atom _will automatically detect which tab type to use_ based on the file! atom-beautify is not auto-detecting. So v0.29.22 has the honor not only of doing indentation different than earlier versions of atom-beautify, it also now does it different than Atom is configured to do. In other words, v0.29.22 goes out of its way to _not_ match any tab setting you're currently using or were using previous, both in atom-beautify and in Atom.
You mention "For changing the indent_size within Atom for a specific language you have two options: 1) the language package itself, or 2) Atom-Beautify settings directly." But I don't see any settings under language-javascript that are relevant. There is no "indent size" for language-javascript. In fact I don't see anything at all related to spaces vs tabs here.
As I already mentioned above, I already went into my atom-beautify settings, I found the "JavaScript: Indent with tabs" option, and turned it off. Now atom-beautify still uses tabs. It isn't following Atom, and it isn't even following its own settings.
You shouldn't do breaking settings in a patch release. Yes, I know you're getting around the "letter of the law" of semvar by sticking to a 0.x.x version forever and ever, which means you can do whatever you want. But it's not expected. atom-beautify is established enough and used by enough people that you should be following semantic versioning. People do not expect breaking changes in a patch release. Please release a 1.x.x and if you want to break things, change it to a 2.x.x release, etc.
Lastly if you want to ignore all that advice, please at least place notes for breaking changes in the changelog. When this change happened, I immediately went to https://github.com/Glavin001/atom-beautify/blob/master/CHANGELOG.md to see if there were notes on this change. There were not. That's why I filed a bug.
atom-beautify is _still_ using tabs without spaces, and I can't get it to stop. I'm not going to change my Atom settings; I like the way it auto-detects things.