Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

no-control-regex doesn't catch erros on escaped strings #785

Closed
IllusionMH opened this issue Jan 14, 2019 · 1 comment
Closed

no-control-regex doesn't catch erros on escaped strings #785

IllusionMH opened this issue Jan 14, 2019 · 1 comment

Comments

@IllusionMH
Copy link
Contributor

IllusionMH commented Jan 14, 2019

Bug Report

  • tslint-microsoft-contrib version: 6.0.0
  • TSLint version: 5.12.0
  • TypeScript version: 3.1.1
  • Running TSLint via: CLI

Difference in behavior during test mighration mentioned in comment

TypeScript code being linted

// should fail
new RegExp('something \x1f something else'); // creates regexp with special character in it (equivalent of /something � something else/)

new RegExp('something \\x1f something else'); // creates regexp with character match sequence in it (equivalent of /something \x1f something else/)

new RegExp('something \\\x1f something else'); // creates regexp that contains backslash followed by special character in it (equivalent of /something \� something else/)

// should pass
new RegExp('something \\\\x1f something else'); // creates regexp that correctly escaped backslash followed by characters x,1,f (equivalent of /something \\x1f something else/)

with tslint.json configuration:

{
    "rules": {
        "no-control-regex": true
    }
}

Actual behavior

Detected errors in strings with 1 and 3 \ characters (will also fail on 5 characters)
No errors in strings with 2 and 4 \ characters

Expected behavior

Should detect errors in strings with 1, 2, and 3 \ characters
No error in string with 4 \ characters

ESLint behavior (was prototype):

Will detect errors in strings with 1, 2, and 5 \ characters
Will detect no errors in strings with 3 and 4 \ characters.

Not sure why it passes on 3 \ characters, but it is up for discussion.

@IllusionMH IllusionMH added Type: Bug Status: In Discussion Please continue discussing the proposed change before sending a pull request. labels Jan 14, 2019
@JoshuaKGoldberg
Copy link

💀 It's time! 💀

TSLint is deprecated and no longer accepting pull requests other than security fixes. See #876. ☠️
We recommend you instead use typescript-eslint to lint your TypeScript code with ESLint. ✅

👋 It was a pleasure open sourcing with you!

@JoshuaKGoldberg JoshuaKGoldberg added 💀 R.I.P. 💀 and removed Status: In Discussion Please continue discussing the proposed change before sending a pull request. labels Jan 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants