js-beautify
js-beautify copied to clipboard
Spaces after /*block comments*/
Input:
foo(2 /*IDCANCEL*/, "Cancel", 0x1 /*BMB_DEFAULT*/);
var bar = 1 /*SOME_CONST_1*/, baz = 2 /*SOME_CONST_2*/;
Output:
foo(2 /*IDCANCEL*/ , "Cancel", 0x1 /*BMB_DEFAULT*/ );
var bar = 1 /*SOME_CONST_1*/ ,
baz = 2 /*SOME_CONST_2*/ ;
So, we have unwanted (in some cases) space like /*comment*/ ;
May be add exclusions for some punctuations, e.g. space looks good for 1 /*SOME_CONST_1*/ | 2 /*SOME_CONST_2*/.
Yes please! :+1:
👍 this would be extremely useful especially when you use flow comment syntax for which you need to have inline comments
@abenhamdine - Please file a separate issue for supporting flow comment syntax. That is a separate issue.
@RCMax @Infocatcher - The reasoning would be "always a space before the comment, and if there were going to be a space between the two elements without the comment, there would be space after the comment.
So, 1 /*SOME_CONST_1*/ | 2 /*SOME_CONST_2*/ would be correct because 1 | 2 has spaces.
I took a quick try at this here: https://github.com/bitwiseman/js-beautify/tree/issue/879
you'd think this would be easy, but as the example shows - while one implementation is simple, there are a number of corner cases.