-
Notifications
You must be signed in to change notification settings - Fork 63
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
Fix: message.line
could be undefined
#191
Conversation
Hi @JounQin!, thanks for the Pull Request The first commit message isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.
Read more about contributing to ESLint here |
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.
Nice catch, though I think there’s a cleaner way of catching this error.
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.
|
In `lib/linter/linter.js`, the `parse()` function's exception handler translates the exception's message to a `LintMessage`. It also passes through the exception's `lineNumber` and `column`, but the exception is not guaranteed to have those properties. In that case, `LintMessage.line` and `column` can be `undefined`. In eslint/markdown#191, the processor would crash when attempting to map messages without a line. Normally widening a type like this would be a breaking change, but since this is only updating the docs to reflect reality, I think this can be a semver-patch change.
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.
Good find, @JounQin. I agree the early return
from adjustMessage()
is the right fix, and I have one idea that could improve the experience with how we're adjusting messages without line
information. What do you think about it?
I also noticed that ESLint's LintMessage
@typedef
and Node.js API docs say line
and column
are always number
s, so I opened eslint/eslint#15032 to add undefined
as a possible value.
Hi @JounQin!, thanks for the Pull Request The pull request title isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.
Read more about contributing to ESLint here |
1 similar comment
Hi @JounQin!, thanks for the Pull Request The pull request title isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.
Read more about contributing to ESLint here |
message.line
could be undefined
message.line
could be undefined
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.
The implementation LGTM, and I had an idea that'll help the test do a better job protecting us from accidentally breaking this in some future change.
Co-authored-by: Brandon Mills <[email protected]>
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 @JounQin! I’ll leave this open for a day or two in case someone else wants to review and then merge and release it.
In `lib/linter/linter.js`, the `parse()` function's exception handler translates the exception's message to a `LintMessage`. It also passes through the exception's `lineNumber` and `column`, but the exception is not guaranteed to have those properties. In that case, `LintMessage.line` and `column` can be `undefined`. In eslint/markdown#191, the processor would crash when attempting to map messages without a line. Normally widening a type like this would be a breaking change, but since this is only updating the docs to reflect reality, I think this can be a semver-patch change.
related mdx-js/eslint-mdx#339 (comment)
cc @btmills