Skip to content
This repository has been archived by the owner on Mar 8, 2018. It is now read-only.

Commit

Permalink
Add jshint and make it part of the test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Edmund von der Burg committed Mar 14, 2013
1 parent 183e0c6 commit ade4324
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
1 change: 1 addition & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
23 changes: 23 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"node": true,
"es5": true,

"camelcase": true,
"curly": true,
"indent": 2,
"newcap": true,
"regexp": true,
"strict": true,
"trailing": true,
"undef": true,
"unused": true,

"predef": [
"describe",
"it",
"before",
"beforeEach",
"after",
"afterEach"
]
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"dependencies": {
"express": "~3.1.0",
"mocha": "~1.8.2",
"supertest": "~0.5.1"
"supertest": "~0.5.1",
"assert": "~0.4.9",
"jshint": "~1.1.0",
"glob": "~3.1.21"
}
}
46 changes: 46 additions & 0 deletions test/jshint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"use strict";

var JSHINT = require("jshint").JSHINT,
assert = require("assert"),
glob = require("glob"),
path = require("path"),
fs = require("fs");


var projectDir = path.normalize(path.join(__dirname, '..'));

var jsFiles = glob.sync(
"**/*.js",
{ cwd: projectDir }
);

var jshintrc = path.join(projectDir, '.jshintrc');
var jshintConfig = JSON.parse(fs.readFileSync(jshintrc).toString());

describe("Run jsHint on", function () {

jsFiles.forEach(function (file) {

if (/node_modules/.test(file)) {
return;
}

it(file, function () {
var content = fs.readFileSync(path.join(projectDir, file)).toString();

var success = JSHINT(
content,
jshintConfig
);

var errorMessage = "";
if (!success) {
// console.log(JSHINT.errors[0]);
errorMessage = "line " + JSHINT.errors[0].line + ": " + JSHINT.errors[0].raw;
}

assert.ok(success, errorMessage);
});
});

});

0 comments on commit ade4324

Please sign in to comment.