twoslashes / twoslash

Markup for generating rich type information in your documentations ahead of time.
https://twoslash.netlify.app/
MIT License
430 stars 16 forks source link

feat: support spaces before cut comments #33

Closed sapphi-red closed 3 months ago

sapphi-red commented 3 months ago

Currently twoslash requires the cut comment to be at the beginning of the line. If I wanted to cut out the type comment for a variable in a function, I have to write it like below.

function foo() {
  const x = "123"
// ---cut-start---
  /** @type {"345"} */
// ---cut-end---
  const b = "345"
}

But if that project uses prettier, it will be formatted and the comments will have a space before the // like below.

function foo() {
  const x = "123"
  // ---cut-start---
  /** @type {"345"} */
  // ---cut-end---
  const b = "345"
}

So I'll have to disable prettier for this part of the code (https://github.com/vitejs/vite/blob/48a2bbb9994f9cd67e3d7455a57f6579f64e784d/docs/config/build-options.md?plain=1#L51-L66).

This PR allows the cut comment to have space characters before.

netlify[bot] commented 3 months ago

Deploy Preview for twoslash ready!

Name Link
Latest commit 7a53d315933a2ba8c5f83547d4458a1027f030cc
Latest deploy log https://app.netlify.com/sites/twoslash/deploys/660420bbee7fee0008d5e11a
Deploy Preview https://deploy-preview-33--twoslash.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.25%. Comparing base (249c9d7) to head (7a53d31).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #33 +/- ## ======================================= Coverage 95.25% 95.25% ======================================= Files 16 16 Lines 1982 1982 Branches 347 347 ======================================= Hits 1888 1888 Misses 94 94 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.