How can I disable "definition for rule 'custom-rule' was not found" errors?

Viewed 549

For reasons outside my control, a codebase I maintain is linted with in two different environments with two different rule-sets. One of the environments has rules the other doesn't. The build in the second is failing due to "definition for rule '{custom_rule}' was not found" errors.

Again, for reasons outside my control, I can't merge the rulesets. How can I disable these "definition not found" errors on ESLint, so my build succeeds?

EDIT: To clarify, I have something like this:

11 ...
12 // eslint-disable-next-line custom-rule
13 var thing = new Thing();
14 ...

And the error is something like the following:

12:3 error  Definition for rule 'custom-rule' was not found  fb-www/extra-arrow-initializer
2 Answers

I asked about this on the ESLint Discord server and got this answer from Nicholas Zakas. I'm assuming it's the definitive answer since, as the original author and top contributor, if there was an alternative I imagine Nicholas would know.

He proposed I create dummy rules for these rule names;

@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.

screenshot of the answer in discord

One method is to disable these errors in code on the line where they occur. To disable next line:

// eslint-disable-next-line no-use-before-define
var thing = new Thing();

Or use the single line syntax:

var thing = new Thing(); // eslint-disable-line no-use-before-define

See the eslint docs

Related