Is there any syntax to add additional info to an eslint-disable-line comment?

Viewed 861

Given a comment like this:

  i++; // eslint-disable-line no-plusplus

Is there any syntax we can add a description or explanation for why we're disabling the rule, on the same line, without triggering ESLint to complain that there's no rule called "-- our description"?

  i++; // eslint-disable-line no-plusplus - our description

In this simple example it's trivial enough to use // eslint-disable-next-line - but in a situation where you have multiple lines that might change order like object keys, or import statements (if using automatic alphabetization) then that breaks down.

Is there any supported method for achieving this?

1 Answers

You can add two dashes --. According to the docs on using configuration comments:

Configuration comments can include descriptions to explain why the comment is necessary. The description must occur after the configuration and is separated from the configuration by two or more consecutive - characters. For example:

/* eslint eqeqeq: "off", curly: "error" -- Here's a description  */

Further Reading: Added on Sep 2019 via New: Description in directive comments

Related