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: fix no-octal-escape false negatives after \0 #12079
Update: fix no-octal-escape false negatives after \0 #12079
Conversation
The false negative could be confirmed this way: Demo Link 1 - The rule doesn't warn on Demo link 2 - Parser reports |
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.
Looks good to me, minor non-blocking style note
The team may feel differently, but when I designed the messageId feature, the intention was to let the messages be declarative in the rules, but the actual content of the messages would not matter as much because the messages could be localized/translated or otherwise changed. So I at least have no problem with messageId+data in tests. |
It's changed to messageId+data now, only one full message is left. Thank you @GrayedFox for the suggestion! |
No worries, happy to help! |
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, thank you!
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!
What is the purpose of this pull request? (put an "X" next to item)
[X] Bug fix
This is a small bug fix, but it can produce more warnings.
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue.
Demo link
What did you expect to happen?
1 error
What actually happened? Please include the actual, raw output from ESLint.
No errors.
What changes did you make? (Give an overview)
Modified regex to not capture
\0
that isn't followed by an octal digit. The previous code was handling\0
by capturing and not reporting, which is okay for the\0
but it missed the rest of the string.Also added messageId, I guess it's preferred way now.
Is there anything you'd like reviewers to focus on?
!== "0"
) is removed as it is no longer needed, but I'm not sure am I missing something with the other part of it, which is also removed now:match[3] !== "undefined"
. How was that evertrue
?\0
should be reported as octal when it's in\08
and\09
, I'll open an issue.prefer-template
has the same bug (looks like it was copy & paste from this rule and then simplified as it's for test only there), I'll fix it in another PR.quotes
does not check these cases at all when converting from string to template literals. I'll fix it after the PR forprefer-template
(as it will share something in astUtils).