Skip to content

Commit 5f99d62

Browse files
saquibkhanSaquib Khan
authored and
Saquib Khan
committed
test:lint Lint added for test folder.
Added closure linter for test folder. Fixed 2k+ issues in 900 files. After this fix there is no lint error in test scripts. Fixes nodejs#25280
1 parent 4d9c81b commit 5f99d62

File tree

301 files changed

+1863
-1777
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

301 files changed

+1863
-1777
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,10 @@ bench-idle:
419419
./node benchmark/idle_clients.js &
420420

421421
jslintfix:
422-
PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/fixjsstyle.py --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js
422+
PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/fixjsstyle.py --strict --nojsdoc -r lib/ -r src/ -r test/ --exclude_files lib/punycode.js
423423

424424
jslint:
425-
PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/gjslint.py --unix_mode --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js
425+
PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/gjslint.py --unix_mode --strict --nojsdoc -r lib/ -r src/ -r test/ --exclude_files lib/punycode.js,test/fixtures/throws_error4.js,test/fixtures/uncaught-exceptions/parse-error-mod.js,test/message/throw_in_line_with_tabs.js
426426

427427
CPPLINT_EXCLUDE ?=
428428
CPPLINT_EXCLUDE += src/node_root_certs.h

test/addons/async-hello-world/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ var assert = require('assert');
22
var binding = require('./build/Release/binding');
33
var called = false;
44

5-
process.on('exit', function () {
5+
process.on('exit', function() {
66
assert(called);
77
});
88

9-
binding(5, function (err, val) {
9+
binding(5, function(err, val) {
1010
assert.equal(null, err);
1111
assert.equal(10, val);
12-
process.nextTick(function () {
12+
process.nextTick(function() {
1313
called = true;
1414
});
1515
});

test/addons/repl-domain-abort/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ process.on('exit', function() {
3434
var lines = [
3535
// This line shouldn't cause an assertion error.
3636
'require(\'' + buildPath + '\')' +
37-
// Log output to double check callback ran.
38-
'.method(function() { console.log(\'cb_ran\'); });',
37+
// Log output to double check callback ran.
38+
'.method(function() { console.log(\'cb_ran\'); });'
3939
];
4040

4141
var dInput = new stream.Readable();

test/common.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ if (!fs.existsSync(exports.opensslCli))
4848
if (process.platform === 'win32') {
4949
exports.faketimeCli = false;
5050
} else {
51-
exports.faketimeCli = path.join(__dirname, "..", "tools", "faketime", "src",
52-
"faketime");
51+
exports.faketimeCli = path.join(__dirname, '..', 'tools', 'faketime', 'src',
52+
'faketime');
5353
}
5454

5555
var ifaces = os.networkInterfaces();
@@ -175,8 +175,8 @@ function leakedGlobals() {
175175
if (-1 === knownGlobals.indexOf(global[val]))
176176
leaked.push(val);
177177

178-
return leaked;
179-
};
178+
return leaked;
179+
}
180180
exports.leakedGlobals = leakedGlobals;
181181

182182
// Turn this off if the test should not check for global leaks.
@@ -243,7 +243,7 @@ exports.checkSpawnSyncRet = function(ret) {
243243
var etcServicesFileName = path.join('/etc', 'services');
244244
if (process.platform === 'win32') {
245245
etcServicesFileName = path.join(process.env.SystemRoot, 'System32', 'drivers',
246-
'etc', 'services');
246+
'etc', 'services');
247247
}
248248

249249
/*
@@ -258,11 +258,11 @@ if (process.platform === 'win32') {
258258
*/
259259
exports.getServiceName = function getServiceName(port, protocol) {
260260
if (port == null) {
261-
throw new Error("Missing port number");
261+
throw new Error('Missing port number');
262262
}
263263

264264
if (typeof protocol !== 'string') {
265-
throw new Error("Protocol must be a string");
265+
throw new Error('Protocol must be a string');
266266
}
267267

268268
/*
@@ -273,36 +273,36 @@ exports.getServiceName = function getServiceName(port, protocol) {
273273

274274
try {
275275
/*
276-
* I'm not a big fan of readFileSync, but reading /etc/services asynchronously
277-
* here would require implementing a simple line parser, which seems overkill
278-
* for a simple utility function that is not running concurrently with any
279-
* other one.
276+
* I'm not a big fan of readFileSync, but reading /etc/services
277+
* asynchronously here would require implementing a simple
278+
* line parser, which seems overkill for a simple utility function
279+
* that is not running concurrently with any other one.
280280
*/
281281
var servicesContent = fs.readFileSync(etcServicesFileName,
282-
{ encoding: 'utf8'});
282+
{ encoding: 'utf8'});
283283
var regexp = util.format('^(\\w+)\\s+\\s%d/%s\\s', port, protocol);
284284
var re = new RegExp(regexp, 'm');
285285

286286
var matches = re.exec(servicesContent);
287287
if (matches && matches.length > 1) {
288288
serviceName = matches[1];
289289
}
290-
} catch(e) {
290+
} catch (e) {
291291
console.error('Cannot read file: ', etcServicesFileName);
292292
return undefined;
293293
}
294294

295295
return serviceName;
296-
}
296+
};
297297

298298
exports.isValidHostname = function(str) {
299299
// See http://stackoverflow.com/a/3824105
300300
var re = new RegExp(
301-
'^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])' +
302-
'(\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9]))*$');
301+
'^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])' +
302+
'(\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9]))*$');
303303

304304
return !!str.match(re) && str.length <= 255;
305-
}
305+
};
306306
exports.hasMultiLocalhost = function hasMultiLocalhost() {
307307
var TCP = process.binding('tcp_wrap').TCP;
308308
var t = new TCP();
@@ -328,4 +328,4 @@ exports.getNodeVersion = function getNodeVersion() {
328328
patch: patch,
329329
pre: pre
330330
};
331-
}
331+
};

test/debugger/test-debug-break-on-uncaught.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var scenarios;
4141
function addScenario(scriptName, throwsInFile, throwsOnLine) {
4242
if (!scenarios) scenarios = [];
4343
scenarios.push(
44-
runScenario.bind(null, scriptName, throwsInFile, throwsOnLine, run)
44+
runScenario.bind(null, scriptName, throwsInFile, throwsOnLine, run)
4545
);
4646
}
4747

@@ -56,16 +56,16 @@ function runScenario(scriptName, throwsInFile, throwsOnLine, next) {
5656
var port = common.PORT + 1337;
5757

5858
var testScript = path.join(
59-
common.fixturesDir,
60-
'uncaught-exceptions',
61-
scriptName
62-
);
59+
common.fixturesDir,
60+
'uncaught-exceptions',
61+
scriptName
62+
);
6363

64-
var child = spawn(process.execPath, [ '--debug-brk=' + port, testScript ]);
64+
var child = spawn(process.execPath, ['--debug-brk=' + port, testScript]);
6565
child.on('close', function() {
6666
assert(asserted, 'debugger did not pause on exception');
6767
if (next) next();
68-
})
68+
});
6969

