Tslint: quotemark: Invalid regular expression: /\\)/: Unmatched ')'

Created on 21 Nov 2018  路  1Comment  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.11.0
  • __TypeScript version__: 3.1.6
  • __Running TSLint via__: CLI

TypeScript code being linted

('a)

with tslint.json configuration:

{ "rules": { "quotemark": true } }

Actual behavior

The 'quotemark' rule threw an error in 'test.ts':
SyntaxError: Invalid regular expression: /\\)/: Unmatched ')'
    at new RegExp (<anonymous>)
    at cb (...\tslint\lib\rules\quotemarkRule.js:106:33)
    ...

Expected behavior

No error.

Looks like the same issue as #3073 and #4181 but those issues got closed as there was no reproducible case.

Easy Accepting PRs Bug good first issue

Most helpful comment

Ha, thanks for the repro @mjomble! Quotemark bugs have been popping up every now and then...

If the problem is that new RegExp(\\\\${actualQuoteMark}, "g") is taking in an invalid string "/\\)/", it seems like it would be a pretty quick fix to add a case to the actualQuoteMark === expectedQuoteMark if statement to return early if the actualQuoteMark is not a ', ", or ```.

Related: #3808.

>All comments

Ha, thanks for the repro @mjomble! Quotemark bugs have been popping up every now and then...

If the problem is that new RegExp(\\\\${actualQuoteMark}, "g") is taking in an invalid string "/\\)/", it seems like it would be a pretty quick fix to add a case to the actualQuoteMark === expectedQuoteMark if statement to return early if the actualQuoteMark is not a ', ", or ```.

Related: #3808.

Was this page helpful?
0 / 5 - 0 ratings