Skip to content

Commit d0bcd9e

Browse files
committed
Add jshint task in gulpfile and lint all js files
1 parent fc40826 commit d0bcd9e

File tree

6 files changed

+21
-7
lines changed

6 files changed

+21
-7
lines changed

gulpfile.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ var gulp = require('gulp'),
55
concat = require('gulp-concat'),
66
mocha = require('gulp-mocha'),
77
shell = require('gulp-shell'),
8-
del = require('del');
8+
del = require('del'),
9+
jshint = require('gulp-jshint'),
10+
stylish = require('jshint-stylish');
911

1012
gulp.task('clean', function(cb) {
1113
del('lib/**/*.*', cb);
@@ -44,5 +46,12 @@ gulp.task('bench', shell.task([
4446
'node benchmark/benchmark.js'
4547
]));
4648

47-
gulp.task('default', ['test', 'compile'], function() {
49+
gulp.task('lint', function() {
50+
return gulp.src('./src/**/*.js')
51+
.pipe(jshint())
52+
.pipe(jshint.reporter(stylish))
53+
.pipe(jshint.reporter('fail'));
54+
});
55+
56+
gulp.task('default', ['lint', 'test', 'compile'], function() {
4857
});

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
"gulp": "^3.8.10",
2424
"gulp-browserify": "^0.5.0",
2525
"gulp-concat": "^2.4.1",
26+
"gulp-jshint": "^1.9.0",
2627
"gulp-mocha": "^2.0.0",
2728
"gulp-rename": "^1.2.0",
2829
"gulp-shell": "^0.2.10",
2930
"gulp-uglify": "^1.0.1",
31+
"jshint-stylish": "^1.0.0",
3032
"mocha": "2.0.x",
3133
"should": "4.3.x"
3234
},

src/core/Node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ function Node(x, y, walkable) {
2323
* @type boolean
2424
*/
2525
this.walkable = (walkable === undefined ? true : walkable);
26-
};
26+
}
2727

2828
module.exports = Node;

src/finders/BestFirstFinder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function BestFirstFinder(opt) {
1818
this.heuristic = function(dx, dy) {
1919
return orig(dx, dy) * 1000000;
2020
};
21-
};
21+
}
2222

2323
BestFirstFinder.prototype = new AStarFinder();
2424
BestFirstFinder.prototype.constructor = BestFirstFinder;

src/finders/IDAStarFinder.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ IDAStarFinder.prototype.findPath = function(startX, startY, endX, endY, grid) {
127127
// return h(a, end) - h(b, end);
128128
//});
129129

130+
131+
/*jshint -W084 *///Disable warning: Expected a conditional expression and instead saw an assignment
130132
for(k = 0, min = Infinity; neighbour = neighbours[k]; ++k) {
131-
133+
/*jshint +W084 *///Enable warning: Expected a conditional expression and instead saw an assignment
132134
if(this.trackRecursion) {
133135
// Retain a copy for visualisation. Due to recursion, this
134136
// node may be part of other paths too.

src/finders/JPFMoveDiagonallyIfNoObstacles.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ JPFMoveDiagonallyIfNoObstacles.prototype._findNeighbors = function(node) {
114114
}
115115
// search horizontally/vertically
116116
else {
117+
var isNextWalkable;
117118
if (dx !== 0) {
118-
var isNextWalkable = grid.isWalkableAt(x + dx, y);
119+
isNextWalkable = grid.isWalkableAt(x + dx, y);
119120
var isTopWalkable = grid.isWalkableAt(x, y + 1);
120121
var isBottomWalkable = grid.isWalkableAt(x, y - 1);
121122

@@ -136,7 +137,7 @@ JPFMoveDiagonallyIfNoObstacles.prototype._findNeighbors = function(node) {
136137
}
137138
}
138139
else if (dy !== 0) {
139-
var isNextWalkable = grid.isWalkableAt(x, y + dy);
140+
isNextWalkable = grid.isWalkableAt(x, y + dy);
140141
var isRightWalkable = grid.isWalkableAt(x + 1, y);
141142
var isLeftWalkable = grid.isWalkableAt(x - 1, y);
142143

0 commit comments

Comments
 (0)