dprint-plugin-typescript icon indicating copy to clipboard operation
dprint-plugin-typescript copied to clipboard

Long implementation comments (`//`) gets appended to the previous line

Open thbt opened this issue 3 years ago • 1 comments
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

thbt avatar Jan 12 '22 00:01 thbt

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;

upsuper avatar Jan 13 '22 03:01 upsuper