-
Notifications
You must be signed in to change notification settings - Fork 453
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
Option to preserve inline object #776
Comments
The default beautifier for JavaScript is JS Beautify unless you change the beautifier in the Atom Beautify settings to Pretty Diff. JS Beautify had a big update last week featuring more advanced object support and destructuring. Would you be able to provide a sample of code so that we can produce the issue and indicate if you are using the default beautifier or Pretty Diff? |
I am using the default JS Beautify, and a simple example is "databaseStructure": [
{name: "id", type: "autonumber", primaryKey: true},
{name: "uid", type: "number", required: true},
{name: "reason", type: "string"},
{name: "addedDate", type: "datetime", required: true},
{name: "addedBy", type: "number", required: true}
] which get's expanded to "databaseStructure": [
{
name: "id",
type: "autonumber",
primaryKey: true
},
{
name: "uid",
type: "number",
required: true
},
{
name: "reason",
type: "string"
},
{
name: "addedDate",
type: "datetime",
required: true
},
{
name: "addedBy",
type: "number",
required: true
}
] after using JS beautify, and it's very annoying for me because I prefer to keep them on a single line. |
The output appears to be completely correct, though you are asking for a different stylistic preference. I will include @bitwiseman so that he can weigh in if this is an enhancement that he would like to pursue for JS Beautify. I just checked this in Pretty Diff and I am not supporting this preference either. We both support object flattening, but only in certain contexts. Universal object flattening is not something that has been requested to me and is generally not desired if the objects large enough to produce horizontal scrolling. |
JSBeautify 1.6.x supports keeping inline objects by setting brace-style to This input remains unchanged when that setting is used: {
"databaseStructure": [
{ name: "id", type: "autonumber", primaryKey: true },
{ name: "uid", type: "number", required: true },
{ name: "reason", type: "string" },
{ name: "addedDate", type: "datetime", required: true },
{ name: "addedBy", type: "number", required: true }
]
} |
Then a new option will need to be added to the tool to support this feature. |
Ah, I see. I could make this functionality the default for |
I'd love to have support for |
@kaaloo Would you mind writing a pull request add this option to the tool? It would be really helpful to the project and just think of all that open source fame and glory you would receive as a project contributor. |
Ha ha, sure I can try! |
There you go, seems to work on my end. |
[#776] Bump jsbeautify to 1.6.2. Add support for collapse-preserve-inline
Is there a new way to do this now because I cannot for the life of me figure out how to preserve my inline objects at the moment... Thanks! |
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. |
@noah-wisch hit the Debug option under the Atom Beautify menu... and see which language setting to change. I was changing my Java Script brace-style but Atom Beautify was applying JSX beautify settings to my .js files.
|
Not sure why it's happening now and never happened before to me, but the JS beautifier expands every object to a key:value per line, instead of keeping them in a single line. This is very annoying for short objects which could be kept on a single line but instead are expanded to several lines.
The text was updated successfully, but these errors were encountered: