Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upProposal: No empty blocks #796
Comments
feross
added
the
enhancement
label
Feb 21, 2017
This comment has been minimized.
This comment has been minimized.
|
Thanks for the request. We need to evaluate the ecosystem impact of this. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
ghost
commented
Mar 22, 2017
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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... |
feross
closed this
Apr 4, 2017
This comment has been minimized.
This comment has been minimized.
|
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
} |
This comment has been minimized.
This comment has been minimized.
|
Perhaps ask the eslint team for a special case to allow empty |
This comment has been minimized.
This comment has been minimized.
|
@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 :) |
This comment has been minimized.
This comment has been minimized.
|
@tunnckoCore ? :P |
This comment has been minimized.
This comment has been minimized.
|
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 |
tunnckoCore commentedFeb 21, 2017
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.
{ "no-empty": ["error", { "allowEmptyCatch": true }] }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-elseifcombo likeBut again, it not make any sense.