This repository has been archived by the owner on Mar 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add jshint and make it part of the test suite
- Loading branch information
Edmund von der Burg
committed
Mar 14, 2013
1 parent
183e0c6
commit ade4324
Showing
4 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
|
||
}); |