Skip to content

Commit 48ecc0b

Browse files
TrottMyles Borins
authored and
Myles Borins
committed
test,tools: enable linting for undefined vars
The test directory had linting for undefined variables disabled. It is enabled everywhere else in the code base. Let's disable the fule for individual lines in the handful of tests that use undefined variables. PR-URL: #6255 Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
1 parent 4a1dfdc commit 48ecc0b

13 files changed

+19
-26
lines changed

test/.eslintrc

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
## Test-specific linter rules
22

33
rules:
4-
## allow undeclared variables
5-
no-undef: 0
64
## common module is mandatory in tests
75
required-modules: [2, "common"]
86

test/message/nexttick_throw.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ process.nextTick(function() {
55
process.nextTick(function() {
66
process.nextTick(function() {
77
process.nextTick(function() {
8+
// eslint-disable-next-line
89
undefined_reference_error_maker;
910
});
1011
});

test/message/timeout_throw.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
require('../common');
33

44
setTimeout(function() {
5+
// eslint-disable-next-line no-undef
56
undefined_reference_error_maker;
67
});

test/parallel/test-domain-exit-dispose-again.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ setTimeout(function firstTimer() {
5656
// Make V8 throw an unreferenced error. As a result, the domain's error
5757
// handler is called, which disposes the domain "d" and should prevent the
5858
// nested timer that is attached to it from running.
59-
err3();
59+
err3(); // eslint-disable-line no-undef
6060
});
6161
}, TIMEOUT_DURATION);
6262

test/parallel/test-domain-exit-dispose.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function err() {
2929
});
3030

3131
// this function doesn't exist, and throws an error as a result.
32-
err3();
32+
err3(); // eslint-disable-line no-undef
3333
}
3434

3535
function handle(e) {
+5-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
'use strict';
2-
require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
43

54
process.on('uncaughtException', function(err) {
65
console.log('Caught exception: ' + err);
76
});
87

9-
var timeoutFired = false;
10-
setTimeout(function() {
8+
setTimeout(common.mustCall(function() {
119
console.log('This will still run.');
12-
timeoutFired = true;
13-
}, 500);
14-
15-
process.on('exit', function() {
16-
assert.ok(timeoutFired);
17-
});
10+
}), 50);
1811

1912
// Intentionally cause an exception, but don't catch it.
20-
nonexistentFunc();
21-
console.log('This will not run.');
22-
13+
nonexistentFunc(); // eslint-disable-line no-undef
14+
common.fail('This will not run.');

test/parallel/test-global.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ var assert = require('assert');
44

55
common.globalCheck = false;
66

7-
baseFoo = 'foo';
7+
baseFoo = 'foo'; // eslint-disable-line no-undef
88
global.baseBar = 'bar';
99

1010
assert.equal('foo', global.baseFoo, 'x -> global.x in base level not working');
1111

12-
assert.equal('bar', baseBar, 'global.x -> x in base level not working');
12+
assert.equal('bar',
13+
baseBar, // eslint-disable-line no-undef
14+
'global.x -> x in base level not working');
1315

1416
var module = require('../fixtures/global/plain');
1517
const fooBar = module.fooBar;

test/parallel/test-http-exceptions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var common = require('../common');
33
var http = require('http');
44

55
var server = http.createServer(function(req, res) {
6-
intentionally_not_defined();
6+
intentionally_not_defined(); // eslint-disable-line no-undef
77
res.writeHead(200, {'Content-Type': 'text/plain'});
88
res.write('Thank you, come again.');
99
res.end();

test/parallel/test-listen-fd-cluster.js

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ if (common.isWindows) {
2121
switch (process.argv[2]) {
2222
case 'master': return master();
2323
case 'worker': return worker();
24-
case 'parent': return parent();
2524
}
2625

2726
var ok;

test/parallel/test-next-tick-errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let exceptionHandled = false;
1010
process.nextTick(function() {
1111
order.push('A');
1212
// cause an error
13-
what();
13+
what(); // eslint-disable-line no-undef
1414
});
1515

1616
// This nextTick function should remain in the queue when the first one

test/parallel/test-regress-GH-2245.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require('../common');
33
var assert = require('assert');
44

55
/*
6-
in node 0.10 a bug existed that caused strict functions to not capture
6+
In Node.js 0.10, a bug existed that caused strict functions to not capture
77
their environment when evaluated. When run in 0.10 `test()` fails with a
88
`ReferenceError`. See https://github.com/nodejs/node/issues/2245 for details.
99
*/
@@ -21,7 +21,7 @@ function test() {
2121

2222
eval(code);
2323

24-
return bar();
24+
return bar(); // eslint-disable-line no-undef
2525

2626
}
2727

test/parallel/test-timers-reset-process-domain-on-throw.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function err() {
2222

2323
function err2() {
2424
// this function doesn't exist, and throws an error as a result.
25-
err3();
25+
err3(); // eslint-disable-line no-undef
2626
}
2727

2828
function handleDomainError(e) {

test/parallel/test-util-inspect.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ assert.equal(util.inspect(new Error('FAIL')), '[Error: FAIL]');
182182
assert.equal(util.inspect(new TypeError('FAIL')), '[TypeError: FAIL]');
183183
assert.equal(util.inspect(new SyntaxError('FAIL')), '[SyntaxError: FAIL]');
184184
try {
185-
undef();
185+
undef(); // eslint-disable-line no-undef
186186
} catch (e) {
187187
assert.equal(util.inspect(e), '[ReferenceError: undef is not defined]');
188188
}

0 commit comments

Comments
 (0)