如何禁用 "definition for rule 'custom-rule' was not found" 错误?
How can I disable "definition for rule 'custom-rule' was not found" errors?
出于我无法控制的原因,我维护的代码库在具有两个不同规则集的两个不同环境中被检查。其中一个环境有规则,另一个没有。由于 "definition for rule '{custom_rule}' was not found"
错误,第二个构建失败。
同样,由于我无法控制的原因,我无法合并规则集。如何在 ESLint 上禁用这些“未找到定义”错误,以便我的构建成功?
编辑:澄清一下,我有这样的东西:
11 ...
12 // eslint-disable-next-line custom-rule
13 var thing = new Thing();
14 ...
错误如下:
12:3 error Definition for rule 'custom-rule' was not found fb-www/extra-arrow-initializer
一种方法是在出现错误的行中禁用代码中的这些错误。禁用下一行:
// eslint-disable-next-line no-use-before-define
var thing = new Thing();
或者使用单行语法:
var thing = new Thing(); // eslint-disable-line no-use-before-define
我在 ESLint Discord 服务器上询问了这个问题,并从 Nicholas Zakas 那里得到了这个答案。我假设这是明确的答案,因为作为原作者和主要贡献者,如果有其他选择,我想 Nicholas 会知道。
他建议我为这些规则名称创建虚拟规则;
@keved I’m not sure there’s much else to be done. You’re referencing a rule that doesn’t exist, which is an error. The only other thing I can think of is to create a dummy plugin in your repo that is only referenced during the Travis build. As long as a rule exists with the given name, you’ll avoid the error. The rule doesn’t actually have to do anything so you could just have one dummy rule and assign it to every rule name.
出于我无法控制的原因,我维护的代码库在具有两个不同规则集的两个不同环境中被检查。其中一个环境有规则,另一个没有。由于 "definition for rule '{custom_rule}' was not found"
错误,第二个构建失败。
同样,由于我无法控制的原因,我无法合并规则集。如何在 ESLint 上禁用这些“未找到定义”错误,以便我的构建成功?
编辑:澄清一下,我有这样的东西:
11 ...
12 // eslint-disable-next-line custom-rule
13 var thing = new Thing();
14 ...
错误如下:
12:3 error Definition for rule 'custom-rule' was not found fb-www/extra-arrow-initializer
一种方法是在出现错误的行中禁用代码中的这些错误。禁用下一行:
// eslint-disable-next-line no-use-before-define
var thing = new Thing();
或者使用单行语法:
var thing = new Thing(); // eslint-disable-line no-use-before-define
我在 ESLint Discord 服务器上询问了这个问题,并从 Nicholas Zakas 那里得到了这个答案。我假设这是明确的答案,因为作为原作者和主要贡献者,如果有其他选择,我想 Nicholas 会知道。
他建议我为这些规则名称创建虚拟规则;
@keved I’m not sure there’s much else to be done. You’re referencing a rule that doesn’t exist, which is an error. The only other thing I can think of is to create a dummy plugin in your repo that is only referenced during the Travis build. As long as a rule exists with the given name, you’ll avoid the error. The rule doesn’t actually have to do anything so you could just have one dummy rule and assign it to every rule name.