简体   繁体   English

禁用评论内的 linting

[英]disable linting inside comments

I want eslint to stop linting inside comments // and /* */.我希望 eslint 停止在评论// 和 /* */ 中进行 linting。

when in comments I want to have freedom to write as I please.在评论中,我希望有随心所欲地写作的自由。 (disable 80 char limitation etc.. ) (禁用 80 字符限制等。

that's pretty basic in my opinion and yet I can't find it anywhere, is there a predefined rule to do that?在我看来这是非常基本的,但我在任何地方都找不到它,是否有预定义的规则可以做到这一点?

Thanks谢谢

Sure, to disable line length checking inside comments just use the following rule in your .eslintrc.js :当然,要禁用注释内的行长检查,只需在.eslintrc.js中使用以下规则:

rules: {
    "max-len": ["warn", { "code": 80, "ignoreComments": true }]
}

This way ESLint will complain about lines with more than 80 characters only if they're not comments.这样 ESLint 只会抱怨超过 80 个字符的行,除非它们不是注释。 Check the documentation for rule max-len for more info.查看规则max-len的文档以获取更多信息。

Also notice that any ESLint rule you define for your project can be ignored in specific code blocks if you want, for example:另请注意,如果您愿意,可以在特定代码块中忽略您为项目定义的任何 ESLint 规则,例如:

/* eslint-disable max-len */
YOUR LONG LINE HERE
/* eslint-enable max-len */

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM