Permalink
Browse files

Apply jshint rules to tests as well

  • Loading branch information...
1 parent c971d10 commit bdd1f67a4e38d6e1e8ea08f4098b5e3181a29cf3 @gotwarlost committed Jan 27, 2013
View
@@ -13,7 +13,7 @@
],
"preferGlobal": true,
"scripts": {
- "pretest": "jshint --config ./node_modules/yui-lint/jshint.json lib/*js lib/command/*js lib/report/*js lib/store/*js lib/util/*js",
+ "pretest": "jshint --config ./node_modules/yui-lint/jshint.json lib/*js lib/command/*js lib/report/*js lib/store/*js lib/util/*js test/*js test/instrumentation/*js test/cli/*js test/other/*js",
"test": "test/run.js",
"posttest": "node ./lib/cli.js check-coverage --statements 95 --branches 80",
"docs": "npm install yuidocjs && node node_modules/yuidocjs/lib/cli.js ."
View
@@ -1,7 +1,6 @@
/*jslint nomen: true */
var path = require('path'),
fs = require('fs'),
- util = require('util'),
cp = require('child_process'),
Module = require('module'),
originalLoader = Module._extensions['.js'],
@@ -1,6 +1,5 @@
/*jslint nomen: true */
-var path = require('path'),
- helper = require('../cli-helper');
+var helper = require('../cli-helper');
module.exports = {
setUp: function (cb) {
@@ -17,7 +17,7 @@ module.exports = {
rimraf.sync(OUTPUT_DIR);
mkdirp.sync(OUTPUT_DIR);
helper.resetOpts();
- runCover([ 'test/run.js', '--report', 'none' ], function (results) {
+ runCover([ 'test/run.js', '--report', 'none' ], function (/* results */) {
cb();
});
},
@@ -10,16 +10,14 @@ var path = require('path'),
runCover = helper.runCommand.bind(null, COVER_COMMAND),
Reporter = require('../../lib/report/cobertura'),
Collector = require('../../lib/collector'),
- existsSync = fs.existsSync || path.existsSync,
- filename,
- cov;
+ existsSync = fs.existsSync || path.existsSync;
module.exports = {
setUp: function (cb) {
rimraf.sync(OUTPUT_DIR);
mkdirp.sync(OUTPUT_DIR);
helper.resetOpts();
- runCover([ 'test/run.js', '--report', 'none' ], function (results) {
+ runCover([ 'test/run.js', '--report', 'none' ], function (/* results */) {
cb();
});
},
@@ -32,8 +30,7 @@ module.exports = {
reportFile = path.resolve(OUTPUT_DIR, 'cobertura-coverage.xml'),
reporter = new Reporter({ dir: OUTPUT_DIR }),
obj,
- collector = new Collector(),
- numFiles;
+ collector = new Collector();
obj = JSON.parse(fs.readFileSync(file, 'utf8'));
collector.add(obj);
@@ -1,7 +1,6 @@
/*jslint nomen: true */
var path = require('path'),
fs = require('fs'),
- vm = require('vm'),
rimraf = require('rimraf'),
mkdirp = require('mkdirp'),
COMMAND = 'cover',
@@ -10,16 +10,14 @@ var path = require('path'),
runCover = helper.runCommand.bind(null, COVER_COMMAND),
Reporter = require('../../lib/report/html'),
Collector = require('../../lib/collector'),
- existsSync = fs.existsSync || path.existsSync,
- filename,
- cov;
+ existsSync = fs.existsSync || path.existsSync;
module.exports = {
setUp: function (cb) {
rimraf.sync(OUTPUT_DIR);
mkdirp.sync(OUTPUT_DIR);
helper.resetOpts();
- runCover([ 'test/run.js', '--report', 'none' ], function (results) {
+ runCover([ 'test/run.js', '--report', 'none' ], function (/* results */) {
cb();
});
},
@@ -102,7 +100,7 @@ module.exports = {
obj[k].code = code;
obj[k].path = mangled;
copy[mangled] = obj[k];
- test.ok(mangled != k); //verify something _did_ get mangled
+ test.ok(mangled !== k); //verify something _did_ get mangled
test.ok(copy[mangled].code);
});
collector.add(copy);
@@ -10,16 +10,14 @@ var path = require('path'),
runCover = helper.runCommand.bind(null, COVER_COMMAND),
Reporter = require('../../lib/report/lcov'),
Collector = require('../../lib/collector'),
- existsSync = fs.existsSync || path.existsSync,
- filename,
- cov;
+ existsSync = fs.existsSync || path.existsSync;
module.exports = {
setUp: function (cb) {
rimraf.sync(OUTPUT_DIR);
mkdirp.sync(OUTPUT_DIR);
helper.resetOpts();
- runCover([ 'test/run.js', '--report', 'none' ], function (results) {
+ runCover([ 'test/run.js', '--report', 'none' ], function (/* results */) {
cb();
});
},
@@ -10,16 +10,14 @@ var path = require('path'),
runCover = helper.runCommand.bind(null, COVER_COMMAND),
Reporter = require('../../lib/report/lcovonly'),
Collector = require('../../lib/collector'),
- existsSync = fs.existsSync || path.existsSync,
- filename,
- cov;
+ existsSync = fs.existsSync || path.existsSync;
module.exports = {
setUp: function (cb) {
rimraf.sync(OUTPUT_DIR);
mkdirp.sync(OUTPUT_DIR);
helper.resetOpts();
- runCover([ 'test/run.js', '--report', 'none' ], function (results) {
+ runCover([ 'test/run.js', '--report', 'none' ], function (/* results */) {
cb();
});
},
@@ -17,7 +17,7 @@ module.exports = {
rimraf.sync(OUTPUT_DIR);
mkdirp.sync(OUTPUT_DIR);
helper.resetOpts();
- runCover([ 'test/run.js', '--report', 'none' ], function (results) {
+ runCover([ 'test/run.js', '--report', 'none' ], function (/* results */) {
cb();
});
},
View
@@ -1,5 +1,4 @@
/*jslint nomen: true */
-/*global __coverage__ */
var Instrumenter = require('../lib/instrumenter'),
vm = require('vm'),
NO_OP = function () {},
@@ -74,7 +73,8 @@ function setup(file, codeArray, opts) {
opts.debug = opts.debug || process.env.DEBUG;
var expectError = opts.expectError,
- coverageVariable = typeof opts.coverageVariable === 'undefined' ? '$$coverage$$' : opts.coverageVariable, //exercise the case where RE substitutions for the preamble have $ signs
+ //exercise the case where RE substitutions for the preamble have $ signs
+ coverageVariable = typeof opts.coverageVariable === 'undefined' ? '$$coverage$$' : opts.coverageVariable,
ps = opts.embedSource || false,
verifier,
cover = new Instrumenter({
@@ -97,11 +97,11 @@ function setup(file, codeArray, opts) {
return;
}
var wrappedCode = '(function (args) { var output;\n' + generated + '\nreturn output;\n})',
- fn,
- output;
+ fn;
global[coverageVariable] = undefined;
fn = vm.runInThisContext(wrappedCode, __filename);
- verifier = new Verifier({ debug: opts.debug, file: file, fn: fn, code: codeArray, generatedCode: generated, coverageVariable: coverageVariable });
+ verifier = new Verifier({ debug: opts.debug, file: file, fn: fn, code: codeArray,
+ generatedCode: generated, coverageVariable: coverageVariable });
if (opts.debug) {
console.log('================== Original ============================================');
console.log(annotatedCode(codeArray));
@@ -3,6 +3,7 @@ var helper = require('../helper'),
code,
verifier;
+/*jshint maxlen: 500 */
module.exports = {
"with a simple do-while": {
setUp: function (cb) {
@@ -3,6 +3,7 @@ var helper = require('../helper'),
code,
verifier;
+/*jshint maxlen: 500 */
module.exports = {
"with a simple expression": {
setUp: function (cb) {
@@ -3,6 +3,7 @@ var helper = require('../helper'),
code,
verifier;
+/*jshint maxlen: 500 */
module.exports = {
"with a simple for-in": {
setUp: function (cb) {
@@ -3,6 +3,7 @@ var helper = require('../helper'),
code,
verifier;
+/*jshint maxlen: 500 */
module.exports = {
"with a simple function": {
setUp: function (cb) {
@@ -2,6 +2,8 @@
var helper = require('../helper'),
code,
verifier;
+
+/*jshint maxlen: 500 */
module.exports = {
"with a simple if": {
"as a statement": {
@@ -1,7 +1,6 @@
/*jslint nomen: true */
var helper = require('../helper'),
Instrumenter = require('../../lib/instrumenter'),
- path = require('path'),
code,
verifier;
@@ -2,6 +2,8 @@
var helper = require('../helper'),
code,
verifier;
+
+/*jshint maxlen: 500 */
module.exports = {
"with an empty switch": {
setUp: function (cb) {
@@ -3,6 +3,7 @@ var helper = require('../helper'),
code,
verifier;
+/*jshint maxlen: 500 */
module.exports = {
"with a simple while": {
setUp: function (cb) {
View
@@ -2,10 +2,10 @@
var hook = require('../../lib/hook'),
currentHook,
matcher = function (file) { return file.indexOf('foo.js') > 0; },
- transformer = function (code, file) { return 'module.exports.bar = function () { return "bar"; };'; },
- transformer2 = function (code, file) { return 'module.exports.blah = function () { return "blah"; };'; },
- badTransformer = function (code, file) { throw "Boo!"; },
- scriptTransformer = function (code, file) { return '(function () { return 42; }());'; };
+ transformer = function () { return 'module.exports.bar = function () { return "bar"; };'; },
+ transformer2 = function () { return 'module.exports.blah = function () { return "blah"; };'; },
+ badTransformer = function () { throw "Boo!"; },
+ scriptTransformer = function () { return '(function () { return 42; }());'; };
module.exports = {
"when require is hooked": {
View
@@ -75,10 +75,10 @@ module.exports = {
},
"should be able to register a new store": function (test) {
- function NStore(opts) {
+ function NStore() {
}
NStore.prototype = {
- set: function (file, content) { return 'x'; }
+ set: function (/* file, content */) { return 'x'; }
};
NStore.TYPE = 'nstore';
@@ -90,7 +90,7 @@ module.exports = {
},
"should not be able to register an invalid store": function (test) {
- function NStore(opts) {}
+ function NStore() {}
test.throws(function () {
Store.register(NStore);
},
@@ -107,7 +107,7 @@ module.exports = {
},
"should require overriding of all overrideables": function (test) {
- function NStore(opts) {}
+ function NStore() {}
NStore.TYPE = 'nstore';
util.inherits(NStore, Store);
Store.register(NStore);
View
@@ -1,7 +1,6 @@
#!/usr/bin/env node
-var path = require('path'),
- nodeunit = require('nodeunit'),
+var nodeunit = require('nodeunit'),
mkdirp = require('mkdirp'),
loader = require('./loader'),
common = require('./common');

0 comments on commit bdd1f67

Please sign in to comment.