Issue #2008 - Add jshint

This commit is contained in:
Jon Buckley 2013-01-31 18:29:37 -05:00
parent 1a1c5abca6
commit 19dbeaa23e
4 changed files with 71 additions and 0 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ build/
tags
.DS_Store
Makefile
node_modules/

19
.jshintrc Normal file
View File

@ -0,0 +1,19 @@
{
// Environments
"browser": true,
"devel": true,
"es5": true,
"worker": true,
// Enforcing
// Relaxing
"boss": true,
"funcscope": true,
"globalstrict": true,
"loopfunc": true,
"maxerr": 1000,
"nonstandard": true,
"sub": true,
"validthis": true
}

23
make.js
View File

@ -971,6 +971,29 @@ target.lint = function() {
crlfchecker.checkIfCrlfIsPresent(LINT_FILES);
};
//
// make jshint
//
target.jshint = function() {
cd(ROOT_DIR);
echo();
echo('### Linting JS files (this can take a while!)');
var LINT_FILES = [//'make.js',
//'external/builder/*.js',
//'external/crlfchecker/*.js',
'src/',
//'web/*.js',
//'test/*.js',
//'test/unit/*.js',
//'extensions/firefox/*.js',
//'extensions/firefox/components/*.js',
//'extensions/chrome/*.js'
];
exec('jshint --reporter test/reporter.js ' + LINT_FILES.join(' '));
};
//
// make clean
//

28
test/reporter.js Normal file
View File

@ -0,0 +1,28 @@
"use strict";
module.exports = {
reporter: function (res) {
var len = 0;
var str = "";
res.forEach(function (r) {
var file = r.file;
var err = r.error;
switch(err.code) {
case 'W004': // variable is already defined
case 'W018': // confusing use of !
break;
default:
len++;
str += file + ": line " + err.line + ", col " +
err.character + ", " + err.reason + "\n";
}
});
if (str) {
process.stdout.write(str + "\n" + len + " error" +
((len === 1) ? "" : "s") + "\n");
}
}
};