7070
var exceptions = [];
7171

@@ -90,25 +90,25 @@ function runScenario(scriptName, throwsInFile, throwsOnLine, next) {
9090

9191
function runTest(client) {
9292
client.req(
93-
{
94-
command: 'setexceptionbreak',
95-
arguments: {
96-
type: 'uncaught',
97-
enabled: true
98-
}
99-
},
100-
function(error, result) {
101-
assert.ifError(error);
93+
{
94+
command: 'setexceptionbreak',
95+
arguments: {
96+
type: 'uncaught',
97+
enabled: true
98+
}
99+
},
100+
function(error, result) {
101+
assert.ifError(error);
102102

103-
client.on('exception', function(event) {
104-
exceptions.push(event.body);
105-
});
103+
client.on('exception', function(event) {
104+
exceptions.push(event.body);
105+
});
106106

107-
client.reqContinue(function(error, result) {
108-
assert.ifError(error);
109-
setTimeout(assertHasPaused.bind(null, client), 100);
110-
});
111-
}
107+
client.reqContinue(function(error, result) {
108+
assert.ifError(error);
109+
setTimeout(assertHasPaused.bind(null, client), 100);
110+
});
111+
}
112112
);
113113
}
114114

test/debugger/test-debugger-repl-break-in-module.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@ repl.addTest('sb(")^$*+?}{|][(.js\\\\", 1)', [
3939

4040
// continue - the breakpoint should be triggered
4141
repl.addTest('c', [
42-
/break in .*[\\\/]mod\.js:23/,
43-
/21/, /22/, /23/, /24/, /25/
42+
/break in .*[\\\/]mod\.js:23/,
43+
/21/, /22/, /23/, /24/, /25/
4444
]);
4545

4646
// -- RESTORE BREAKPOINT ON RESTART --
4747

4848
// Restart the application - breakpoint should be restored
4949
repl.addTest('restart', [].concat(
50-
[
51-
/terminated/
52-
],
53-
repl.handshakeLines,
54-
[
55-
/Restoring breakpoint mod.js:23/,
56-
/Warning: script 'mod\.js' was not loaded yet\./,
57-
/Restoring breakpoint \).*:\d+/,
58-
/Warning: script '\)[^']*' was not loaded yet\./
59-
],
60-
repl.initialBreakLines));
50+
[
51+
/terminated/
52+
],
53+
repl.handshakeLines,
54+
[
55+
/Restoring breakpoint mod.js:23/,
56+
/Warning: script 'mod\.js' was not loaded yet\./,
57+
/Restoring breakpoint \).*:\d+/,
58+
/Warning: script '\)[^']*' was not loaded yet\./
59+
],
60+
repl.initialBreakLines));
6161

6262
// continue - the breakpoint should be triggered
6363
repl.addTest('c', [

test/debugger/test-debugger-repl-restart.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ var repl = require('./helper-debugger-repl.js');
2323

2424
repl.startDebugger('breakpoints.js');
2525
var linesWithBreakpoint = [
26-
/1/, /2/, /3/, /4/, /5/, /\* 6/
26+
/1/, /2/, /3/, /4/, /5/, /\* 6/
2727
];
2828
// We slice here, because addTest will change the given array.
2929
repl.addTest('sb(6)', linesWithBreakpoint.slice());
3030

31-
var initialLines = repl.initialLines.slice()
31+
var initialLines = repl.initialLines.slice();
3232
initialLines.splice(2, 0, /Restoring/, /Warning/);
3333

3434
// Restart the debugged script
3535
repl.addTest('restart', [
36-
/terminated/,
36+
/terminated/
3737
].concat(initialLines));
3838

3939
repl.addTest('list(5)', linesWithBreakpoint);

test/debugger/test-debugger-repl-term.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ addTest('n', [
3838
addTest('', [
3939
/debug>/,
4040
/break in .*:5/,
41-
/3/, /4/, /5/, /6/, /7/,
41+
/3/, /4/, /5/, /6/, /7/
4242
]);
4343

4444
// continue
@@ -52,12 +52,12 @@ addTest('c', [
5252
addTest('', [
5353
/debug>/,
5454
/break in .*:5/,
55-
/3/, /4/, /5/, /6/, /7/,
55+
/3/, /4/, /5/, /6/, /7/
5656
]);
5757

5858
// should repeat continue
5959
addTest('', [
6060
/debug>/,
6161
/break in .*:23/,
62-
/21/, /22/, /23/, /24/, /25/,
62+
/21/, /22/, /23/, /24/, /25/
6363
]);

test/disabled/test-debug-brk-file.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function debug_client_connect() {
8383
// get breakpoint list and check if it exists on line 0
8484
if (!body.length) {
8585
var req = JSON.stringify({'seq': 1, 'type': 'request',
86-
'command': 'listbreakpoints'});
86+
'command': 'listbreakpoints'});
8787
conn.write('Content-Length: ' + req.length + '\r\n\r\n' + req);
8888
return;
8989
}
@@ -97,7 +97,7 @@ function debug_client_connect() {
9797
}
9898

9999
var req = JSON.stringify({'seq': 100, 'type': 'request',
100-
'command': 'disconnect'});
100+
'command': 'disconnect'});
101101
conn.write('Content-Length: ' + req.length + '\r\n\r\n' + req);
102102
} finally {
103103
msg = null;

test/disabled/test-readline.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var readlineFakeStream = function() {
6060
}
6161
});
6262
var _stdoutWrite = process.stdout.write;
63-
process.stdout.write = function (data) {
63+
process.stdout.write = function(data) {
6464
data.split('').forEach(rl.written_bytes.push.bind(rl.written_bytes));
6565
_stdoutWrite.apply(this, arguments);
6666
}
@@ -73,7 +73,7 @@ var written_bytes_length, refreshed;
7373

7474
rl.write('foo');
7575
assert.equal(3, rl.cursor);
76-
[key.xterm, key.rxvt, key.gnome, key.putty].forEach(function (key) {
76+
[key.xterm, key.rxvt, key.gnome, key.putty].forEach(function(key) {
7777
rl.write.apply(rl, key.home);
7878
assert.equal(0, rl.cursor);
7979
rl.write.apply(rl, key.end);
@@ -95,8 +95,8 @@ rl.write.apply(rl, key.xterm.home);
9595
{cursor: 8, key: key.xterm.metab},
9696
{cursor: 7, key: key.xterm.metab},
9797
{cursor: 4, key: key.xterm.metab},
98-
{cursor: 0, key: key.xterm.metab},
99-
].forEach(function (action) {
98+
{cursor: 0, key: key.xterm.metab}
99+
].forEach(function(action) {
100100
written_bytes_length = rl.written_bytes.length;
101101
rl.write.apply(rl, action.key);
102102
assert.equal(action.cursor, rl.cursor);
@@ -107,7 +107,8 @@ rl.write.apply(rl, key.xterm.home);
107107
rl = readlineFakeStream();
108108
rl.write('foo bar.hop/zoo');
109109
rl.write.apply(rl, key.xterm.home);
110-
['bar.hop/zoo', '.hop/zoo', 'hop/zoo', '/zoo', 'zoo', ''].forEach(function (expectedLine) {
110+
['bar.hop/zoo', '.hop/zoo', 'hop/zoo', '/zoo', 'zoo', ''
111+
].forEach(function(expectedLine) {
111112
rl.write.apply(rl, key.xterm.metad);
112113
assert.equal(0, rl.cursor);
113114
assert.equal(expectedLine, rl.line);

0 commit comments

Comments
 (0)