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
Adds try/catch to the ESLint processor preprocess task #1093
Conversation
…the original code if an error is thrown by the underlying parser (e.g. a parsing error outside the template strings).
An error indicates bug, you should never suppress unexpected errors. |
@JounQin The syntax error will be reported by ESLint so it will be caught. Ideally @babel/parser would be called with the ErrorRecovery flag set to true. But graphql-tag-pluck does not seem to give any control on that. Additionally it's not clear that this would be enough in all parsing error cases. I think the right thing to do is to suppress the error so that ESLint can proceed and the syntax error can be reported. I would add a warning message when running ESLint in debug mode, so that debugging is easier. |
This is similar situation for all processors. If the syntax is correct, then it's a bug of this plugin. If the syntax is incorrect, then a clearer crash error should help the user to understand. Maybe ESLint should support |
See ESLint discussion here: eslint/eslint#16015 (reply in thread) |
So if I don't understand incorrectly, @btmills agreed to |
I think it is under consideration. I still think it's bad form for a preprocessor to throw, but not sure how preprocessor would be intended to report errors to ESLint core. |
@B2o5T what do you think? |
See eslint/eslint#16104 and my PR eslint/eslint#16105 |
Sorry for the long response, closing it here since this will be fixed in ESLint directly |
Description
Adds try/catch to the ESLint processor preprocess task, to bail and return the original code if an error is thrown by the underlying parser (e.g. a parsing error outside the template strings).
The ESLint crew told me processors are not supposed to throw errors. See discussion here: eslint/eslint#16015
Fixes # (issue)
Type of change
Screenshots/Sandbox (if appropriate/relevant):
Here is a simple repo that reproduces the issue: https://github.com/therealgilles/graphql-config-code-file-ts
How Has This Been Tested?
I'm not sure how to build the repo and run existing tests. If you have documentation on this, I'll be happy to do it.
Test Environment:
@graphql-eslint/...
: 3.10.4Checklist: