Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting errors + 'bench' not working on Windows #88

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do smarttabs and trailing options do? I couldn't find them in the jshint docs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smart tabs: http://jshint.com/docs/faq/

Trailing: looks like this was removed with v2.5, it warned for trailing
whitespace on lines

On Sunday, February 1, 2015, Raminder Singh [email protected]
wrote:

In .jshintrc
#88 (comment):

@@ -0,0 +1,17 @@
+{

  • "browser": false,
  • "node": true,
  • "globals": {
  • "require": true
  • },
  • "predef": {
  • },
  • "eqeqeq": true,
  • "quotmark": true,
  • "smarttabs": true,
  • "trailing": true,

What do smarttabs and trailing options do? I couldn't find them in the
jshint docs.

Reply to this email directly or view it on GitHub
https://github.com/qiao/PathFinding.js/pull/88/files#r23895774.

"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