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: quotes autofix produces syntax error with octal escape sequences #12118
Conversation
Is there an equivalent escape sequence that is allowed in templates? (Ideally in octal but other radix is good too) To be clear, I'm not trying to suggest a complicated fix. I'm trying to establish if there is no way for the user to fix the issue (in which case, best not to report at all), or if there is a way they could change the code to get the same value. |
I think there are only 'hex' ( So, there is a way to manually fix, but the user would be forced to convert octal -> hex. On the other hand octal escapes shouldn't be used anyway, as far as I know it's a legacy feature and is forbidden in strict mode. Re the auto-fix, it might be not even too complicated, but I guess that rules such as |
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 for contributing!
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!
Thanks for contributing to ESLint! |
What is the purpose of this pull request? (put an "X" next to item)
[X] Bug fix
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.
What did you expect to happen?
Given how
prefer-template
works in similar situations, to report a warning but without the auto-fix.What actually happened? Please include the actual, raw output from ESLint.
Fixed to:
What changes did you make? (Give an overview)
Prevent fix to a template literal if the source string contains an octal escape sequence.
An alternative would be to not report that string at all.
Is there anything you'd like reviewers to focus on?