Skip to content
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

Add rule no-void #135

Merged
merged 1 commit into from Aug 13, 2019
Merged

Add rule no-void #135

merged 1 commit into from Aug 13, 2019

Conversation

acarballo-cs
Copy link
Contributor

Avoid useless void operator

Avoid useless void operator
@acarballo-cs acarballo-cs changed the title Update eslintrc.json Add rule no-void Nov 16, 2018
@LinusU
Copy link
Member

LinusU commented Nov 16, 2018

Sounds good to me, I don't really see when one would need it 🤔

@feross
Copy link
Member

feross commented Aug 13, 2019

This sounds good to me. Only one repo was failing and it was an easy fix: feross/chrome-net@8cc2520

Let's release this in standard 14.

Copy link
Member

@feross feross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@feross feross merged commit 5031de3 into standard:master Aug 13, 2019
@mightyiam
Copy link
Member

I was just recently contemplating whether there are useful usages of void. Do you feel like the ESLint rule doc lists all them? I never used it, even once. So I'd probably not miss it. Yet, I'm still wondering. How about non-leaky arrow functions?

pull bot pushed a commit to shakir-abdo/standard that referenced this pull request Aug 13, 2019
@feross
Copy link
Member

feross commented Aug 13, 2019

void is used so rarely and there are better alternatives, so it's probably easier to just ban it so most folks won't even have to learn what it is.

If I have to make an argument for void, I agree that non-leaky arrow functions is a reasonable one:

button.onclick = () => void doSomething()

However, you can do this with fewer characters like this:

button.onclick = () => { doSomething() }

And this avoids the need to understand a new concept. So it's clearer, IMO.

Of course, you can always add an eslint ignore comment if you really need to use void for some reason and nothing else works.

@mightyiam
Copy link
Member

No argument here.

@Jessidhia
Copy link

I find void to be a more elegant solution to the "semicolon prefix" workaround to the ASI problem.

void (() => { /* some iife */ })()
// vs
;(() => { /* another iife */ })()

but this is kind of a style choice.

@nolanlawson
Copy link

I use void 0 as a shorthand for undefined, but this is probably confusing and something I should stop doing anyway. Especially given that undefined can't be redefined anymore. 👍

@feross
Copy link
Member

feross commented Aug 19, 2019

Especially given that undefined can't be redefined anymore. 👍

Yep! So happy about this change!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

6 participants