Closed friederbluemle closed 8 years ago
Okay it seems like this is a problem with js-beautify. It can be fixed by adding an option:
-a, --space-after-anon-function Add a space before an anonymous function's parens, ie. function ()
IMO this should be the default. Closing this issue on JsFormat.
How to add this option?
@friederbluemle Yeah could you please advise on how to add this to Settings - User?
@SiamKreative I do not have a way to verify at moment. I briefly checked js-beautify's README - did you try
"space_after_anon_function": true,
Yup, does not seem to work.
is working for me, steps:
1) Install JSformatter in sublime text 2) Preferences -> Package settings -> JSFormatter -> User 3) Introduce this:
{
"space_after_anon_function": true
}
4) Create a file to beautifull (file.js) and introduce:
var ModuleTwo = (function(random) { // This will be idented like the other function
random.extension = function () { // <---
// another method!
};
return random;
})(random);
4) Control + ALT + F 5) Enjoy 👯
If I am not mistaken, the
function
keyword (like most (all?) other keywords) should be followed by a space. Applying the JsFormat formatter results in this:Actual
Expected
EDIT: I just found this: http://javascript.crockford.com/code.html