When attaching comments and generating code there seems to be a bug with the placement of inline comments.
They always break up the line which can lead to problems, for example when returning objects in strict mode.
Lets take this sample code snippet:
function test() {
"use strict";
return /** some inline comment */ {
someFunc: function() {}
};
}
When parsing it with acorn and then attaching comments with escodegen and generating the code like this:
When attaching comments and generating code there seems to be a bug with the placement of inline comments. They always break up the line which can lead to problems, for example when returning objects in strict mode. Lets take this sample code snippet:
When parsing it with acorn and then attaching comments with escodegen and generating the code like this:
the output is generated as
Notice how the curly brace of the object got moved to a new line, which breaks due to the strict mode, similar to this error (https://stackoverflow.com/a/63953324/5843525)
It generally seems to be a problem that inline comments break up code lines in unexpected ways.