Permalink
Browse files

Moved from jslint to jshint and fixed new lint issues

  • Loading branch information...
davglass committed Oct 5, 2012
1 parent ba119fe commit fd1aae5da22e1d5a9e35ffa12267b925e9ac9e36
Showing with 33 additions and 39 deletions.
  1. +11 −13 lib/coverage.js
  2. +3 −3 lib/index.js
  3. +6 −6 lib/options.js
  4. +2 −4 lib/server.js
  5. +8 −11 lib/wrapper/wrapper.js
  6. +3 −2 package.json
View
@@ -1,5 +1,4 @@
var istanbul = require('istanbul');
-var path = require('path');
var Table = require('cli-table');
var util = require('../lib/index');
var coverageInfo = {};
@@ -43,10 +42,10 @@ var set = function(json) {
coverageInfo.push(json);
} else {
for (i in json) {
- if (json[i].coveredLines !== undefined) { //YUITest
+ if (json[i].coveredLines !== undefined) { //YUITest
coverageInfo[i] = coverageInfo[i] || {};
coverageInfo[i].path = i;
-
+ /*jshint loopfunc: true */
['calledLines', 'calledFunctions', 'coveredLines', 'coveredFunctions'].forEach(function(prop) {
coverageInfo[i][prop] = coverageInfo[i][prop] || 0;
coverageInfo[i][prop] = Math.max(coverageInfo[i][prop], json[i][prop], 0);
@@ -82,16 +81,16 @@ var printYUITestReport = function() {
items.sort(function(a, b) {
if (!a.path || !b.path) {
return 0;
- }
+ }
var an = a.path.toLowerCase(),
bn = b.path.toLowerCase(),
- ret = 0;
+ ret = 0;
if (an < bn) {
ret = -1;
- }
+ }
if (an > bn) {
- ret = 1;
+ ret = 1;
}
return ret;
});
@@ -105,7 +104,7 @@ var printYUITestReport = function() {
row.calledLines + '/' + row.coveredLines,
percentLine + '%',
row.calledFunctions + '/' + row.coveredFunctions,
- percentFunction + '%',
+ percentFunction + '%'
];
['calledLines', 'calledFunctions', 'coveredLines', 'coveredFunctions'].forEach(function(prop) {
@@ -135,7 +134,7 @@ var printYUITestReport = function() {
totals.calledLines + '/' + totals.coveredLines,
Math.floor((totals.calledLines / totals.coveredLines) * 100) + '%',
totals.calledFunctions + '/' + totals.coveredFunctions,
- Math.floor((totals.calledFunctions / totals.coveredFunctions) * 100) + '%',
+ Math.floor((totals.calledFunctions / totals.coveredFunctions) * 100) + '%'
]);
console.log(table.toString());
};
@@ -204,7 +203,7 @@ var printIstanbulReport = function() {
var report = function() {
if (coverageType === 'istanbul') {
- printIstanbulReport();
+ printIstanbulReport();
} else {
printYUITestReport();
}
@@ -244,12 +243,12 @@ var getIstanbulStatus = function(coverage) {
lines.push(summary.lines.pct);
pct += summary.lines.pct;
});
-
+
str = util.color(' ' + Math.floor(pct / lines.length) + '%', 'blue');
return str;
};
-var status = function(json) {
+exports.status = function(json) {
var out;
if (isIstanbul(json)) {
coverageType = 'istanbul';
@@ -260,4 +259,3 @@ var status = function(json) {
return out;
};
-exports.status = status;
View
@@ -84,7 +84,7 @@ mods = {
console.log(mods.color(str, 'bold+blue'));
},
status: function(json, start, end) {
- var str = (json.failed ? mods.color(bad, 'bold+red') : mods.color(good, 'bold+green')) +
+ var str = (json.failed ? mods.color(bad, 'bold+red') : mods.color(good, 'bold+green')) +
' ' + mods.color('[' + json.name + ']:', (json.failed ? 'red' : 'blue') + '+bold') +
' Passed: ' + (json.passed ? mods.color(String(json.passed), 'green+bold') : json.passed) +
' Failed: ' + (json.failed ? mods.color(String(json.failed), 'red+bold') : json.failed) +
@@ -96,7 +96,7 @@ mods = {
}
console.log(str);
-
+
if (json.failed) {
if (json.error) {
printFail('Javascript Error', json.error);
@@ -127,7 +127,7 @@ mods = {
if (start && end) {
exports.log(' [Timer] ' + timer(start, end));
}
-
+
}
};
View
@@ -66,7 +66,7 @@ var path = require('path'),
break;
case "-i":
case "--import":
- options.import = args.shift();
+ options['import'] = args.shift();
break;
case "-s":
case "--silent":
@@ -132,7 +132,7 @@ var path = require('path'),
console.log(' --junit JUnit XML export');
console.log(' --server Starts a static file server in the CWD, tests should be relative to this directory');
console.log(' --port <Number> The port to start the server on');
- console.log(' --coverage Generate a coverage report and print it to the screen (you must instrument your own files with YUITest first)');
+ console.log(' --coverage Generate a coverage report and print it to the screen (you must instrument your own files first)');
console.log(' --coverage-warn <Number> The percentage to highlight as low coverage: default is 80');
console.log(' --no-run Do not execute the tests, just prep the server (for other testing)');
process.exit();
@@ -177,11 +177,11 @@ var path = require('path'),
options.timeout = null;
}
- if (options.import) {
- if (!existsSync(options.import) || existsSync(path.join(process.cwd(), options.import))) {
- options.import = path.join(process.cwd(), options.import);
+ if (options['import']) {
+ if (!existsSync(options['import']) || existsSync(path.join(process.cwd(), options['import']))) {
+ options['import'] = path.join(process.cwd(), options['import']);
}
- paths = require(options.import);
+ paths = require(options['import']);
if (paths && paths.length) {
options.paths = paths;
}
View
@@ -1,12 +1,10 @@
-var http = require('http'),
- util = require('./index'),
+var util = require('./index'),
path = require('path'),
url = require('url'),
fs = require('fs'),
express = require('express'),
echoecho = require('echoecho'),
exists = fs.exists || path.exists,
- existsSync = fs.existsSync || path.existsSync,
server;
exports.stop = function() {
@@ -70,7 +68,7 @@ exports.start = function(options) {
server.get('/'+'*', handler);
server.post('/'+'*', handler);
- server.delete('/'+'*', handler);
+ server['delete']('/'+'*', handler);
server.put('/'+'*', handler);
View
@@ -13,13 +13,9 @@ Timeout: Specify a timeout (override too) to kill a test
var waitTimer,
waitCounter = 0,
testTimer,
- fs = require('fs'),
file = phantom.args[0],
timeout = parseInt(phantom.args[1], 10),
- timer,
- filterName = function(str) {
- return str.replace(/ /g, '_').replace(/\//g, '_');
- };
+ timer;
var injectGetYUITest = function() {
window.TestResults = null;
@@ -40,7 +36,7 @@ var injectGetYUITest = function() {
json = JSON.parse(json);
json.coverage = cover;
json = JSON.stringify(json);
-
+
}
if (json && window.__coverage__) {
json = JSON.parse(json);
@@ -60,10 +56,11 @@ var startTest = function(page, cb) {
testTimer = setInterval(function() {
//console.log('Checking..');
var status = page.evaluate(function() {
- var t = window.getYUITest();
+ var t = window.getYUITest(),
+ i, name;
if (t) {
- for (var i in t) {
- var name = i.replace('Test', '');
+ for (i in t) {
+ name = i.replace('Test', '');
t[name] = t[i];
}
}
@@ -127,10 +124,10 @@ var executeTest = function(file, cb) {
height: 768
};
- page.onConsoleMessage = function(msg) {
+ page.onConsoleMessage = function() {
//console.log('[console.log]', msg);
};
- page.onAlert = function(msg) {
+ page.onAlert = function() {
//console.log('[window.alert]', msg);
};
page.onError = function(msg, trace) {
View
@@ -16,11 +16,12 @@
"glob": "~3.1.12"
},
"devDependencies": {
- "jslint": "*",
+ "yui-lint": "~0.1.1",
+ "jshint": "~0.9.0",
"yuitest": "*"
},
"scripts": {
- "pretest": "./node_modules/.bin/jslint --white --sloppy --node --stupid --nomen --plusplus --forin ./bin/*.js ./lib/*.js",
+ "pretest": "jshint --config ./node_modules/yui-lint/jshint.json ./lib/*.js ./lib/*/*.js",
"test": "./tests/test.sh"
},
"preferGlobal": "true"

0 comments on commit fd1aae5

Please sign in to comment.