-
Notifications
You must be signed in to change notification settings - Fork 159
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
examples/data/addressbook/redis.js | ||
lib/CardDAV/**/* | ||
lib/DAV/**/* | ||
lib/DAVACL/**/* | ||
lib/shared/**/* | ||
lib/VObject/**/* | ||
test/**/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
"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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please set this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a best practice not to. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mikedeboer Done! |
||
"forin" : false, // true: Require filtering for..in loops with obj.hasOwnProperty() | ||
"immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` | ||
"indent" : 4, // {int} Number of spaces to use for indentation | ||
"latedef" : false, // true: Require variables/functions to be defined before being used | ||
"newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` | ||
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` | ||
"noempty" : true, // true: Prohibit use of empty blocks | ||
"nonew" : true, // true: Prohibit use of constructors for side-effects (without assignment) | ||
"plusplus" : false, // true: Prohibit use of `++` & `--` | ||
"quotmark" : "double", // Quotation mark consistency: | ||
|
||
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) | ||
"unused" : true, // true: Require all defined variables be used | ||
"strict" : true, // true: Requires all functions run in ES5 Strict Mode | ||
"trailing" : true, // true: Prohibit trailing whitespaces | ||
"maxparams" : false, // {int} Max number of formal params allowed per function | ||
"maxdepth" : false, // {int} Max depth of nested blocks (within functions) | ||
"maxstatements" : false, // {int} Max number statements per function | ||
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function | ||
"maxlen" : 100, // {int} Max number of characters per line | ||
|
||
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) | ||
"boss" : false, // true: Tolerate assignments where comparisons would be expected | ||
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints. | ||
"eqnull" : false, // true: Tolerate use of `== null` | ||
"esnext" : true, // true: Allow ES.next (ES6) syntax (ex: `const`) | ||
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features) | ||
// (ex: `for each`, multiple try/catch, function expression…) | ||
"evil" : false, // true: Tolerate use of `eval` and `new Function()` | ||
"expr" : false, // true: Tolerate `ExpressionStatement` as Programs | ||
"funcscope" : false, // true: Tolerate defining variables inside control statements | ||
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict') | ||
"iterator" : false, // true: Tolerate using the `__iterator__` property | ||
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block | ||
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings | ||
"laxcomma" : false, // true: Tolerate comma-first style coding | ||
"loopfunc" : false, // true: Tolerate functions being defined in loops | ||
"multistr" : false, // true: Tolerate multi-line strings | ||
"proto" : false, // true: Tolerate using the `__proto__` property | ||
"scripturl" : false, // true: Tolerate script-targeted URLs | ||
"smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment | ||
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` | ||
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation | ||
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;` | ||
"validthis" : false, // true: Tolerate using this in a non-constructor function | ||
|
||
"browser" : false, // Web Browser (window, document, etc) | ||
"couch" : false, // CouchDB | ||
"devel" : false, // Development/debugging (alert, confirm, etc) | ||
"dojo" : false, // Dojo Toolkit | ||
"jquery" : false, // jQuery | ||
"mootools" : false, // MooTools | ||
"node" : true, // Node.js | ||
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc) | ||
"prototypejs" : false, // Prototype and Scriptaculous | ||
"rhino" : false, // Rhino | ||
"worker" : false, // Web Workers | ||
"wsh" : false, // Windows Scripting Host | ||
"yui" : false, // Yahoo User Interface | ||
|
||
// Legacy | ||
"nomen" : false, // true: Prohibit dangling `_` in variables | ||
"onevar" : false, // true: Allow only one `var` statement per function | ||
"passfail" : false, // true: Stop on first error | ||
"white" : false, // true: Check against strict whitespace and indentation rules | ||
|
||
"globals" : {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
language: node_js | ||
node_js: | ||
- "0.8" | ||
- "0.10" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.PHONY: default | ||
default: lint test | ||
|
||
.PHONY: lint | ||
lint: node_modules | ||
./node_modules/.bin/jshint examples/ lib/ test/ | ||
|
||
node_modules: | ||
npm install | ||
|
||
.PHONY: test | ||
test: node_modules test-mocha | ||
node test/test_base.js | ||
|
||
# TODO: test/test_ftp.js and test/test_xml.js need to be resurrected. | ||
.PHONY: test-mocha | ||
test-mocha: node_modules | ||
./node_modules/.bin/mocha \ | ||
test/test_codesearch.js \ | ||
test/test_filelist.js |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See http://bonsaiden.github.io/JavaScript-Garden/#types.equality for a discussion There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I make a point of not knowing how |
||
coll.ensureIndex(op.data, {unique: true}, next); | ||
else | ||
coll.insert(op.data, next); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why you'd want to prohibit this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bitwise operators are very "low-level". You shouldn't be thinking in terms of them, ideally. In programming, you should strive to describe what you would like done and not how to do it. There's an interesting, somewhat tangential discussion here http://latentflip.com/imperative-vs-declarative/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I don't think this is used in jsDAV, I'm fine with it. As I'm a low-level kind of programmer, mixing my days with C, Obj-C, JS and other things, I don't really see a problem... it's just a bit of basic CS.
But, if it helps contributors write better code, it'll be worth it ;)