Skip to content
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

no-useless-escape: '\..' in a RegExp is useless? #883

Closed
RobDesideri opened this issue May 11, 2017 · 1 comment

Comments

@RobDesideri
Copy link

commented May 11, 2017

Hi, this is the regex:

let r = new RegExp(`.*/${assetFilename}\..*$`)

This is the warning:

immagine

The \.. pattern is intended as a literal dot . followed by a 'any single character' .

Why this warning?

@RobDesideri

This comment has been minimized.

Copy link
Author

commented May 16, 2017

Ok, I understood my error.

The template literals requires the same escape treatment as normal js strings (ref).
And, this behavior not change also if string (or template literal) is passed as a RegExp argument (ref).

So, the correct pattern is:

let r = new RegExp(`.*\\/${assetFilename}\\..*$`)

This is why standard emit the error.
Hope this can be useful for others.

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
1 participant
You can’t perform that action at this time.