I have been looking around the web for a good Sublime (3) package to use to auto-format my source code in various languages, namely JavaScript. I came across this SOF post (Sublime Text 2: Auto fix indentation for javascript?) and thus decided to give JSFormat a try. So far, it seems to work pretty good...except for when it handles JSON objects in the JS code. For example, let's say that I have a function like this:
function foo() {
return {name: 'Dave', score: 1000};
}
It returns a JavaScript object in JSON format, prettu much a hash object. I like writing such objects in one line because it is simple and easy to read, especially since it is just a small, ad-hoc object. But, if I were to format this with JSFormat, my function would now look like this:
function foo() {
return {
name: 'Dave',
score: 1000
};
}
Maybe this is just me, but I really don't like representing such simple JSON objects in multiple lines. Yes, normally JavaScript code that requires braces should have its contents on a separate lines from the braces, such as functions, if statements and loops. Maybe if the JSON object was a long object that contained functions inside of it, such as a jQuery Ajax class, then it makes sense to separate the attributes onto multiple lines.
Nonetheless, regardless whether my points about the braces makes sense, I know that JSFormat supports configuration and perhaps there is a way to configure JSFormat to not separate the attributes of a JSON object into multiple lines, if it is not desired. Any ideas?