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

selectively disabling rules on a case-by-case basis. maybe. #6

Closed
timoxley opened this issue Jan 27, 2015 · 6 comments

Comments

@timoxley
Copy link
Contributor

commented Jan 27, 2015

Sometimes I do actually want ==. I can't think of any usecases now but I find that on occasion I explicitly opt for ==.

I'm wondering if some of these style restrictions could be selectively 'disabled' for a particular case if a comment is present to explain why an ill-advised practice was used instead of best practice.

"use strict"
var items = getCurrentItems()
// style: my religion speaks of a prophecy where vile, dark beings
// enter this realm and do unspeakable things to its inhabitants should 
// the chosen one (me, lol) fail to protect the semicolon of the 7th line of
// the 7th file. Remove this semicolon at your peril.
items = items.map(function(n) { return n * 2});
console.log(items)

maybe.

@feross

This comment has been minimized.

Copy link
Member

commented Jan 27, 2015

Hahahah, nice.

I just added documentation for how to ignore specific warnings. See: https://github.com/feross/standard/blob/master/README.md#how-do-i-hide-a-certain-warning

@feross

This comment has been minimized.

Copy link
Member

commented Jan 27, 2015

The most useful use-case for == is to check if a value is equal to undefined or null, like this:

if (obj == null) {
  // obj is `null` or `undefined`
}

Which is nicer than:

if (obj === null || obj === undefined) {
  // obj is `null` or `undefined`
}

JavaScript Standard Style allows == null out-of-the-box without needing to hide any warnings. If you want to use == to compare to objects other than null, you'll need to ignore the warning that generates.

@soyuka

This comment has been minimized.

Copy link

commented Jan 27, 2015

+1 about ==, this is the one case that is really usefull! You can't just use === everywhere, but you should know the difference.

@feross

This comment has been minimized.

Copy link
Member

commented Jan 27, 2015

Since the common case of == null is allowed by default, and there's a way to hide the warnings in other cases, I'm going to close this issue now. But you can feel free to continue discussion if there's interest.

@feross feross closed this Jan 27, 2015

@timoxley

This comment has been minimized.

Copy link
Contributor Author

commented Jan 27, 2015

Perfect. That was the exact usecase.

@feross

This comment has been minimized.

Copy link
Member

commented Jan 27, 2015

Yay!

@lock lock bot locked as resolved and limited conversation to collaborators May 11, 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.