javascriptnode.jseslinteslint-config-airbnb

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


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.


Solution

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