Skip to content

Comments between ) and { on if/then/else is not stable #618

@vjeux

Description

@vjeux
async function f() {
  if (untrackedChoice === 0) /* Cancel */ {
    return null;
  } else if (untrackedChoice === 1) /* Add */ {
    await repository.addAll(Array.from(untrackedChanges.keys()));
    shouldAmend = true;
  } else if (untrackedChoice === 2) /* Allow Untracked */ {
    allowUntracked = true;
  }
}

turns into

async function f() {
  if (untrackedChoice === 0)
    /* Cancel */ {
      return null;
    }
  else if (untrackedChoice === 1)
    /* Add */ {
      await repository.addAll(Array.from(untrackedChanges.keys()));
      shouldAmend = true;
    }
  else if (untrackedChoice === 2)
    /* Allow Untracked */ {
      allowUntracked = true;
    }
}

https://jlongster.github.io/prettier/#%7B%22content%22%3A%22async%20function%20f()%20%7B%5Cn%20%20if%20(untrackedChoice%20%3D%3D%3D%200)%20%2F*%20Cancel%20*%2F%20%7B%5Cn%20%20%20%20return%20null%3B%5Cn%20%20%7D%20else%20if%20(untrackedChoice%20%3D%3D%3D%201)%20%2F*%20Add%20*%2F%20%7B%5Cn%20%20%20%20await%20repository.addAll(Array.from(untrackedChanges.keys()))%3B%5Cn%20%20%20%20shouldAmend%20%3D%20true%3B%5Cn%20%20%7D%20else%20if%20(untrackedChoice%20%3D%3D%3D%202)%20%2F*%20Allow%20Untracked%20*%2F%20%7B%5Cn%20%20%20%20allowUntracked%20%3D%20true%3B%5Cn%20%20%7D%5Cn%7D%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Atrue%2C%22trailingComma%22%3Atrue%2C%22bracketSpacing%22%3Atrue%2C%22doc%22%3Afalse%7D%7D

which then turns into

async function f() {
  if (untrackedChoice === 0) {
    /* Cancel */ return null;
  } else if (untrackedChoice === 1) {
    /* Add */ await repository.addAll(Array.from(untrackedChanges.keys()));
    shouldAmend = true;
  } else if (untrackedChoice === 2) {
    /* Allow Untracked */ allowUntracked = true;
  }
}

https://jlongster.github.io/prettier/#%7B%22content%22%3A%22async%20function%20f()%20%7B%5Cn%20%20if%20(untrackedChoice%20%3D%3D%3D%200)%5Cn%20%20%20%20%2F*%20Cancel%20*%2F%20%7B%5Cn%20%20%20%20%20%20return%20null%3B%5Cn%20%20%20%20%7D%5Cn%20%20else%20if%20(untrackedChoice%20%3D%3D%3D%201)%5Cn%20%20%20%20%2F*%20Add%20*%2F%20%7B%5Cn%20%20%20%20%20%20await%20repository.addAll(Array.from(untrackedChanges.keys()))%3B%5Cn%20%20%20%20%20%20shouldAmend%20%3D%20true%3B%5Cn%20%20%20%20%7D%5Cn%20%20else%20if%20(untrackedChoice%20%3D%3D%3D%202)%5Cn%20%20%20%20%2F*%20Allow%20Untracked%20*%2F%20%7B%5Cn%20%20%20%20%20%20allowUntracked%20%3D%20true%3B%5Cn%20%20%20%20%7D%5Cn%7D%5Cn%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Atrue%2C%22trailingComma%22%3Atrue%2C%22bracketSpacing%22%3Atrue%2C%22doc%22%3Afalse%7D%7D

But... seriously, why would you put comments there!?

Metadata

Metadata

Assignees

No one assigned

    Labels

    locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions