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

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

@IllusionMH

Description

@IllusionMH

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions