Skip to content

Commit 24213ab

Browse files
committed
build: Enforce eslint rules
Fixed violations: * no-unused-vars * no-irregular-whitespace * no-empty
1 parent 939d76b commit 24213ab

19 files changed

Lines changed: 47 additions & 33 deletions

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/coverage

.eslintrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "eslint:recommended",
3+
"env": {
4+
"node": true,
5+
"qunit": true
6+
},
7+
"rules": {
8+
"no-console": 0
9+
}
10+
}

.jshintrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

lib/child.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ var QUnit = require('qunitjs'),
1313
require('../support/json/cycle');
1414

1515
var options = JSON.parse(process.argv.pop()),
16-
currentModule = path.basename(options.code.path, '.js'),
17-
currentTest;
16+
currentModule = path.basename(options.code.path, '.js');
1817

1918
// send ping messages to when child is blocked.
2019
// after I sent the first ping, testrunner will start to except the next ping
2120
// within maxBlockDuration, otherwise this process will be killed
2221
process.send({event: 'ping'});
23-
setInterval(function() {
22+
setInterval(function() {
2423
process.send({event: 'ping'});
2524
}, Math.floor(options.maxBlockDuration / 2));
2625

@@ -65,9 +64,6 @@ function _require(res, addToGlobal) {
6564
* @param {Object} test
6665
*/
6766
QUnit.testStart(function(test) {
68-
// currentTest is undefined while first test is not done yet
69-
currentTest = test.name;
70-
7167
// use last module name if no module name defined
7268
currentModule = test.module || currentModule;
7369
});

lib/coverage.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ var istanbul,
1010

1111
try {
1212
istanbul = require('istanbul');
13-
} catch (e) {}
13+
} catch (e) {
14+
// Ignore
15+
}
1416

1517
exports.setup = function(opts) {
1618
collector = new istanbul.Collector();

lib/generators.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
'use strict'
22

3-
/**
4-
* Is true when generators are supported.
5-
*/
6-
exports.support = false;
3+
var supported;
74

85
try {
96
eval("(function *(){})()");
10-
exports.support = true;
11-
} catch(err) {}
7+
supported = true;
8+
} catch(err) {
9+
supported = false;
10+
}
11+
12+
/**
13+
* Is true when generators are supported.
14+
*/
15+
exports.support = supported;
1216

1317
/**
1418
* Returns true if function is a generator fn.
1519
*
1620
* @param {Function} fn
1721
* @return {Boolean}
1822
*/
19-
exports.isGeneratorFn = function(fn) {
23+
exports.isGeneratorFn = function(fn) {
2024
return fn.constructor.name == 'GeneratorFunction';
2125
}

lib/testrunner.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
var fs = require('fs'),
2-
path = require('path'),
1+
var path = require('path'),
32
coverage = require('./coverage'),
43
cp = require('child_process'),
54
_ = require('underscore'),
@@ -177,7 +176,7 @@ exports.run = function(files, callback) {
177176
opts.code = absPath(opts.code);
178177
opts.tests = absPaths(opts.tests);
179178

180-
runOne(opts, function(err, stat) {
179+
runOne(opts, function(err) {
181180
if (err) {
182181
return callback(err, log.stats());
183182
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"node": ">=0.6.0 < 8.0"
3535
},
3636
"scripts": {
37-
"test": "node --harmony ./test/testrunner.js"
37+
"test": "node --harmony ./test/testrunner.js && eslint .",
38+
"lint": "eslint ."
3839
},
3940
"dependencies": {
4041
"argsparser": "^0.0.6",
@@ -46,6 +47,7 @@
4647
},
4748
"devDependencies": {
4849
"chainer": "^0.0.5",
50+
"eslint": "^3.17.1",
4951
"timekeeper": "^0.0.4"
5052
},
5153
"optionalDependencies": {

test/fixtures/async-code.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
exports.blubb = 123;
1+
exports.blubb = 123;

test/fixtures/async-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test('a', 2, function(assert){
1212
}, 100);
1313
});
1414

15-
test('2', 1, function (){
15+
test('2', 1, function (assert){
1616
assert.ok(true, "tests intermixing sync and async tests #2");
1717
});
1818

0 commit comments

Comments
 (0)