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
RegExp parse errors in regexpp are not tolerated and crash eslint #12169
RegExp parse errors in regexpp are not tolerated and crash eslint #12169
Comments
Hi @Jessidhia, thanks for the issue. I think at the very least, we should wrap the regex parse in a try/catch statement and then bail out gracefully if we can. I'm very curious to know what happens in the default parser. Seems to me this should be a parse error, even before any rules are run. |
It is indeed parsing error in the default parser (demo) I believe this is a bug in |
Sounds like this should be filed in the |
I agree that this is a problem in |
Based on @mysticatea's last comment, I think we should accept this bug and put a try/catch around the regex parse. We would need to figure out how best to handle these cases: Either ignore that regex, or emit a lint warning that the regex can't be parsed. |
I think that ignoring syntax errors makes sense. Syntax errors should be reported by parsers and the purpose of |
The rule will also crash with the default parser on this: /*eslint no-misleading-character-class: error */
new RegExp("{", "u"); so this isn't just an issue with The other 3 rules that use @Jessidhia would you like to submit a PR for this fix? |
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
@typescript-eslint/parser
, but the crash is in theregexpp
instance used by theno-misleading-character-class
rule.Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
/{/u
It happens on the command line as well but this is particularly bothersome with editor plugins (e.g. vscode integration), as you get plugin crash messages while typing up regexps.
What did you expect to happen?
No crash, at worst just an "invalid regexp" lint.
What actually happened? Please include the actual, raw output from ESLint.
To be clear, this is indeed a syntax error, it's not a false positive on my input code; rather, it's an unhandled error happening inside the rule when a regexp is invalid.
Are you willing to submit a pull request to fix this bug?
Maybe, I don't know how this should be handled.
The text was updated successfully, but these errors were encountered: