jscs
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -10,6 +10,8 @@ var treeIterator = require('./tree-iterator'); | ||
var index = this._index = {}; | ||
this.iterate(function(node) { | ||
this.iterate(function(node, parentNode, parentCollection) { | ||
if (node) { | ||
var type = node.type; | ||
if (type) { | ||
node.parentNode = parentNode; | ||
node.parentCollection = parentCollection; | ||
(index[type] || (index[type] = [])).push(node); | ||
@@ -16,0 +18,0 @@ } |
@@ -34,3 +34,3 @@ var assert = require('assert'); | ||
) { | ||
errors.add('Implicit binary conversion', node.loc.start); | ||
errors.add('Implicit boolean conversion', node.loc.start); | ||
} | ||
@@ -37,0 +37,0 @@ }); |
@@ -53,12 +53,16 @@ module.exports = { | ||
function iterate(node, cb) { | ||
var nodesToIterate = [node]; | ||
var currentNode; | ||
while (!!(currentNode = nodesToIterate.shift())) { | ||
cb(currentNode); | ||
for (var i in currentNode) { | ||
if (iterableProperties[i]) { | ||
var contents = currentNode[i]; | ||
function iterate(node, cb, parentNode, parentCollection) { | ||
cb(node, parentNode, parentCollection); | ||
for (var propName in node) { | ||
if (node.hasOwnProperty(propName)) { | ||
if (iterableProperties[propName]) { | ||
var contents = node[propName]; | ||
if (typeof contents === 'object') { | ||
nodesToIterate = nodesToIterate.concat(contents); | ||
if (Array.isArray(contents)) { | ||
for (var i = 0, l = contents.length; i < l; i++) { | ||
iterate(contents[i], cb, node, contents); | ||
} | ||
} else { | ||
iterate(contents, cb, node, [ contents ]); | ||
} | ||
} | ||
@@ -65,0 +69,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"name" : "jscs", | ||
"version" : "0.0.1", | ||
"version" : "0.0.2", | ||
"repository" : "https://github.com/mdevils/jscs", | ||
@@ -8,0 +8,0 @@ "contributors" : [ |
@@ -31,3 +31,3 @@ node-jscs | ||
``` | ||
```javascript | ||
{ | ||
@@ -34,0 +34,0 @@ /* |
Sorry, the diff of this file is not supported yet
60331
1428