javascript - es lint max length rule disabling is not working - Stack Overflow

I am trying to disable eslint rule in a typescript file. I have a regular expression which contains mor

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 ment 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?

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 ment 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?

Share Improve this question asked Mar 10, 2022 at 8:41 JackJack 3391 gold badge5 silver badges22 bronze badges 4
  • 1 I think to disable the next-line you cannot use block quotes /**/. Use // eslint-disable-next-line max-len – evolutionxbox Commented Mar 10, 2022 at 9:07
  • other way also tried out. not works. But inline ments working – Jack Commented Mar 10, 2022 at 9:08
  • What do you mean by "inline ments"? – evolutionxbox Commented Mar 10, 2022 at 9:09
  • 3 You also may want to also rethink why you need a regex that is 500 characters long. That sounds like a nightmare to maintain. – Andy Commented Mar 10, 2022 at 9:10
Add a ment  | 

2 Answers 2

Reset to default 6

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 */

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./prettier/prettier/issues/3375

Edit

I think you can also add a ignoreRule for you speisifc regex. See here the docs: https://eslint/docs/rules/max-len of ignorePattern

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743754964a4501590.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信