question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

allowing eslint-disable-next-line directives to have extra lines only for descriptions

See original GitHub issue

The version of ESLint you are using. eslint@7.22.0

The problem you want to solve. With the adoption of the description in directive comments RFC eslint-disable-next-line directives can get long.

// eslint-disable-next-line global-require -- description on why this exception is seen as appropriate but past a comfortable reading line length
const fizz = require(buzz);

When using max-len these lines are reported as errors (by getDirectiveComments, à la #10334)

/path/to/file.js
  15:2  error  eslint-disable-next-line comment should not span multiple lines

This pushes developers to either get too terse and remove possibly important information or to disable and re-enable the rule

/* eslint-disable global-require --
   description on why this exception is seen as appropriate but past a 
   comfortable reading line length */
const fizz = require(buzz);
/* eslint-enable global-require -- re-enable */

Developers may forget to re-enable the rule, though this may be mitigated by eslint-comments/disable-enable-pair. If they use a rule like eslint-comments/require-description the re-enabling comment may become tedious.

Your take on the correct solution to problem. A pit of success may be allowing eslint-disable-next-line directives to have extra lines but only for the description. e.g.

/* eslint-disable-next-line global-require --
   description on why this exception is seen as appropriate but past a 
   comfortable reading line length */
const fizz = require(buzz);

Are you willing to submit a pull request to implement this change? I may need guidance as it would be my first in this project, but yes. Eslint has given me a lot over the years, proposing an implementation seems more than fair.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
mdjermanoviccommented, Oct 21, 2021

I support this proposal for eslint-disable-next-line comments and I agree with @btmills that it is intuitive.

I think we still shouldn’t allow multiline eslint-disable-line comments.

For clarity, before #10334 multiline eslint-disable-next-line and eslint-disable-line comments were ignored (i.e. not interpreted as eslint directives), the change made in #10334 was to report errors on such comments.

1reaction
btmillscommented, Oct 20, 2021

I’d be okay reversing #10334 for eslint-disable-next-line comments to allow multiple lines because it’s intuitive to me that the comment would then apply to the next line after the comment ends.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rules - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Turning off eslint rule for a specific file - Stack Overflow
1) Disabling "All rules"​​ Two ways you can do this: Put /* eslint-disable-line */ at the end of the line(s), or /* eslint-disable-next-line...
Read more >
How to disable ESLint for some lines, files or folders
Ignore multiple files or folders ... To turn off ESLint in the whole file, you can add /* eslint-disable */ in the first...
Read more >
eslint-comments/require-description - mysticatea
This rule warns directive comments without description. WARNING. This rule can only be used with ESLint v7.x or later. # Rule Details. Examples...
Read more >
eslint-plugin-jsdoc - npm Package Health Analysis - Snyk
In conjunction with the require-jsdoc rule, these settings can be enforced so as to report problems if a jsdoc block is not found...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found