js-beautify icon indicating copy to clipboard operation
js-beautify copied to clipboard

Spaces after /*block comments*/

Open Infocatcher opened this issue 9 years ago • 4 comments
trafficstars

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*/.

Infocatcher avatar Feb 20 '16 06:02 Infocatcher

Yes please! :+1:

RCMax avatar May 10 '16 17:05 RCMax

👍 this would be extremely useful especially when you use flow comment syntax for which you need to have inline comments

abenhamdine avatar Dec 02 '16 11:12 abenhamdine

@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.

bitwiseman avatar Dec 23 '16 19:12 bitwiseman

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.

bitwiseman avatar May 12 '18 00:05 bitwiseman