-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
fix: improve error message for falsy parsed JS AST #19458
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
Conversation
✅ Deploy Preview for docs-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
CI failures are external to this change. |
Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
if (!ast.tokens) { | ||
throw new Error("AST is missing the tokens array."); | ||
throw new TypeError("AST is missing the tokens array."); |
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.
Following #19458 (comment), I went ahead and updated the rest of the error classes too.
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.
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Adds an
if
for the case of a falsy AST inJS
'sSourceCode
>validate
function.Uses a more generalized, succinct error message than what I originally suggested in the issue. I found this one to align more with the rest of them.
Is there anything you'd like reviewers to focus on?