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.

Rule Change: no-empty suggest to add comments inside empty blocks

See original GitHub issue

What 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:closed
  • Created a year ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
mdjermanoviccommented, May 22, 2022

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.

1reaction
amareshsmcommented, Jun 9, 2022

I am working on this. I will send a PR soon.

Read more comments on GitHub >

github_iconTop 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 >

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