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
Disallow empty block statements (no-empty) #796
Comments
Thanks for the request. We need to evaluate the ecosystem impact of this. |
Yea, i'm curious too. But don't think it will be big, huh.. i hope, it would be bad signal for the js community. |
I don't feel the value this adds outweighs the complexity it adds in coding standard. Let's please KISS this library and let ESLint serve the persnickety. |
I really wanted to like this rule, and the ecosystem impact is only 3 repos! But all 3 repos are mine! These are all pretty low-level modules, so these snippets aren't necessarily the clearest. But it's not obvious how I would rewrite these snippets to remove the empty block.
while (self._request(wire, piece, self._critical[piece] || hotswap)) {}
while (this.read()) {} // consume and discard the rest of the stream data
for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} For that reason, I'm -1 on this. Unless other collaborators have thoughts they'd like to chime in... |
If we could limit it to that idiom, that'd be fine. Your while (nBits > 0) {
e = (e * 256) + buffer[offset + i]
i += d
nBits -= 8
} |
Perhaps ask the eslint team for a special case to allow empty |
@dcousens Fair point about the for-loop! Does someone want to volunteer to request this option from the ESLint team? If you do it, please post the link here so I can subscribe to it :) |
@tunnckoCore ? :P |
I don't have the time currently. As we seen, from whole community only @feross is using such things hehe. As seen, there's always better approach instead of some tricky bytes - that's javascript: tons of available ways, one best! haha |
I think we can merge this now with this config: no-empty: ["error", { "allowEmptyCatch": true }] The examples I pointed out before can be worked around by including a comment inside the empty body, which explains the reason that it's empty. I think this might have been an addition later to the rule? And the other example can be rewritten as @dcousens pointed out. Let's include in standard 16. |
Digging more and more in ESLint rules, i found some good ones which enforces good style and more readable code. This issue is for no-empty rule - not fixable.
Suggested configuration.
Never seen a point for doing such things. It is just waste of code and is messy, adding needless branches.
For what god reason this make sense
I've seen such code here and there over the years, but mostly if i remember correctly it was because
if-elseif
combo likeBut again, it not make any sense.
The text was updated successfully, but these errors were encountered: