Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Quintana committed Jan 24, 2015
1 parent 19572d2 commit 9135794
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 18 deletions.
17 changes: 17 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -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
}
5 changes: 2 additions & 3 deletions benchmark/parse_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@
*/

var fs = require('fs');
var endOfLine = require('os').EOL;

function parse(filename) {
var content = fs.readFileSync(filename).toString();
var lines = content.split(endOfLine);
var content = fs.readFileSync(filename, { encoding: 'utf8' });
var lines = content.split(/\r?\n/);
return {
height : parseInt(lines[1].split(' ')[1]),
width : parseInt(lines[2].split(' ')[1]),
Expand Down
6 changes: 2 additions & 4 deletions src/core/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/core/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/finders/IDAStarFinder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var Util = require('../core/Util');
var Heuristic = require('../core/Heuristic');
var Node = require('../core/Node');
var DiagonalMovement = require('../core/DiagonalMovement');
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/finders/JPFAlwaysMoveDiagonally.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/finders/JPFMoveDiagonallyIfAtMostOneObstacle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/finders/JPFMoveDiagonallyIfNoObstacles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/finders/JPFNeverMoveDiagonally.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions src/finders/JumpPointFinderBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 9135794

Please sign in to comment.