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

Feature request: [tl! hide] (proposed solution to prettier moving comments) #4

Open
mcgrealife opened this issue Jan 28, 2023 · 1 comment

Comments

@mcgrealife
Copy link

Being able to use prettier to format code snippets before passing them to torchlight is a dream!

However, I've been regularly encountering a case where prettier moves my comment to a new line, changing which line torchlight highlights.

const fn = () => (
  <div> // [tl! highlight]
    <div></div>
  </div>
)

Which prettier formatting transforms to:

const fn = () => (
  <div>
    {' '}
    // [tl! highlight]
    <div></div>
  </div>
)

(With the [tl! highlight] is moved to a new line)

Does anyone have tips on how to prevent prettier from doing this? Or workarounds?

@mcgrealife
Copy link
Author

Using // prettier-ignore does solve prevent the comment from being moved – however, the prettier comment is then shown in my highlighted code snippet
prettier-ignore-comment-shown

A torchlight config to hide all // prettier-ignore comments might be a footgun

Maybe a // [tl! hide] comment would instruct torchlight to remove the entire comment? (not just the tl portion of the comment)

Like this

const fn = () =>
  // prettier-ignore // [tl! hide]
  <div> // [tl! highlight]
    <div></div>
  </div>

@mcgrealife mcgrealife changed the title Any tips on preventing prettier from moving comments? Feature request: [tl! hide] (proposed solution to prettier moving comments) Jan 28, 2023
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

No branches or pull requests

1 participant