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
Chore: Updated no-control-regex tests to cover all cases (fixes #6438) #6752
Conversation
@efegurkan, thanks for your PR! By analyzing the annotation information on this pull request, we identified @ilyavolodin, @nzakas and @btmills to be potential reviewers |
LGTM |
Thank you! |
LGTM |
LGTM, but waiting another day for others to look |
@@ -20,16 +20,17 @@ var ruleTester = new RuleTester(); | |||
|
|||
ruleTester.run("no-control-regex", rule, { | |||
valid: [ | |||
"var regex = /x1f/", | |||
"var regex =" + /x1f/, |
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.
Why is this written as a string concat? This is a constant value, just write the string out.
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.
I changed it as a mistake, fixing and pushing it.
toString prints out different outputs for /\x01/ and "/\x01/". Because of that behavior, no-control-regex rule was broken before(fixed on 141b778). During the fix I added a test to cover the case I wrote for fix. Which was also passing when the fix was not there. The test was on a string literal unfortunately which was not covering the test case where regex is written on a literal (like /\x01/). Changed the tests to make sure it covers the literal regex's as expected.
LGTM |
Thanks! |
What issue does this pull request address?
#6438
What changes did you make? (Give an overview)
toString prints out different outputs for /\x01/ and "/\x01/". Because
of that behavior, no-control-regex rule was broken before(fixed on 141b778).
During the fix for #5737 I added a test to cover the case I wrote for fix. Which
was also passing when the fix was not there. The test was on a string
literal unfortunately which was not covering the test case where regex
is written on a literal (like /\x01/). Changed the tests to make sure it
covers the literal regex's as expected.
Is there anything you'd like reviewers to focus on?