[英]eslint: How to disable certain "eslint-disable-" syntax?
In a project we our working on we use fairly strict eslint rules for good reason.在我们工作的项目中,我们有充分的理由使用相当严格的 eslint 规则。 Occasionally we need to break one of the rules, so we would disable a rule for a specific line.
有时我们需要打破其中一条规则,因此我们会禁用特定行的规则。 For example:
例如:
// eslint-disable-line no-console
In this case we use the eslint-disable-line
syntax with the specific rule that we want disabled, to avoid accidentally disabling other rules that are important.在这种情况下,我们使用带有我们想要禁用的特定规则的
eslint-disable-line
语法,以避免意外禁用其他重要的规则。
Occasionally a dev will sneak a file in that has // eslint-disable-line
without the specific rule, or the dreaded /* eslint-disable */
at the file level.有时,开发人员会在文件中偷偷放入一个没有特定规则
// eslint-disable-line
,或者文件级别可怕的/* eslint-disable */
。
What I am looking for is a way to force eslint to only accept directives when they include one or more specific rules, so that, for example我正在寻找的是一种强制 eslint 仅在包含一个或多个特定规则时才接受指令的方法,例如
// eslint-disable-next-line max-len
would still disable that specific check, but仍然会禁用该特定检查,但是
// eslint-disable-next-line
without the rule would still result in an error.没有规则仍然会导致错误。
Plugin eslint-plugin-eslint-comments is what you want.插件eslint-plugin-eslint-comments就是你想要的。
The closest I got to making eslint-disable
stricter is forcing to specify which rules should be disabled using this eslint plugin我最接近使
eslint-disable
更严格的方法是使用此 eslint 插件强制指定应禁用哪些规则
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.