[英]es lint max length rule disabling is not working
I am trying to disable eslint rule in a typescript file.我正在尝试禁用 typescript 文件中的 eslint 规则。 I have a regular expression which contains more than 500 characters.
我有一个包含超过 500 个字符的正则表达式。 So it's generated an eslint warning.
所以它产生了一个 eslint 警告。 Since this is a regular expression, better way is to add an eslint comment before declaring the regular expression only for that line.
由于这是一个正则表达式,更好的方法是在仅为该行声明正则表达式之前添加一个 eslint 注释。 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
.我可以看到 eslint 警告,因为
This line has a length of 509. Maximum allowed is 270
。 So how can I remove this warning?那么我怎样才能删除这个警告呢?
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?你有哪个版本的eslint? I think you can can try
//eslint-disable-line
for disable all rules for the specific line, or using // eslint-disable max-len
我想你可以尝试
//eslint-disable-line
来禁用特定行的所有规则,或者使用// eslint-disable max-len
Taking from here: https://github.com/prettier/prettier/issues/3375取自这里: https://github.com/prettier/prettier/issues/3375
Edit编辑
I think you can also add a ignoreRule for you speisifc regex.我想你也可以为你的 speisifc 正则表达式添加一个 ignoreRule。 See here the docs: https://eslint.org/docs/rules/max-len of ignorePattern
在这里查看文档: ignorePattern 的 https: //eslint.org/docs/rules/max-len
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.