diff --git a/README.md b/README.md index dc7067c..acb5c75 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ and our contributors to also abide by. Every application that YUI creates to aid in development will follow by all of the config options in this package. -In the past we had always tried to abide by JSLint's stricter +In the past we had always tried to abide by JSLint's stricter ruleset, but as we and our community have grown over the years -it's come to our attention that they are no longer benefictial +it's come to our attention that they are no longer beneficial to us and we should look for an alternative. So we decided that we will now use [JSHint](http://jshint.com/) as our default linting tool with one predefined set of options. @@ -29,13 +29,29 @@ Special Options **Special options should never be used file wide.** -They should only be added at the method level with a comment that explains why they -are needed. - -For example, we use a *whitelist* approach to filtering an `Object` for performance -in several places. In this case, we skip the `hasOwnProperty` check when iterating -that object. In that case the developer should add the `/*jshint forin: false */` comment -only inside the function that they are calling the offending code.. +Options should only be overriden in special cases, should be explained with a +comment, and should have minimal scope (i.e., at the method level or bracketed +around the code in question). + +For example, we might use a *whitelist* approach in filtering an object where +we skip the `hasOwnProperty` check. In this case, the developer should use +jshint directives to temporarily disable the `forin` option around the +offending code: + +``` +var obj = { + apple: 10, + orange: 11, + kiwi: 12 +}; + +// Intentionally skipping the hasOwnProperty check. +/*jshint forin: false*/ +for (prop in obj) { + receiver[prop] = supplier[prop]; +} +/*jshint forin: true*/ +``` Build Status ------------ @@ -54,7 +70,7 @@ From inside your package.json: { "devDependencies": { "jshint": "~0.9.0", - "yui-lint": "~0.1.0" + "yui-lint": "~0.1.1" }, "scripts": { "pretest": "jshint --config ./node_modules/yui-lint/jshint.json ./lib/*.js" @@ -68,13 +84,13 @@ The Rules For more information on these properties, check out the [jshint docs](http://www.jshint.com/docs/) - "browser": true, //the standard browser globals should be predefined - "node": true, //Node.js globals should be predefined - "yui": true, //YUI Globals + "browser": true, // true if the standard browser globals should be predefined + "node": true, // true if Node.js globals should be predefined + "yui": true, // true if YUI globals should be predefined "bitwise": true, // true if bitwise operators should not be allowed "curly": true, // true if curly braces should be required around blocks in loops and conditionals "eqeqeq": true, // true if === should be required (for ALL equality comparisons) - "forin": false, // true if unfiltered 'for in' statements should be forbidden + "forin": true, // true if unfiltered 'for in' statements should be forbidden "immed": true, // true if immediate function invocations must be wrapped in parens "newcap": true, // true if Initial Caps must be used with constructor functions "noarg": true, // true if arguments.caller and arguments.callee should be forbidden diff --git a/jshint.json b/jshint.json index 9c637e0..da887da 100644 --- a/jshint.json +++ b/jshint.json @@ -5,7 +5,7 @@ "bitwise": true, "curly": true, "eqeqeq": true, - "forin": false, + "forin": true, "immed": true, "newcap": true, "noarg": true, diff --git a/package.json b/package.json index 350108a..697d603 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yui-lint", - "description": "Default JSHint rules used by YUI in it's various packages", + "description": "Default JSHint rules used by YUI in its various packages", "version": "0.1.1", "main": "./yui-lint.js", "dependencies": {