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

how to align comments at the end of lines?

Open Yuan-Hang opened this issue 7 years ago • 5 comments

Expect this:

var a = 1;   // comment1
var bb = 22; // comment2

But got this:

var a = 1; // comment1
var bb = 22; // comment2

Yuan-Hang avatar Feb 18 '18 15:02 Yuan-Hang

This issue is currently wrecking the formatting on a bunch of code I wrote awhile ago, but am now just trying to use in an environment that uses js-beautify. Has anything ever happened with this? Why would any formatter automatically strip all whitespace before comments? Is there a setting to control this? If not, I don't think I can continue to use js-beautify.

jfriend00 avatar Jan 16 '21 08:01 jfriend00

@jfriend00

This issue is currently wrecking the formatting on a bunch of code I wrote awhile ago, but am now just trying to use in an environment that uses js-beautify. Has anything ever happened with this? Why would any formatter automatically strip all whitespace before comments?

As you may have noticed from https://github.com/prettier/prettier/issues/10068 this not uncommon.

If not, I don't think I can continue to use js-beautify.

That is unfortunate but unavoidable. I hope you'll take this experience and reflect on how you might get more traction on issues that matter to you by asking nicely and offering to contribute. Contributors and maintainers of projects like this are volunteers. Comments consisting purely of pointed remarks about the quality/design/implementation of project are particularly ineffective since they make people less interested in working with you.

bitwiseman avatar Jan 21 '21 20:01 bitwiseman

That is unfortunate but unavoidable.

Why is it unavoidable? Nobody believes there's any algorithm that could do better?

jfriend00 avatar Jan 21 '21 22:01 jfriend00

If not, I don't think I can continue to use js-beautify.

That is unfortunate but unavoidable.

Why is it unavoidable? Nobody believes there's any algorithm that could do better?

Of course not. The problem isn't finding an algorithm. The problem is finding a person with the time and inclination to design, implement, test, and document this feature. I gathered from your statements that you expect that person to be someone other than you. That seems very unlikely, thus "unfortunate but unavoidable".

If I was wrong and you are interested in doing this work, I suggest you start by reading the CONTRIBUTING.md and try building the project locally. If you have questions along the way. Please come to the gitter.im channel for the project.

bitwiseman avatar Jan 25 '21 21:01 bitwiseman

In case it helps anyone, you can accomplish something similar by using spaces inside your comments.

var a = 1; //    comment1
var bb = 22; //  comment2

p2edwards avatar Sep 23 '23 20:09 p2edwards