Skip to content
Browse files

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

This currently outputs many issues. These will be fixed in subsequent
commits.
  • Loading branch information...
1 parent a92676e commit c7f99019c253b92075a4ece2a89b680b6e2a4ef4 @dmajda dmajda committed Sep 13, 2011
Showing with 51 additions and 1 deletion.
  1. +9 −0 .jshintrc
  2. +40 −0 Jakefile
  3. +2 −1 package.json
View
9 .jshintrc
@@ -0,0 +1,9 @@
+{
+ "curly": true,
+ "eqeqeq": true,
+ "evil": true,
+ "laxbreak": true,
+ "noempty": true,
+ "sub": true,
+ "nonew": true
+}
View
40 Jakefile
@@ -7,13 +7,33 @@ 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";
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() {});
View
3 package.json
@@ -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"

0 comments on commit c7f9901

Please sign in to comment.
Something went wrong with that request. Please try again.