diff --git a/.jshintrc b/.jshintrc new file mode 100755 index 00000000..103efe8d --- /dev/null +++ b/.jshintrc @@ -0,0 +1,17 @@ +{ + "browser": false, + "node": true, + "globals": { + "require": true + }, + "predef": { + }, + "eqeqeq": true, + "quotmark": true, + "smarttabs": true, + "trailing": true, + "undef": true, + "unused": "vars", + "eqnull": true, + "strict": false +} diff --git a/src/core/Grid.js b/src/core/Grid.js index c31b5ebf..9d5282b2 100644 --- a/src/core/Grid.js +++ b/src/core/Grid.js @@ -38,8 +38,7 @@ function Grid(width, height, matrix) { */ Grid.prototype._buildNodes = function(width, height, matrix) { var i, j, - nodes = new Array(height), - row; + nodes = new Array(height); for (i = 0; i < height; ++i) { nodes[i] = new Array(width); @@ -219,8 +218,7 @@ Grid.prototype.clone = function() { thisNodes = this.nodes, newGrid = new Grid(width, height), - newNodes = new Array(height), - row; + newNodes = new Array(height); for (i = 0; i < height; ++i) { newNodes[i] = new Array(width); diff --git a/src/core/Util.js b/src/core/Util.js index 615f5dd8..339b6c3a 100644 --- a/src/core/Util.js +++ b/src/core/Util.js @@ -142,7 +142,7 @@ function smoothenPath(grid, path) { sx, sy, // current start coordinate ex, ey, // current end coordinate newPath, - i, j, coord, line, testCoord, blocked; + i, j, coord, line, testCoord, blocked, lastValidCoord; sx = x0; sy = y0; diff --git a/src/finders/IDAStarFinder.js b/src/finders/IDAStarFinder.js index e40beafd..8880859c 100644 --- a/src/finders/IDAStarFinder.js +++ b/src/finders/IDAStarFinder.js @@ -1,4 +1,3 @@ -var Util = require('../core/Util'); var Heuristic = require('../core/Heuristic'); var Node = require('../core/Node'); var DiagonalMovement = require('../core/DiagonalMovement'); @@ -112,7 +111,7 @@ IDAStarFinder.prototype.findPath = function(startX, startY, endX, endY, grid) { return f; } - if(node == end) { + if(node === end) { route[depth] = [node.x, node.y]; return node; } diff --git a/src/finders/JPFAlwaysMoveDiagonally.js b/src/finders/JPFAlwaysMoveDiagonally.js index 6a1621ea..01e45f7f 100644 --- a/src/finders/JPFAlwaysMoveDiagonally.js +++ b/src/finders/JPFAlwaysMoveDiagonally.js @@ -79,7 +79,7 @@ JPFAlwaysMoveDiagonally.prototype._findNeighbors = function(node) { var parent = node.parent, x = node.x, y = node.y, grid = this.grid, - px, py, nx, ny, dx, dy, + px, py, dx, dy, neighbors = [], neighborNodes, neighborNode, i, l; // directed pruning: can ignore most neighbors, unless forced. diff --git a/src/finders/JPFMoveDiagonallyIfAtMostOneObstacle.js b/src/finders/JPFMoveDiagonallyIfAtMostOneObstacle.js index a89adaae..f6976404 100644 --- a/src/finders/JPFMoveDiagonallyIfAtMostOneObstacle.js +++ b/src/finders/JPFMoveDiagonallyIfAtMostOneObstacle.js @@ -85,7 +85,7 @@ JPFMoveDiagonallyIfAtMostOneObstacle.prototype._findNeighbors = function(node) { var parent = node.parent, x = node.x, y = node.y, grid = this.grid, - px, py, nx, ny, dx, dy, + px, py, dx, dy, neighbors = [], neighborNodes, neighborNode, i, l; // directed pruning: can ignore most neighbors, unless forced. diff --git a/src/finders/JPFMoveDiagonallyIfNoObstacles.js b/src/finders/JPFMoveDiagonallyIfNoObstacles.js index b22360dd..760cf3a8 100644 --- a/src/finders/JPFMoveDiagonallyIfNoObstacles.js +++ b/src/finders/JPFMoveDiagonallyIfNoObstacles.js @@ -89,7 +89,7 @@ JPFMoveDiagonallyIfNoObstacles.prototype._findNeighbors = function(node) { var parent = node.parent, x = node.x, y = node.y, grid = this.grid, - px, py, nx, ny, dx, dy, + px, py, dx, dy, neighbors = [], neighborNodes, neighborNode, i, l; // directed pruning: can ignore most neighbors, unless forced. diff --git a/src/finders/JPFNeverMoveDiagonally.js b/src/finders/JPFNeverMoveDiagonally.js index a006556e..c9991790 100644 --- a/src/finders/JPFNeverMoveDiagonally.js +++ b/src/finders/JPFNeverMoveDiagonally.js @@ -55,7 +55,7 @@ JPFNeverMoveDiagonally.prototype._jump = function(x, y, px, py) { } } else { - throw new Error("Only horizontal and vertical movements are allowed"); + throw new Error('Only horizontal and vertical movements are allowed'); } return this._jump(x + dx, y + dy, x, y); @@ -71,7 +71,7 @@ JPFNeverMoveDiagonally.prototype._findNeighbors = function(node) { var parent = node.parent, x = node.x, y = node.y, grid = this.grid, - px, py, nx, ny, dx, dy, + px, py, dx, dy, neighbors = [], neighborNodes, neighborNode, i, l; // directed pruning: can ignore most neighbors, unless forced. diff --git a/src/finders/JumpPointFinderBase.js b/src/finders/JumpPointFinderBase.js index 18396ed9..bcad4cea 100644 --- a/src/finders/JumpPointFinderBase.js +++ b/src/finders/JumpPointFinderBase.js @@ -4,7 +4,6 @@ var Heap = require('heap'); var Util = require('../core/Util'); var Heuristic = require('../core/Heuristic'); -var DiagonalMovement = require('../core/DiagonalMovement'); /** * Base class for the Jump Point Search algorithm @@ -73,8 +72,8 @@ JumpPointFinderBase.prototype._identifySuccessors = function(node) { neighbors, neighbor, jumpPoint, i, l, x = node.x, y = node.y, - jx, jy, dx, dy, d, ng, jumpNode, - abs = Math.abs, max = Math.max; + jx, jy, d, ng, jumpNode, + abs = Math.abs; neighbors = this._findNeighbors(node); for(i = 0, l = neighbors.length; i < l; ++i) {