diff --git a/package.json b/package.json index 7801ed885964e53f924355ddae3bb3d909007649..eecc9a09648dccf0957d9ccd54744eefca6de0ed 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "devDependencies": { "vows": "0.5.13", "awsbox": "0.2.12", - "irc": "0.3.3" + "irc": "0.3.3", + "jshint": "0.7.1" }, "scripts": { "postinstall": "./scripts/generate_ephemeral_keys.sh", diff --git a/tests/data/lib.jshintrc b/tests/data/lib.jshintrc new file mode 100644 index 0000000000000000000000000000000000000000..fa8c0257f97f0e09d30c121ae4930ac6bad0394d --- /dev/null +++ b/tests/data/lib.jshintrc @@ -0,0 +1,8 @@ +{ + "undef": true, + "node": true, + "es5": true, + "esnext": true, + "strict": false, + "sub": true +} diff --git a/tests/jshint-test.js b/tests/jshint-test.js new file mode 100755 index 0000000000000000000000000000000000000000..21f0570664352bf601c87c51c4e035f732036898 --- /dev/null +++ b/tests/jshint-test.js @@ -0,0 +1,39 @@ +#!/usr/bin/env node + +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +require('./lib/test_env.js'); + +// add lib/ to the require path + +const +assert = require('assert'), +vows = require('vows'), +fs = require('fs'), +path = require('path'), +exec = require('child_process').exec; + +var suite = vows.describe('jshint'); +var jshintPath = '../node_modules/jshint/bin/hint'; + +// disable vows (often flakey?) async error behavior +suite.options.error = false; + +suite.addBatch({ + "run jshint on the lib directory": { + topic: function () { + var child = exec(jshintPath + ' --config ./data/lib.jshintrc ../lib/ | grep "not defined"', {cwd: path.resolve(__dirname)}, this.callback); + }, + "no globals are created or referenced" : function (error, stdout, stderr) { + var errors = stdout.split("\n").length - 1; + assert.strictEqual(errors, 0); + } + } +}); + + +// run or export the suite. +if (process.argv[1] === __filename) suite.run(); +else suite.export(module);