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

Use jshint, clean up tests r=mikedeboer #106

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Use jshint, clean up tests r=mikedeboer #106

wants to merge 2 commits into from

Conversation

lambdabaa
Copy link
Collaborator

@lambdabaa
Copy link
Collaborator Author

@mikedeboer Can you take a look and also turn on your travis endpoint? See https://travis-ci.org/profile/mikedeboer and toggle the little radio button for mikedeboer/jsDAV

@@ -72,7 +72,7 @@ exports.init = function(mongo, skipInit, callback) {
Async.list(operations)
.each(function(op, next) {
var coll = mongo.collection(op.collection);
if (op.type == "index")
if (op.type === "index")
Copy link
Owner

Choose a reason for hiding this comment

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

why ===?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I make a point of not knowing how == and != coerce things so that I can use my brain for other, more useful activities

@mikedeboer
Copy link
Owner

I kind of like the style changes, except the === ones. I understand why it's promoted by JSHint, but we're smart enough to not shoot ourselves in the foot with such obvious things.

I'd actually prefer to take a JSHint configuration that yields as few warnings as possible and work from there.

"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : false, // true: Require {} for every new block or scope
"eqeqeq" : true, // true: Require triple equals (===) for comparison
Copy link
Owner

Choose a reason for hiding this comment

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

please set this to false

Copy link

Choose a reason for hiding this comment

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

it's a best practice not to.

Copy link
Owner

Choose a reason for hiding this comment

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

Evert! 😄 I know it's best practice, but my short reasoning to allow it is as follows:

Know JS.

This might seem silly, but many of these 'rules' were invented to prevent Joe programmer to shoot themselves in the foot. We're not developing websites with JQuery here, we're coding a program in a set environment with parameters we control. Footguns will be caught during review.

The above might sound a bit gnarly, but I think 'best practices' need to be weighed and challenged for each use case.

I think JSHint is great and I'd really like to use it here, but it doesn't fix code. This PR doesn't fix any functional bug, just stylistic ones.

Copy link

Choose a reason for hiding this comment

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

It has very little to do with knowing or not knowing js. The JIT can heavily optimize for triple-equals.

When representing double, vs triple equals in machine code, the former is insanely complex and the latter is super simple. Using === is a very practical thing to do. Whenever I see == I think either the author is not very knowledgeable of js, or there must be a special exception in play here where the behavior of == is actually desired.

Copy link
Owner

Choose a reason for hiding this comment

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

It was not really my intention to start a discussion here :/

@gaye just allow for == in JSHint, so I can merge this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mikedeboer Done!

@@ -172,7 +176,7 @@ var jsDAV_CalendarQueryValidator = module.exports = Base.extend({
component = component.getValue();

var isMatching = Util.textMatch(component, textMatch.value, textMatch["match-type"]);
return (textMatch["negate-condition"] ^ isMatching);
return (textMatch["negate-condition"] !== isMatching);
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure if this will yield the same results... did you check that?

@mikedeboer
Copy link
Owner

Sorry if I sound like a jerk, but could you also just revert the == to === changes you made?

Everything else, except the question about the bitwise operator change, looks good to me! Thanks for working on this!

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