Add "jake hint" task that checks all javaScript files using JSHint

This currently outputs many issues. These will be fixed in subsequent
commits.
redux
David Majda 13 years ago
parent a92676edce
commit c7f99019c2

@ -0,0 +1,9 @@
{
"curly": true,
"eqeqeq": true,
"evil": true,
"laxbreak": true,
"noempty": true,
"sub": true,
"nonew": true
}

@ -7,6 +7,8 @@ var PEGJS_VERSION = fs.readFileSync("VERSION", "utf8").trim();
/* Relative paths are here because of use in |require|. */
var SRC_DIR = "./src";
var TEST_DIR = "./test";
var BENCHMARK_DIR = "./benchmark";
var LIB_DIR = "./lib";
var BIN_DIR = "./bin";
var EXAMPLES_DIR = "./examples";
@ -14,6 +16,24 @@ var DIST_DIR = "./dist";
var DIST_WEB_DIR = "./dist/web";
var DIST_NODE_DIR = "./dist/node";
var SRC_FILES = fs.readdirSync(SRC_DIR).filter(function(file) {
return /\.js$/.test(file);
}).map(function(file) {
return SRC_DIR + "/" + file;
});
var TEST_FILES = fs.readdirSync(TEST_DIR).filter(function(file) {
return /-test\.js$/.test(file);
}).map(function(file) {
return TEST_DIR + "/" + file;
});
var TEST_HELPERS_FILE = TEST_DIR + "/helpers.js";
var TEST_RUN_FILE = TEST_DIR + "/run";
var BENCHMARK_BENCHMARKS_FILE = BENCHMARK_DIR + "/benchmarks.js";
var BENCHMARK_RUNNER_FILE = BENCHMARK_DIR + "/runner.js";
var BENCHMARK_RUN_FILE = BENCHMARK_DIR + "/run";
var PEGJS = BIN_DIR + "/pegjs";
var PEGJS_SRC_FILE = SRC_DIR + "/peg.js";
@ -25,6 +45,8 @@ var PEGJS_DIST_MIN_FILE = DIST_WEB_DIR + "/peg-" + PEGJS_VERSION + ".min.js"
var PARSER_SRC_FILE = SRC_DIR + "/parser.pegjs";
var PARSER_OUT_FILE = SRC_DIR + "/parser.js";
var JAKEFILE = "./Jakefile";
function exitFailure() {
process.exit(1);
}
@ -185,4 +207,22 @@ task("benchmark", ["build"], function(runCount) {
process.on("exit", function() { complete(); });
}, true);
desc("Run JSHint");
task("hint", ["build"], function() {
var process = childProcess.spawn(
"jshint",
SRC_FILES.concat(TEST_FILES).concat([
TEST_HELPERS_FILE,
TEST_RUN_FILE,
BENCHMARK_BENCHMARKS_FILE,
BENCHMARK_RUNNER_FILE,
BENCHMARK_RUN_FILE,
PEGJS,
JAKEFILE
]),
{ customFds: [0, 1, 2] }
);
process.on("exit", function() { complete(); });
}, true);
task("default", ["build"], function() {});

@ -16,7 +16,8 @@
},
"devDependencies": {
"jake": ">= 0.1.10",
"uglify-js": ">= 0.0.5"
"uglify-js": ">= 0.0.5",
"jshint": ">= 0.3.1"
},
"engines": {
"node": ">= 0.4.4"

Loading…
Cancel
Save