Browse Source

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>
v4.x
Rich Trott 9 years ago
committed by Myles Borins
parent
commit
c76f214b90
  1. 2
      test/.eslintrc
  2. 1
      test/message/nexttick_throw.js
  3. 1
      test/message/timeout_throw.js
  4. 2
      test/parallel/test-domain-exit-dispose-again.js
  5. 2
      test/parallel/test-domain-exit-dispose.js
  6. 18
      test/parallel/test-exception-handler2.js
  7. 6
      test/parallel/test-global.js
  8. 2
      test/parallel/test-http-exceptions.js
  9. 1
      test/parallel/test-listen-fd-cluster.js
  10. 2
      test/parallel/test-next-tick-errors.js
  11. 4
      test/parallel/test-regress-GH-2245.js
  12. 2
      test/parallel/test-timers-reset-process-domain-on-throw.js
  13. 2
      test/parallel/test-util-inspect.js

2
test/.eslintrc

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

1
test/message/nexttick_throw.js

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

1
test/message/timeout_throw.js

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

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

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

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

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

18
test/parallel/test-exception-handler2.js

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

6
test/parallel/test-global.js

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

2
test/parallel/test-http-exceptions.js

@ -3,7 +3,7 @@ var common = require('../common');
var http = require('http'); var http = require('http');
var server = http.createServer(function(req, res) { 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.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Thank you, come again.'); res.write('Thank you, come again.');
res.end(); res.end();

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

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

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

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

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

@ -3,7 +3,7 @@ require('../common');
var assert = require('assert'); 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 their environment when evaluated. When run in 0.10 `test()` fails with a
`ReferenceError`. See https://github.com/nodejs/node/issues/2245 for details. `ReferenceError`. See https://github.com/nodejs/node/issues/2245 for details.
*/ */
@ -21,7 +21,7 @@ function test() {
eval(code); eval(code);
return bar(); return bar(); // eslint-disable-line no-undef
} }

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

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

2
test/parallel/test-util-inspect.js

@ -182,7 +182,7 @@ assert.equal(util.inspect(new Error('FAIL')), '[Error: FAIL]');
assert.equal(util.inspect(new TypeError('FAIL')), '[TypeError: FAIL]'); assert.equal(util.inspect(new TypeError('FAIL')), '[TypeError: FAIL]');
assert.equal(util.inspect(new SyntaxError('FAIL')), '[SyntaxError: FAIL]'); assert.equal(util.inspect(new SyntaxError('FAIL')), '[SyntaxError: FAIL]');
try { try {
undef(); undef(); // eslint-disable-line no-undef
} catch (e) { } catch (e) {
assert.equal(util.inspect(e), '[ReferenceError: undef is not defined]'); assert.equal(util.inspect(e), '[ReferenceError: undef is not defined]');
} }

Loading…
Cancel
Save