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

Invalid error "unescaped or unmatched closing brace" #101

Closed
jens-duttke opened this issue Mar 5, 2020 · 1 comment · Fixed by #102
Closed

Invalid error "unescaped or unmatched closing brace" #101

jens-duttke opened this issue Mar 5, 2020 · 1 comment · Fixed by #102

Comments

@jens-duttke
Copy link

jens-duttke commented Mar 5, 2020

The latest Babel version (7.8.7) is using this package in the latest version (0.6.3), which now produces an error (with Babel 7.8.4 this error did not occur).

This regular expression is an absolutely valid JavaScript expression:

/\{([^}]+)\}/gu

But regjsparser throws the following error:
{code}
Module build failed (from ../node_modules/babel-loader/lib/index.js):
SyntaxError: ...\src\ts\context\i18n\index.tsx: unescaped or unmatched closing brace at position 6
{([^}]+)}
^
at bail (...\node_modules\regjsparser\parser.js:1129:13)
at createCharacter (...\node_modules\regjsparser\parser.js:237:11)
at parseClassAtomNoDash (...\node_modules\regjsparser\parser.js:1105:16)
at parseClassAtom (...\node_modules\regjsparser\parser.js:1094:16)
at parseNonemptyClassRanges (...\node_modules\regjsparser\parser.js:1052:18)
at parseClassRanges (...\node_modules\regjsparser\parser.js:1008:15)
at parseCharacterClass (...\node_modules\regjsparser\parser.js:986:15)
at parseAtom (...\node_modules\regjsparser\parser.js:649:22)
at parseTerm (...\node_modules\regjsparser\parser.js:490:18)
at parseAlternative (...\node_modules\regjsparser\parser.js:463:21)
at parseDisjunction (...\node_modules\regjsparser\parser.js:443:16)
at finishGroup (...\node_modules\regjsparser\parser.js:520:18)
at parseGroup (...\node_modules\regjsparser\parser.js:516:14)
at parseAtom (...\node_modules\regjsparser\parser.js:665:16)
at parseTerm (...\node_modules\regjsparser\parser.js:490:18)
at parseAlternative (...\node_modules\regjsparser\parser.js:463:21)
{code}

If I escape the }, this error does is gone:

/\{([^\}]+)\}/gu

but here, the ESLint rule "no-useless-escape", correctly complains about the useless escaping.

@jviereck
Copy link
Owner

Pushed v0.6.4 including #102 to NPM: https://www.npmjs.com/package/regjsparser/v/0.6.4.

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