Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

quotemark: Invalid regular expression: /\\)/: Unmatched ')' #4310

Closed
mjomble opened this issue Nov 21, 2018 · 1 comment · Fixed by #4344
Closed

quotemark: Invalid regular expression: /\\)/: Unmatched ')' #4310

mjomble opened this issue Nov 21, 2018 · 1 comment · Fixed by #4344

Comments

@mjomble
Copy link

mjomble commented Nov 21, 2018

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.

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented Nov 21, 2018

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.

isabelleweber added a commit to isabelleweber/tslint that referenced this issue Dec 5, 2018
JoshuaKGoldberg pushed a commit that referenced this issue Jun 17, 2019
* Add quotemark type validation to allow early return (#4310)

* Fix no-unsafe-any linting error in quotemark rule

* Separate invalid quote tests into new tests

* Fixed introduced build break
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants