Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

set `forin` option to `true` #4

Merged
merged 1 commit into from about 1 year ago

2 participants

Eugene Kashida Dav Glass
Eugene Kashida
Collaborator

Also includes documentation updates.

Dav Glass davglass merged commit ab74e58 into from
Dav Glass davglass closed this
Dav Glass
Owner

Published in yui-lint@0.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 04, 2013
Eugene Kashida fix typso and documentation++ 968370a
This page is out of date. Refresh to see the latest.
44  README.md
Source Rendered
@@ -8,9 +8,9 @@ and our contributors to also abide by.
8 8
 Every application that YUI creates to aid in development will follow
9 9
 by all of the config options in this package.
10 10
 
11  
-In the past we had always tried to abide by JSLint's stricter 
  11
+In the past we had always tried to abide by JSLint's stricter
12 12
 ruleset, but as we and our community have grown over the years
13  
-it's come to our attention that they are no longer benefictial
  13
+it's come to our attention that they are no longer beneficial
14 14
 to us and we should look for an alternative. So we decided that we
15 15
 will now use [JSHint](http://jshint.com/) as our default linting tool with one predefined
16 16
 set of options.
@@ -29,13 +29,29 @@ Special Options
29 29
 
30 30
 **Special options should never be used file wide.**
31 31
 
32  
-They should only be added at the method level with a comment that explains why they
33  
-are needed.
34  
-
35  
-For example, we use a *whitelist* approach to filtering an `Object` for performance
36  
-in several places. In this case, we skip the `hasOwnProperty` check when iterating
37  
-that object. In that case the developer should add the `/*jshint forin: false */` comment
38  
-only inside the function that they are calling the offending code..
  32
+Options should only be overriden in special cases, should be explained with a
  33
+comment, and should have minimal scope (i.e., at the method level or bracketed
  34
+around the code in question).
  35
+
  36
+For example, we might use a *whitelist* approach in filtering an object where
  37
+we skip the `hasOwnProperty` check. In this case, the developer should use
  38
+jshint directives to temporarily disable the `forin` option around the
  39
+offending code:
  40
+
  41
+```
  42
+var obj = {
  43
+    apple: 10,
  44
+    orange: 11,
  45
+    kiwi: 12
  46
+};
  47
+
  48
+// Intentionally skipping the hasOwnProperty check.
  49
+/*jshint forin: false*/
  50
+for (prop in obj) {
  51
+    receiver[prop] = supplier[prop];
  52
+}
  53
+/*jshint forin: true*/
  54
+```
39 55
 
40 56
 Build Status
41 57
 ------------
@@ -54,7 +70,7 @@ From inside your package.json:
54 70
     {
55 71
         "devDependencies": {
56 72
             "jshint": "~0.9.0",
57  
-            "yui-lint": "~0.1.0"
  73
+            "yui-lint": "~0.1.1"
58 74
         },
59 75
         "scripts": {
60 76
             "pretest": "jshint --config ./node_modules/yui-lint/jshint.json ./lib/*.js"
@@ -68,13 +84,13 @@ The Rules
68 84
 
69 85
 For more information on these properties, check out the [jshint docs](http://www.jshint.com/docs/)
70 86
 
71  
-    "browser":      true,   //the standard browser globals should be predefined
72  
-    "node":         true,   //Node.js globals should be predefined
73  
-    "yui":          true,   //YUI Globals 
  87
+    "browser":      true,   // true if the standard browser globals should be predefined
  88
+    "node":         true,   // true if Node.js globals should be predefined
  89
+    "yui":          true,   // true if YUI globals should be predefined
74 90
     "bitwise":      true,   // true if bitwise operators should not be allowed
75 91
     "curly":        true,   // true if curly braces should be required around blocks in loops and conditionals
76 92
     "eqeqeq":       true,   // true if === should be required (for ALL equality comparisons)
77  
-    "forin":        false,  // true if unfiltered 'for in' statements should be forbidden
  93
+    "forin":        true,   // true if unfiltered 'for in' statements should be forbidden
78 94
     "immed":        true,   // true if immediate function invocations must be wrapped in parens
79 95
     "newcap":       true,   // true if Initial Caps must be used with constructor functions
80 96
     "noarg":        true,   // true if arguments.caller and arguments.callee should be forbidden
2  jshint.json
@@ -5,7 +5,7 @@
5 5
     "bitwise":      true,
6 6
     "curly":        true,
7 7
     "eqeqeq":       true,
8  
-    "forin":        false,
  8
+    "forin":        true,
9 9
     "immed":        true,
10 10
     "newcap":       true,
11 11
     "noarg":        true,
2  package.json
... ...
@@ -1,6 +1,6 @@
1 1
 {
2 2
     "name": "yui-lint",
3  
-    "description": "Default JSHint rules used by YUI in it's various packages",
  3
+    "description": "Default JSHint rules used by YUI in its various packages",
4 4
     "version": "0.1.1",
5 5
     "main": "./yui-lint.js",
6 6
     "dependencies": {
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.