babel icon indicating copy to clipboard operation
babel copied to clipboard

Improved javascript regex regocnizing for extracting js messages

Open gitaarik opened this issue 4 years ago • 6 comments

In a JS library that I use, there was regex with a / inside a character class [a-z]. The babel JS lexer thought this closed the regex, but JavaScript allows this as a normal match character within a character class, and does not close the regex. I updated the regex so that it will cover this exception.

This could also possibly fix these issues, or set the stage for further improvements regarding these issues:

  • https://github.com/python-babel/babel/issues/640
  • https://github.com/python-babel/babel/issues/616

How do I add unit tests for this? I haven't found clear documentation about this.

gitaarik avatar Jun 09 '21 11:06 gitaarik

Hi @akx, have you had time to look at this? It would be nice if this can be merged.

gitaarik avatar Jul 13 '21 13:07 gitaarik

Hey @akx , could you please give me some guidance about how/where I should add unit tests for this? I haven't found clear documentation about this.

gitaarik avatar Feb 19 '22 19:02 gitaarik

@akx Got it now, I wasn't familiar with tox, but now I am, a little.

I added the unit test:

https://github.com/gitaarik/babel/blob/javascript-lexer-regex-parse-fix/tests/messages/test_js_extract.py#L156-L182

I would really appreciate it if this can be merged soon and that a new release could be made. Then the build process of our project can be greatly simplified :).

gitaarik avatar Feb 19 '22 21:02 gitaarik

Codecov Report

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

Comparison is base (65de3dc) 89.82% compared to head (b37389a) 89.82%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #791   +/-   ##
=======================================
  Coverage   89.82%   89.82%           
=======================================
  Files          25       25           
  Lines        4391     4391           
=======================================
  Hits         3944     3944           
  Misses        447      447           

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

codecov[bot] avatar Feb 23 '22 19:02 codecov[bot]

I'm not completely understanding this Codecov result, and what, if anything, is wrong.

gitaarik avatar Feb 24 '22 13:02 gitaarik

@akx Is what you requested done now? can this be merged?

michaeldg avatar Apr 07 '23 20:04 michaeldg