Skip to content

Commit 0125691

Browse files
committedOct 29, 2011
nested reporter: fixing nodelint failures (with white set to false for strict whitespace)
1 parent de9c0e3 commit 0125691

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed
 

‎lib/reporters/nested.js

+20-18
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ exports.run = function (files, options) {
3434
if (!options) {
3535
// load default options
3636
var content = fs.readFileSync(
37-
__dirname + '/../../bin/nodeunit.json', 'utf8'
37+
__dirname + '/../../bin/nodeunit.json',
38+
'utf8'
3839
);
3940
options = JSON.parse(content);
4041
}
@@ -57,13 +58,14 @@ exports.run = function (files, options) {
5758
return path.join(process.cwd(), p);
5859
});
5960
var tracker = track.createTracker(function (tracker) {
61+
var i, names;
6062
if (tracker.unfinished()) {
6163
console.log('');
6264
console.log(error(bold(
6365
'FAILURES: Undone tests (or their setups/teardowns): '
6466
)));
65-
var names = tracker.names();
66-
for (var i = 0; i < names.length; i += 1) {
67+
names = tracker.names();
68+
for (i = 0; i < names.length; i += 1) {
6769
console.log('- ' + names[i]);
6870
}
6971
console.log('');
@@ -76,15 +78,16 @@ exports.run = function (files, options) {
7678
// i.e., whether this part has been printed yet.
7779
tracker.already_printed = {};
7880

79-
tracker.print_status = function(status, name_arr) {
81+
tracker.print_status = function (status, name_arr) {
8082
var txt = '';
8183
var space = " ";
82-
for (var i = 0; i < name_arr.length; i++) {
83-
var part = name_arr.slice(0, i+1).join(",");
84+
var part, i, k;
85+
for (i = 0; i < name_arr.length; i++) {
86+
part = name_arr.slice(0, i + 1).join(",");
8487
// Only print the part if it hasn't already been printed.
8588
if (!tracker.already_printed[part]) {
8689
// Indent once for each nested level
87-
for (var k = 0; k < i; k++) {
90+
for (k = 0; k < i; k++) {
8891
txt += space;
8992
}
9093
if (i === name_arr.length - 1) {
@@ -95,7 +98,8 @@ exports.run = function (files, options) {
9598
txt += bold(error(name_arr[i] + " (fail) ✖ "));
9699
}
97100
} else {
98-
// This is a testCase, just print the testCase name and a newline.
101+
// This is a testCase, just print the testCase name
102+
// and a newline.
99103
txt += name_arr[i];
100104
txt += "\n";
101105
}
@@ -115,16 +119,15 @@ exports.run = function (files, options) {
115119

116120
if (!assertions.failures()) {
117121
tracker.print_status('pass', name);
118-
}
119-
else {
122+
} else {
120123
tracker.print_status('fail', name);
121124
assertions.forEach(function (a) {
122125
if (a.failed()) {
123126
a = utils.betterErrors(a);
124127
if (a.error instanceof AssertionError && a.message) {
125128
console.log(
126129
'Assertion Message: ' +
127-
assertion_message(a.message)
130+
assertion_message(a.message)
128131
);
129132
}
130133
console.log(a.error.stack + '\n');
@@ -138,18 +141,17 @@ exports.run = function (files, options) {
138141
if (assertions.failures()) {
139142
console.log(
140143
'\n' + bold(error('FAILURES: ')) + assertions.failures() +
141-
'/' + assertions.length + ' assertions failed (' +
142-
assertions.duration + 'ms)'
144+
'/' + assertions.length + ' assertions failed (' +
145+
assertions.duration + 'ms)'
143146
);
144-
}
145-
else {
147+
} else {
146148
console.log(
147-
'\n' + bold(ok('OK: ')) + assertions.length +
148-
' assertions (' + assertions.duration + 'ms)'
149+
'\n' + bold(ok('OK: ')) + assertions.length +
150+
' assertions (' + assertions.duration + 'ms)'
149151
);
150152
}
151153
},
152-
testStart: function(name) {
154+
testStart: function (name) {
153155
tracker.put(name);
154156
}
155157
});

‎nodelint.cfg

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
//See: http://www.jslint.com/lint.html#options
12
var options = {
3+
//white: false, // if false, strict whitespace rules should be enforced.
24
indent: 4,
3-
onevar: false
5+
onevar: false,
6+
vars: true // allow multiple var statement per function.
47
};

0 commit comments

Comments
 (0)