Open krishnanand opened 6 years ago
This is definitely a bug, and thank you for finding this issue so I can fix it in my fork.
If you are still trying to make this work and haven't solve this with another library yet because you want something like slimit, I just made a release of my fork of slimit (as calmjs.parse-1.1.0
) and this now works also:
>>> from calmjs.parse import es5
>>> code = 'function callbackFn(activate, options) {\n if (true)\n}'
>>> es5(code)
Traceback (most recent call last):
...
calmjs.parse.exceptions.ECMASyntaxError: Unexpected '}' at 3:1 after '\n' at 2:12
You may just simply catch SyntaxError
as ECMASyntaxError
inherits it.
This is my test case
Am I doing this incorrectly? If yes, how do I validate the string?