allowing eslint-disable-next-line directives to have extra lines only for descriptions
See original GitHub issueThe 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:
- Created 2 years ago
- Reactions:7
- Comments:13 (11 by maintainers)
Top GitHub Comments
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
andeslint-disable-line
comments were ignored (i.e. not interpreted as eslint directives), the change made in #10334 was to report errors on such comments.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.