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: https://github.com/nodejs/node/pull/6255
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
This commit is contained in:
Rich Trott 2016-04-17 23:41:59 -07:00 committed by James M Snell
parent 8ede3d5002
commit 4faaed69fa
13 changed files with 19 additions and 26 deletions

View File

@ -1,8 +1,6 @@
## Test-specific linter rules
rules:
## allow undeclared variables
no-undef: 0
## common module is mandatory in tests
required-modules: [2, "common"]

View File

@ -5,6 +5,7 @@ process.nextTick(function() {
process.nextTick(function() {
process.nextTick(function() {
process.nextTick(function() {
// eslint-disable-next-line
undefined_reference_error_maker;
});
});

View File

@ -2,5 +2,6 @@
require('../common');
setTimeout(function() {
// eslint-disable-next-line no-undef
undefined_reference_error_maker;
});

View File

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

View File

@ -29,7 +29,7 @@ function err() {
});
// this function doesn't exist, and throws an error as a result.
err3();
err3(); // eslint-disable-line no-undef
}
function handle(e) {

View File

@ -1,22 +1,14 @@
'use strict';
require('../common');
var assert = require('assert');
const common = require('../common');
process.on('uncaughtException', function(err) {
console.log('Caught exception: ' + err);
});
var timeoutFired = false;
setTimeout(function() {
setTimeout(common.mustCall(function() {
console.log('This will still run.');
timeoutFired = true;
}, 500);
process.on('exit', function() {
assert.ok(timeoutFired);
});
}), 50);
// Intentionally cause an exception, but don't catch it.
nonexistentFunc();
console.log('This will not run.');
nonexistentFunc(); // eslint-disable-line no-undef
common.fail('This will not run.');

View File

@ -4,12 +4,14 @@ var assert = require('assert');
common.globalCheck = false;
baseFoo = 'foo';
baseFoo = 'foo'; // eslint-disable-line no-undef
global.baseBar = 'bar';
assert.equal('foo', global.baseFoo, 'x -> global.x in base level not working');
assert.equal('bar', baseBar, 'global.x -> x in base level not working');
assert.equal('bar',
baseBar, // eslint-disable-line no-undef
'global.x -> x in base level not working');
var module = require('../fixtures/global/plain');
const fooBar = module.fooBar;

View File

@ -3,7 +3,7 @@ var common = require('../common');
var http = require('http');
var server = http.createServer(function(req, res) {
intentionally_not_defined();
intentionally_not_defined(); // eslint-disable-line no-undef
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Thank you, come again.');
res.end();

View File

@ -21,7 +21,6 @@ if (common.isWindows) {
switch (process.argv[2]) {
case 'master': return master();
case 'worker': return worker();
case 'parent': return parent();
}
var ok;

View File

@ -10,7 +10,7 @@ let exceptionHandled = false;
process.nextTick(function() {
order.push('A');
// cause an error
what();
what(); // eslint-disable-line no-undef
});
// This nextTick function should remain in the queue when the first one

View File

@ -3,7 +3,7 @@ require('../common');
var assert = require('assert');
/*
in node 0.10 a bug existed that caused strict functions to not capture
In Node.js 0.10, a bug existed that caused strict functions to not capture
their environment when evaluated. When run in 0.10 `test()` fails with a
`ReferenceError`. See https://github.com/nodejs/node/issues/2245 for details.
*/
@ -21,7 +21,7 @@ function test() {
eval(code);
return bar();
return bar(); // eslint-disable-line no-undef
}

View File

@ -22,7 +22,7 @@ function err() {
function err2() {
// this function doesn't exist, and throws an error as a result.
err3();
err3(); // eslint-disable-line no-undef
}
function handleDomainError(e) {

View File

@ -301,7 +301,7 @@ errors.forEach(function(err) {
assert.equal(util.inspect(err), err.stack);
});
try {
undef();
undef(); // eslint-disable-line no-undef
} catch (e) {
assert.equal(util.inspect(e), e.stack);
}