New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Request: allowing eslint-disable-next-line directives to have extra lines only for descriptions #15567
Comments
Hi @thernstig, thanks for the issue!
A problem with this is that it becomes unclear what's a part of the directive, and where the directive applies. Consider the following example: /* eslint spaced-comment: "error" */
// eslint-disable-next-line spaced-comment -- some description
//this comment isn't spaced Directive on line 3 disables error on line 4, and the code is lint-free as in this demo. If we change the logic and interpret consecutive comments as parts of the same directive, the error on line 4 would not be disabled and the directive would become unused since it would apply to line 5.
This rule ignores all |
/* eslint spaced-comment: "error" */
// eslint-disable-next-line spaced-comment -- some description
//this comment isn't spaced Does the same problem not occur with |
The current behavior seems consistent and intuitive to me: 1 JS comment = 1 directive that applies to the line after the comment. /* eslint-disable-next-line --
comment ends on this line */
// and applies to this line
// eslint-disable-next-line -- comment ends on this line
// and applies to this line Consecutive line comments are separate comments, so I think it would become confusing if we treat them like parts of the directive that applies after the last comment. |
You are probably right. I just read too much into It kind of makes I wonder if there should be a doc update somewhere to let users be aware of this. |
It should be possible because From the documentation:
Here's an example where it doesn't report error on a multiline /* eslint no-undef: ["error"] */
/* eslint multiline-comment-style: ["error", "separate-lines"] */
/* eslint-disable-next-line no-undef
-- some description */
foo(); |
@mdjermanovic very true, should we close this then? I assume from all this there is no good way to support the original request? |
I agree with closing as it seems there is no good way to support the requested feature. |
ESLint version
v8.8.0
What problem do you want to solve?
It is possible to allow
eslint-disable-next-line
directives to span multiple lines like this:But some of us prefer reserving
//
for plain comments usingmultiline-comment-style
with the option"separate-lines"
.We would like to support this:
What do you think is the correct solution?
For ESLint to support it.
Participation
Additional comments
Original PR for the currently allowed multi-line eslint-disable-next-line directives seen here #15436
The text was updated successfully, but these errors were encountered: