I am trying to disable eslint rule in a typescript file. I have a regular expression which contains more than 500 characters. So it's generated an eslint warning. Since this is a regular expression, better way is to add an eslint comment before declaring the regular expression only for that line. So my attempt is as below.
/* eslint-disable-next-line max-len */
export const URI_REGEX = "" // something which is very long
But still this is not working. I could see the eslint warning as This line has a length of 509. Maximum allowed is 270
. So how can I remove this warning?
CodePudding user response:
Not sure, your method should be working but can you give this a try by wrapping it?
/* eslint-disable max-len */
export const URI_REGEX = "" // something which is very long
/* eslint-enable max-len */
CodePudding user response:
Which version of eslint do you have?
I think you can can try //eslint-disable-line
for disable all rules for the specific line, or using // eslint-disable max-len
Taking from here: https://github.com/prettier/prettier/issues/3375
Edit
I think you can also add a ignoreRule for you speisifc regex. See here the docs: https://eslint.org/docs/rules/max-len of ignorePattern