mlly icon indicating copy to clipboard operation
mlly copied to clipboard

fix: comment stripping should remove multiline comments (#279)

Open cjpearson opened this issue 1 year ago • 4 comments

Resolves #279

cjpearson avatar Oct 04 '24 16:10 cjpearson

Thanks for the PR dear @cjpearson

Removing multi-line comments without AST awareness can be unsafe this is why we don't it.

See https://github.com/unjs/mlly/pull/56 for some context.

Until https://github.com/unjs/mlly/issues/219 arrives, if we can find similar solution to #56 i am open to it otherwise i would wait.

pi0 avatar Oct 06 '24 20:10 pi0

Codecov Report

Attention: Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 84.08%. Comparing base (226a47b) to head (c4ab502). Report is 62 commits behind head on main.

Files with missing lines Patch % Lines
src/syntax.ts 91.66% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #280      +/-   ##
==========================================
- Coverage   88.04%   84.08%   -3.96%     
==========================================
  Files           8        8              
  Lines        1062      823     -239     
  Branches      188      201      +13     
==========================================
- Hits          935      692     -243     
- Misses        127      131       +4     

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

codecov[bot] avatar Oct 06 '24 20:10 codecov[bot]

Oh I didn't realize acorn was already in this package. I think that would be a much better way to handle comments. I'll take a look at that approach.

cjpearson avatar Oct 07 '24 08:10 cjpearson

I've tweaked the approach to use acorn rather than regular expressions for the comment stripping. My understanding is #219 will cover replacing ESM_RE and CJS_RE, so I made it so the change just affects comment stripping portion. Once #219 is done I suppose the comment stripping will be entirely unnecessary

cjpearson avatar Oct 07 '24 11:10 cjpearson