Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 476
Slbox Avatar asked Aug 30 '25 17:08

Slbox


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-disable-next-line eqeqeq -- Here's a description

or

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

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

like image 85
Slbox Avatar answered Sep 02 '25 08:09

Slbox