eslint: How to disable certain "eslint-disable-" syntax?

811 views Asked by At

In a project we our working on we use fairly strict eslint rules for good reason. 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.

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.

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

2

There are 2 answers

3
abitwhy Wei On BEST ANSWER

Plugin eslint-plugin-eslint-comments is what you want.

0
Vladyslav Zavalykhatko On

The closest I got to making eslint-disable stricter is forcing to specify which rules should be disabled using this eslint plugin