Warn when ESLint directives which expect to be used in block level comments are used in inline comments
See original GitHub issueThe problem you want to solve.
ESLint requires that eslint-disable rule-name
and similar directives are placed in block level comments (/* */
) and not in inline comments (//
).
To temporarily disable rule warnings in your file, use block comments in the following format:
While the rational is not stated in the docs, I assume this is because disabling a rule is a “big deal” and that should be reflected in the type of comment used.
I think this requirement makes sense, but it can be hard to remember, and when you get it wrong (use an inline comment instead of a block level comment), ESLint just silently ignores your request.
Your take on the correct solution to problem.
I propose that we emit an error or warning when we discover an ESLint directive that is in the incorrect type of comment.
There is some precedent for this, as getDirectiveComments already has a number of different places where it will emit problems.
Are you willing to submit a pull request to implement this change?
Yes.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top GitHub Comments
I went ahead and opened the RFC: https://github.com/eslint/rfcs/pull/34
Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.
Thanks for contributing to ESLint and we appreciate your understanding.