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

`no-undef-init` makes defining a const with undefined impossible #456

Closed
despairblue opened this issue Mar 10, 2016 · 4 comments

Comments

@despairblue
Copy link

commented Mar 10, 2016

const nothing1 = undefined // does not lint
const nothing2 = null // does lint
// etc

This may look weird, but it's part of a spec and I want to have all fixtures as consts, instead of copying them to all assertions. Maybe later I decide that the function I'm testing should work with empty strings instead of undefined, so I can simply change one line.

I do see that this is a very specific edge case. If this is a wont-fix, I'm fine with it. I can simply change it to let nothing1.

@yoshuawuyts

This comment has been minimized.

Copy link
Contributor

commented Mar 10, 2016

I do see that this is a very specific edge case

I think I agree; I don't see a compelling reason to relax the rule - wonder what others think

@feross

This comment has been minimized.

Copy link
Member

commented Mar 11, 2016

@despairblue What's the error you get?

@despairblue

This comment has been minimized.

Copy link
Author

commented Mar 11, 2016

@feross on one computer I get It's not necessary to initialize 'nothing1' to undefined on the other it works as expected. I suppose it was fixed and I have an old eslint version installed on one computer.

Thanks for the help 👍

@feross

This comment has been minimized.

Copy link
Member

commented Mar 12, 2016

Cheers!

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
3 participants
You can’t perform that action at this time.