dprint-plugin-typescript
dprint-plugin-typescript copied to clipboard
Long implementation comments (`//`) gets appended to the previous line
trafficstars
When preferSingleLine: true is set, long implementation comments are reformated as trailing comment to the previous line of code, even though they're not related with it.
(I'm aware I could use a multi-line comment (/* ... */) but we usually reserve those for doc comments).
Input Code
if (
cond1
// first line of a long comment related to cond2
// second line of a long comment related to cond2
|| cond2
) {
Expected Output
if (
cond1
// first line of a long comment related to cond2
// second line of a long comment related to cond2
|| cond2
) {
Actual Output
if (
cond1 // first line of a long comment related to cond2
// second line of a long comment related to cond2
|| cond2
) {
dprint-plugin-typescript version: 0.61.0
A similar situation:
Input Code
let result =
// comment for the first part of the expression
first
// explanation for the second part
+ second;
Expected Output
let result =
// comment for the first part of the expression
first
// explanation for the second part
+ second;
Actual Output
let result = // comment for the first part of the expression
first // explanation for the second part
+ second;