Rule Change: no-empty suggest to add comments inside empty blocks
See original GitHub issueWhat rule do you want to change?
no-empty
What change to do you want to make?
Implement suggestions
How do you think the change should be implemented?
A new default behavior
Example code
const foo = () => {
console.log('Still going');
return Math.random() > 0.5;
};
while(foo()) {}
What does the rule currently do for this code?
Throws an error because an empty while loop is not allowed.
What will the rule do after it’s changed?
show a suggestion to add comments inside an empty loop.
Participation
- I am willing to submit a pull request to implement this change.
Additional comments
Reference #15839
Issue Analytics
- State:
- Created a year ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
S00108: Nested block not empty, if comment present?
The rule S00108 states, that nested blocks should not be empty, because this could indicates accidentally missing code.
Read more >no-empty - ESLint - Pluggable JavaScript Linter
This rule ignores block statements which contain a comment (for example, in an empty catch or finally block of a try statement to...
Read more >Ignore `catch` block in the `no-empty` rule · Issue #2808 - GitHub
I know I can put in a // empty comment there, but that feels like an unuseful reiteration of the obvious. Possible solution...
Read more >Why do TSLint and JSLint report empty blocks? - Stack Overflow
Perhaps the function was forgotten to be filled out. Recommend () => undefined as a noop. More. If you want to disable it...
Read more >Configuration | Stylelint
You can add any number of keys in the object. For example, you can: turn off block-no-empty; turn on unit-allowed-list with a primary...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Suggestion that adds
/* empty */
comment inside the reported empty block statement makes sense to me 👍Since all new features need a consensus from the team, let’s wait for more opinions.
I am working on this. I will send a PR soon.