I have this regex of mine that will check the string if it contains link or url (i.e. https://eslint.org/docs/rules/no-useless-escape)
. Using this regex /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig
, I've encountered and error while running my test cases in react about Unnecessary escape character: \/ no-useless-escape
. How to disable this eslint-error in order for me to proceed with my test case and use the regex.
Appreciate for any help!
You can use ESLint and try adding either of the things:-
//eslint-disable-line
on the line to disable warnings.//eslint-disable-next-line
to line before to disable warnings.See from docs of ESLint, Disabling Rules with Inline Comments.
You can disable warnings in entire file by adding
/* eslint-disable */
at the top of the file.It's the
\/
in[-A-Z0-9+&@#\/%?=~_|!:,.;]
and[-A-Z0-9+&@#\/%=~_|]
(NOT the ones in:\/\/
). Most characters do not have to be escaped within a character class (square brackets). This should be equivalent:/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig
So See https://www.regular-expressions.info/charclass.html for more info, but the relevant part: