Skip to content

Commit

Permalink
test: fix block-scoped-var linter errors
Browse files Browse the repository at this point in the history
As per block-scoped-var rule, the variables which were used before
declaration or declared within a block and used outside are trated
as linter errors.

Refer: nodejs#3118
  • Loading branch information
thefourtheye committed Oct 4, 2015
1 parent cd2d641 commit b5207ba
Show file tree
Hide file tree
Showing 27 changed files with 34 additions and 19 deletions.
3 changes: 2 additions & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ exports.isWindows = process.platform === 'win32';
exports.isAix = process.platform === 'aix';

function rimrafSync(p) {
var st;
try {
var st = fs.lstatSync(p);
st = fs.lstatSync(p);
} catch (e) {
if (e.code === 'ENOENT')
return;
Expand Down
1 change: 1 addition & 0 deletions test/internet/test-dgram-broadcast-multi-process.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable block-scoped-var */
'use strict';
var common = require('../common'),
assert = require('assert'),
Expand Down
1 change: 1 addition & 0 deletions test/message/nexttick_throw.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable block-scoped-var */
'use strict';
var common = require('../common');
var assert = require('assert');
Expand Down
1 change: 1 addition & 0 deletions test/message/timeout_throw.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable block-scoped-var */
'use strict';
var common = require('../common');
var assert = require('assert');
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-child-process-stdio-big-write-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function parent() {
var sent = 0;

var n = '';
var buf;
child.stdout.setEncoding('ascii');
child.stdout.on('data', function(c) {
n += c;
Expand All @@ -29,7 +30,7 @@ function parent() {

// Write until the buffer fills up.
do {
var buf = new Buffer(BUFSIZE);
buf = new Buffer(BUFSIZE);
buf.fill('.');
sent += BUFSIZE;
} while (child.stdin.write(buf));
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-domain-crypto.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable strict */
/* eslint-disable strict, block-scoped-var */
try {
var crypto = require('crypto');
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-domain-exit-dispose-again.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable block-scoped-var */
'use strict';
var common = require('../common');
var assert = require('assert');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-domain-exit-dispose.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable block-scoped-var */
'use strict';
var common = require('../common');
var assert = require('assert');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-exception-handler2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable block-scoped-var */
'use strict';
var common = require('../common');
var assert = require('assert');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-global.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable strict */
/* eslint-disable strict, block-scoped-var */
var common = require('../common');
var assert = require('assert');

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-http-exceptions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable block-scoped-var */
'use strict';
var common = require('../common');
var assert = require('assert');
Expand Down
5 changes: 3 additions & 2 deletions test/parallel/test-https-resume-after-renew.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ hmac.fill('H');

server._sharedCreds.context.enableTicketKeyCallback();
server._sharedCreds.context.onticketkeycallback = function(name, iv, enc) {
var newName, newIV;
if (enc) {
var newName = new Buffer(16);
var newIV = crypto.randomBytes(16);
newName = new Buffer(16);
newIV = crypto.randomBytes(16);
newName.fill('A');
} else {
// Renew
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-intl.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable block-scoped-var */
'use strict';
var common = require('../common');
var assert = require('assert');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-listen-fd-cluster.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable block-scoped-var */
'use strict';
var common = require('../common');
var assert = require('assert');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-next-tick-errors.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable block-scoped-var */
'use strict';
var common = require('../common');
var assert = require('assert');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-process-versions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable block-scoped-var */
'use strict';
var common = require('../common');
var assert = require('assert');
Expand Down
8 changes: 2 additions & 6 deletions test/parallel/test-repl-syntax-error-handling.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ function parent() {

function child() {
var vm = require('vm');
try {
vm.runInThisContext('haf!@##&$!@$*!@', { displayErrors: false });
} catch (er) {
var caught = true;
}
assert(caught);
assert.throws(() =>
vm.runInThisContext('haf!@##&$!@$*!@', { displayErrors: false }), Error);
vm.runInThisContext('console.log(10)', { displayErrors: false });
}
2 changes: 1 addition & 1 deletion test/parallel/test-repl.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable max-len, strict */
/* eslint-disable max-len, strict, block-scoped-var */
var common = require('../common');
var assert = require('assert');

Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-stream2-writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ test('write backpressure', function(t) {

var i = 0;
(function W() {
var ret;
do {
var ret = tw.write(chunks[i++]);
ret = tw.write(chunks[i++]);
} while (ret !== false && i < chunks.length);

if (i < chunks.length) {
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable block-scoped-var */
'use strict';
var common = require('../common');
var assert = require('assert');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-vm-new-script-new-context.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable strict */
/* eslint-disable strict, block-scoped-var */
var common = require('../common');
var assert = require('assert');
var Script = require('vm').Script;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-vm-new-script-this-context.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable strict */
/* eslint-disable strict, block-scoped-var */
var common = require('../common');
var assert = require('assert');
var Script = require('vm').Script;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-vm-run-in-new-context.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable strict */
/* eslint-disable strict, block-scoped-var */
// Flags: --expose-gc

var common = require('../common');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-vm-static-this.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable strict */
/* eslint-disable strict, block-scoped-var */
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ Object.keys(tests).forEach(function(file) {
Def.name + ' -> ' + Inf.name;
var ok = true;
var testNum = ++done;
for (var i = 0; i < Math.max(c.length, test.length); i++) {
var i;
for (i = 0; i < Math.max(c.length, test.length); i++) {
if (c[i] !== test[i]) {
ok = false;
failures++;
Expand Down
1 change: 1 addition & 0 deletions test/pummel/test-net-connect-memleak.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ net.createServer(function() {}).listen(common.PORT);
var before = 0;
(function() {
// 2**26 == 64M entries
var junk;
gc();
for (var i = 0, junk = [0]; i < 26; ++i) junk = junk.concat(junk);
before = process.memoryUsage().rss;
Expand Down
1 change: 1 addition & 0 deletions test/pummel/test-tls-connect-memleak.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ tls.createServer({

(function() {
// 2**26 == 64M entries
var junk;
for (var i = 0, junk = [0]; i < 26; ++i) junk = junk.concat(junk);

var options = { rejectUnauthorized: false };
Expand Down

0 comments on commit b5207ba

Please sign in to comment.