jaredkwright
jaredkwright

Reputation: 1380

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.

Upvotes: 4

Views: 1064

Answers (2)

abitwhy Wei
abitwhy Wei

Reputation: 66

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

Upvotes: 1

Vladyslav Zavalykhatko
Vladyslav Zavalykhatko

Reputation: 17384

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

Upvotes: 0

Related Questions