Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix comments for try-catch blocks #13747

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ortonpaul
Copy link

Description

Closes #13219

Checklist

Try the playground for this PR

@alex12058
Copy link

This MR looks good. It is annoying that prettier moves comments above a catch block into the catch block as if prevents me from being able to use // eslint-disable-next-line on a catch block so I have to also add // prettier-ignore to prevent the comment from being moved.

@fisker
Copy link
Member

fisker commented Mar 7, 2023

Prettier pr-13747
Playground link

--parser babel

Input:

// Comment 1
try { // Comment 2
  // Comment 3
}
// Comment 4
catch(e) { // Comment 5
  // Comment 6
}
// Comment 7
finally { // Comment 8
  // Comment 9
}
// Comment 10

Output:

// Comment 1
try {
  // Comment 2
  // Comment 3
} // Comment 4
catch (e) {
  // Comment 5
  // Comment 6
} finally {
  // Comment 7
  // Comment 8
  // Comment 9
}
// Comment 10

Commentt 7 should print above finally too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TryCatch block moves the comment an annoying location
3 participants