Skip to content

Commit 9135794

Browse files
author
Josh Quintana
committed
Fix linting errors
1 parent 19572d2 commit 9135794

10 files changed

+30
-18
lines changed

.jshintrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"browser": false,
3+
"node": true,
4+
"globals": {
5+
"require": true
6+
},
7+
"predef": {
8+
},
9+
"eqeqeq": true,
10+
"quotmark": true,
11+
"smarttabs": true,
12+
"trailing": true,
13+
"undef": true,
14+
"unused": "vars",
15+
"eqnull": true,
16+
"strict": false
17+
}

benchmark/parse_map.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@
3030
*/
3131

3232
var fs = require('fs');
33-
var endOfLine = require('os').EOL;
3433

3534
function parse(filename) {
36-
var content = fs.readFileSync(filename).toString();
37-
var lines = content.split(endOfLine);
35+
var content = fs.readFileSync(filename, { encoding: 'utf8' });
36+
var lines = content.split(/\r?\n/);
3837
return {
3938
height : parseInt(lines[1].split(' ')[1]),
4039
width : parseInt(lines[2].split(' ')[1]),

src/core/Grid.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ function Grid(width, height, matrix) {
3838
*/
3939
Grid.prototype._buildNodes = function(width, height, matrix) {
4040
var i, j,
41-
nodes = new Array(height),
42-
row;
41+
nodes = new Array(height);
4342

4443
for (i = 0; i < height; ++i) {
4544
nodes[i] = new Array(width);
@@ -219,8 +218,7 @@ Grid.prototype.clone = function() {
219218
thisNodes = this.nodes,
220219

221220
newGrid = new Grid(width, height),
222-
newNodes = new Array(height),
223-
row;
221+
newNodes = new Array(height);
224222

225223
for (i = 0; i < height; ++i) {
226224
newNodes[i] = new Array(width);

src/core/Util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function smoothenPath(grid, path) {
142142
sx, sy, // current start coordinate
143143
ex, ey, // current end coordinate
144144
newPath,
145-
i, j, coord, line, testCoord, blocked;
145+
i, j, coord, line, testCoord, blocked, lastValidCoord;
146146

147147
sx = x0;
148148
sy = y0;

src/finders/IDAStarFinder.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var Util = require('../core/Util');
21
var Heuristic = require('../core/Heuristic');
32
var Node = require('../core/Node');
43
var DiagonalMovement = require('../core/DiagonalMovement');
@@ -112,7 +111,7 @@ IDAStarFinder.prototype.findPath = function(startX, startY, endX, endY, grid) {
112111
return f;
113112
}
114113

115-
if(node == end) {
114+
if(node === end) {
116115
route[depth] = [node.x, node.y];
117116
return node;
118117
}

src/finders/JPFAlwaysMoveDiagonally.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ JPFAlwaysMoveDiagonally.prototype._findNeighbors = function(node) {
7979
var parent = node.parent,
8080
x = node.x, y = node.y,
8181
grid = this.grid,
82-
px, py, nx, ny, dx, dy,
82+
px, py, dx, dy,
8383
neighbors = [], neighborNodes, neighborNode, i, l;
8484

8585
// directed pruning: can ignore most neighbors, unless forced.

src/finders/JPFMoveDiagonallyIfAtMostOneObstacle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ JPFMoveDiagonallyIfAtMostOneObstacle.prototype._findNeighbors = function(node) {
8585
var parent = node.parent,
8686
x = node.x, y = node.y,
8787
grid = this.grid,
88-
px, py, nx, ny, dx, dy,
88+
px, py, dx, dy,
8989
neighbors = [], neighborNodes, neighborNode, i, l;
9090

9191
// directed pruning: can ignore most neighbors, unless forced.

src/finders/JPFMoveDiagonallyIfNoObstacles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ JPFMoveDiagonallyIfNoObstacles.prototype._findNeighbors = function(node) {
8989
var parent = node.parent,
9090
x = node.x, y = node.y,
9191
grid = this.grid,
92-
px, py, nx, ny, dx, dy,
92+
px, py, dx, dy,
9393
neighbors = [], neighborNodes, neighborNode, i, l;
9494

9595
// directed pruning: can ignore most neighbors, unless forced.

src/finders/JPFNeverMoveDiagonally.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ JPFNeverMoveDiagonally.prototype._jump = function(x, y, px, py) {
5555
}
5656
}
5757
else {
58-
throw new Error("Only horizontal and vertical movements are allowed");
58+
throw new Error('Only horizontal and vertical movements are allowed');
5959
}
6060

6161
return this._jump(x + dx, y + dy, x, y);
@@ -71,7 +71,7 @@ JPFNeverMoveDiagonally.prototype._findNeighbors = function(node) {
7171
var parent = node.parent,
7272
x = node.x, y = node.y,
7373
grid = this.grid,
74-
px, py, nx, ny, dx, dy,
74+
px, py, dx, dy,
7575
neighbors = [], neighborNodes, neighborNode, i, l;
7676

7777
// directed pruning: can ignore most neighbors, unless forced.

src/finders/JumpPointFinderBase.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
var Heap = require('heap');
55
var Util = require('../core/Util');
66
var Heuristic = require('../core/Heuristic');
7-
var DiagonalMovement = require('../core/DiagonalMovement');
87

98
/**
109
* Base class for the Jump Point Search algorithm
@@ -73,8 +72,8 @@ JumpPointFinderBase.prototype._identifySuccessors = function(node) {
7372
neighbors, neighbor,
7473
jumpPoint, i, l,
7574
x = node.x, y = node.y,
76-
jx, jy, dx, dy, d, ng, jumpNode,
77-
abs = Math.abs, max = Math.max;
75+
jx, jy, d, ng, jumpNode,
76+
abs = Math.abs;
7877

7978
neighbors = this._findNeighbors(node);
8079
for(i = 0, l = neighbors.length; i < l; ++i) {

0 commit comments

Comments
 (0)