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
Update: Improve error message for fatal fixer errors #13120
Conversation
Very useful change, thanks! 👍 I'm not sure how to label this, looks like an enhancement rather than a chore. |
I'll champion this. I don't think this needs to go through the RFC process, given that it's an error message change, but let's see what others think. Is it possible to test the value of the error message (RegExp check is fine) to ensure that the change is correct? |
Agreed that this isn't a chore, but a useful enhancement for end users :) |
I didn't realise there was a test. I've updated the test's regex to validate the structure of the message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Very helpful, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
labelled |
What is the purpose of this pull request? (put an "X" next to an item)
[x] Other, please explain:
When the autofixer outputs broken code, the rule tester rightfully hard fails the test.
However, the error current message can be pretty vague as it relies upon the error message from the parser. Some of the parser errors can be explicit and easy to trace, and others can be useless without an error location.
For example, the following invalid code
'const a = "1";`'`
Produces this error message in both espree and typescript-eslint
Which results in this test failure:
This is especially problematic for fixer failure, because you cannot actually see the fixer output anywhere. So the above error message is impossible to action.
Usually I just patch my local eslint install to
console.log
the fixer output, but I finally figured it was probably just better if this was part of core.This change simply includes the code in the output so it's possible to see what code caused the error: