From 3d4e4d89099f1c08e586060961ed884e5f52301a Mon Sep 17 00:00:00 2001 From: Joshaven Potter Date: Wed, 6 Oct 2010 23:05:23 -0400 Subject: [PATCH] syntax fixes to pass jslint --- lib/assert.js | 4 +-- lib/child_process.js | 2 +- lib/crypto.js | 21 ++++++------ lib/dns.js | 18 +++++------ lib/events.js | 2 +- lib/freelist.js | 2 +- lib/fs.js | 4 +-- lib/http.js | 22 ++++++------- lib/net.js | 32 +++++++++---------- lib/path.js | 4 +-- lib/readline.js | 4 +-- lib/repl.js | 4 +-- lib/sys.js | 6 ++-- lib/url.js | 2 +- src/node.js | 10 +++--- test/disabled/test-dns.js | 2 +- test/disabled/test-eio-race3.js | 2 +- test/disabled/test-fs-sendfile.js | 2 +- .../disabled/test-http-big-proxy-responses.js | 8 ++--- test/disabled/test-http-head-request.js | 2 +- test/disabled/test-http-stress.js | 4 +-- test/disabled/test-idle-watcher.js | 2 +- test/disabled/test-process-title.js | 2 +- test/disabled/test-remote-module-loading.js | 2 +- test/disabled/test-setuidgid.js | 2 +- test/disabled/tls_client.js | 2 +- test/disabled/tls_server.js | 2 +- test/fixtures/echo.js | 2 +- 28 files changed, 85 insertions(+), 86 deletions(-) diff --git a/lib/assert.js b/lib/assert.js index 19cb376c7e..6d1ffcd670 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -59,7 +59,7 @@ assert.AssertionError.prototype.toString = function() { , JSON.stringify(this.actual) ].join(" "); } -} +}; // assert.AssertionError instanceof Error @@ -279,7 +279,7 @@ function _throws (shouldThrow, block, err, message) { (!shouldThrow && threw)) { throw exception; } -} +}; // 11. Expected to throw an error: // assert.throws(block, Error_opt, message_opt); diff --git a/lib/child_process.js b/lib/child_process.js index 200ed93525..af59905966 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -88,7 +88,7 @@ exports.execFile = function (file /* args, options, callback */) { stderr += chunk; if (!killed && stderr.length > options.maxBuffer) { child.kill(options.killSignal); - killed = true + killed = true; } }); diff --git a/lib/crypto.js b/lib/crypto.js index 4a0db0ecb0..206a201408 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -3579,8 +3579,7 @@ var RootCaCerts = [ +"I2bw/FWAp/tmGYI1Z2JwOV5vx+qQQEQIHriy1tvuWacNGHk0vFQYXlPKNFHtRQrmjseCNj6nOGOp\n" +"MCwXEGCSn1WHElkQwg9naRHMTh5+Spqtr0CodaxWkHS4oJyleW/c6RrIaQXpuvoDs3zk4E7Czp3o\n" +"tkYNbn5XOmeUwssfnHdKZ05phkOTOPu220+DkdRgfks+KzgHVZhepA==\n" -+"-----END CERTIFICATE-----\n", - ++"-----END CERTIFICATE-----\n" ]; var sys = require("sys"); @@ -3630,45 +3629,45 @@ exports.createCredentials = function(cred) { } } return c; -} +}; exports.Credentials = Credentials; exports.Hash = Hash; exports.createHash = function(hash) { return new Hash(hash); -} +}; exports.Hmac = Hmac; exports.createHmac = function(hmac, key) { return (new Hmac).init(hmac, key); -} +}; exports.Cipher = Cipher; exports.createCipher = function(cipher, key) { return (new Cipher).init(cipher, key); -} +}; exports.createCipheriv = function(cipher, key, iv) { return (new Cipher).initiv(cipher, key, iv); -} +}; exports.Decipher = Decipher; exports.createDecipher = function(cipher, key) { return (new Decipher).init(cipher, key); -} +}; exports.createDecipheriv = function(cipher, key, iv) { return (new Decipher).initiv(cipher, key, iv); -} +}; exports.Sign = Sign; exports.createSign = function(algorithm) { return (new Sign).init(algorithm); -} +}; exports.Verify = Verify; exports.createVerify = function(algorithm) { return (new Verify).init(algorithm); -} +}; exports.RootCaCerts = RootCaCerts; diff --git a/lib/dns.js b/lib/dns.js index 50c2898498..f0f25b4c53 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -13,13 +13,13 @@ timer.callback = function () { var sockets = Object.keys(activeWatchers); for (var i = 0, l = sockets.length; i < l; i++) { var socket = sockets[i]; - var s = parseInt(socket); + var s = parseInt(socket, 10); channel.processFD( watchers[socket].read ? s : dns.SOCKET_BAD , watchers[socket].write ? s : dns.SOCKET_BAD ); } updateTimer(); -} +}; function updateTimer() { @@ -30,7 +30,7 @@ function updateTimer() { var max = 20000; var timeout = channel.timeout(max); timer.start(timeout, 0); -} +}; var channel = new dns.Channel({SOCK_STATE_CB: function (socket, read, write) { @@ -50,8 +50,8 @@ var channel = new dns.Channel({SOCK_STATE_CB: function (socket, read, write) { , write ? socket : dns.SOCKET_BAD ); updateTimer(); - } - } + }; + }; watcher.set(socket, read == 1, write == 1); @@ -84,7 +84,7 @@ exports.resolve = function (domain, type_, callback_) { } else { throw new Error('Unknown type "' + type + '"'); } -} +}; function familyToSym(family) { @@ -92,7 +92,7 @@ function familyToSym(family) { family = (family === 6) ? dns.AF_INET6 : dns.AF_INET; } return family; -} +}; exports.getHostByName = function (domain, family/*=4*/, callback) { @@ -114,7 +114,7 @@ exports.lookup = function (domain, family, callback) { callback = family; family = undefined; } else if (family && family !== 4 && family !== 6) { - family = parseInt(family); + family = parseInt(family, 10); if (family === dns.AF_INET) { family = 4; } else if (family === dns.AF_INET6) { @@ -203,7 +203,7 @@ var resolveMap = { 'TXT' : exports.resolveTxt, 'SRV' : exports.resolveSrv, 'PTR' : exports.resolvePtr, - 'NS' : exports.resolveNs, + 'NS' : exports.resolveNs }; // ERROR CODES diff --git a/lib/events.js b/lib/events.js index ea8f7aa628..d0f641b26c 100644 --- a/lib/events.js +++ b/lib/events.js @@ -117,5 +117,5 @@ exports.Promise = function removed () { throw new Error( 'Promise has been removed. See '+ 'http://groups.google.com/group/nodejs/msg/0c483b891c56fea2 for more information.'); -} +}; process.Promise = exports.Promise; diff --git a/lib/freelist.js b/lib/freelist.js index a09fb4b21e..67da85a791 100644 --- a/lib/freelist.js +++ b/lib/freelist.js @@ -4,7 +4,7 @@ exports.FreeList = function(name, max, constructor) { this.constructor = constructor; this.max = max; this.list = []; -} +}; exports.FreeList.prototype.alloc = function () { diff --git a/lib/fs.js b/lib/fs.js index b5d1ae0aec..c1d5891ee6 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -111,7 +111,7 @@ fs.readFileSync = function (path, encoding) { if (!i._bytesRead) return; i.copy(buffer,offset,0,i._bytesRead); offset += i._bytesRead; - }) + }); } else if (buffers.length) { //buffers has exactly 1 (possibly zero length) buffer, so this should be a shortcut buffer = buffers[0].slice(0, buffers[0]._bytesRead); @@ -943,7 +943,7 @@ WriteStream.prototype.close = function (cb) { sys.error(writeStreamCloseWarning); } return this.end(cb); -} +}; WriteStream.prototype.end = function (cb) { diff --git a/lib/http.js b/lib/http.js index dc7901b41b..b56854ad83 100755 --- a/lib/http.js +++ b/lib/http.js @@ -235,9 +235,9 @@ IncomingMessage.prototype.resume = function () { IncomingMessage.prototype._addHeaderLine = function (field, value) { var dest; if (this.complete) { - dest = this.trailers + dest = this.trailers; } else { - dest = this.headers + dest = this.headers; } switch (field) { // Array headers: @@ -317,8 +317,8 @@ OutgoingMessage.prototype._send = function (data, encoding) { } this._headerSent = true; } - this._writeRaw(data, encoding) -} + this._writeRaw(data, encoding); +}; OutgoingMessage.prototype._writeRaw = function(data, encoding) { if (this.connection._outgoing[0] === this && this.connection.writable) { @@ -606,7 +606,7 @@ exports.ServerResponse = ServerResponse; ServerResponse.prototype.writeContinue = function () { this._writeRaw("HTTP/1.1 100 Continue" + CRLF + CRLF, 'ascii'); this._sent100 = true; -} +}; ServerResponse.prototype.writeHead = function (statusCode) { var reasonPhrase, headers, headerIndex; @@ -769,7 +769,7 @@ sys.inherits(Server, net.Server); Server.prototype.setSecure = function (credentials) { this.secure = true; this.credentials = credentials; -} +}; exports.Server = Server; @@ -875,7 +875,7 @@ function connectionListener (socket) { && continueExpression.test(req.headers['expect'])) { res._expect_continue = true; if (self.listeners("checkContinue").length) { - self.emit("checkContinue", req, res) + self.emit("checkContinue", req, res); } else { res.writeContinue(); self.emit('request', req, res); @@ -905,7 +905,7 @@ function Client ( ) { } else if (self.parser.incoming && self.parser.incoming.upgrade) { var bytesParsed = ret; self.ondata = null; - self.onend = null + self.onend = null; var req = self.parser.incoming; @@ -1008,9 +1008,9 @@ Client.prototype._initParser = function () { // All that should be required for keep-alive is to not reconnect, // but outgoingFlush instead. if (req.shouldKeepAlive) { - outgoingFlush(self) - self._outgoing.shift() - outgoingFlush(self) + outgoingFlush(self); + self._outgoing.shift(); + outgoingFlush(self); } else { self.end(); } diff --git a/lib/net.js b/lib/net.js index 307af68173..af6fc31b2c 100644 --- a/lib/net.js +++ b/lib/net.js @@ -91,7 +91,7 @@ var timeout = new (function () { remove(socket); socket._idleNext = list._idleNext; socket._idleNext._idlePrev = socket; - socket._idlePrev = list + socket._idlePrev = list; list._idleNext = socket; } @@ -200,7 +200,7 @@ var timeout = new (function () { socket._idlePrev._idleNext = socket._idleNext; socket._idleNext = list._idleNext; socket._idleNext._idlePrev = socket; - socket._idlePrev = list + socket._idlePrev = list; list._idleNext = socket; } } @@ -313,7 +313,7 @@ function setImplmentationMethods (self) { } self._shutdownImpl = function () { - shutdown(self.fd, 'write') + shutdown(self.fd, 'write'); }; if (self.secure) { @@ -525,7 +525,7 @@ function Stream (fd, type) { this.type = null; this.secure = false; - if (parseInt(fd) >= 0) { + if (parseInt(fd, 10) >= 0) { this.open(fd, type); } else { setImplmentationMethods(this); @@ -567,7 +567,7 @@ Stream.prototype.setSecure = function (credentials) { // If client, trigger handshake this._checkForSecureHandshake(); } -} +}; Stream.prototype.verifyPeer = function () { @@ -575,7 +575,7 @@ Stream.prototype.verifyPeer = function () { throw new Error('Stream is not a secure stream.'); } return this.secureStream.verifyPeer(this.credentials.context); -} +}; Stream.prototype._checkForSecureHandshake = function () { @@ -586,7 +586,7 @@ Stream.prototype._checkForSecureHandshake = function () { // Do an empty write to see if we need to write out as part of handshake if (!emptyBuffer) allocEmptyBuffer(); this.write(emptyBuffer); -} +}; Stream.prototype.getPeerCertificate = function (credentials) { @@ -594,7 +594,7 @@ Stream.prototype.getPeerCertificate = function (credentials) { throw new Error('Stream is not a secure stream.'); } return this.secureStream.getPeerCertificate(); -} +}; Stream.prototype.getCipher = function () { @@ -602,7 +602,7 @@ Stream.prototype.getCipher = function () { throw new Error('Stream is not a secure stream.'); } return this.secureStream.getCurrentCipher(); -} +}; Stream.prototype.open = function (fd, type) { @@ -616,7 +616,7 @@ Stream.prototype.open = function (fd, type) { this._writeWatcher.set(this.fd, false, true); this.writable = true; -} +}; exports.createConnection = function (port, host) { @@ -703,7 +703,7 @@ Stream.prototype._writeOut = function (data, encoding, fd) { len = data.length; } else { - assert(typeof data == 'string') + assert(typeof data == 'string'); if (!pool || pool.length - pool.used < kMinPoolSpace) { pool = null; @@ -788,7 +788,7 @@ Stream.prototype._writeOut = function (data, encoding, fd) { } return false; -} +}; // Flushes the write buffer out. @@ -869,7 +869,7 @@ function doConnect (socket, port, host) { }; } -function toPort (x) { return (x = Number(x)) >= 0 ? x : false } +function toPort (x) { return (x = Number(x)) >= 0 ? x : false; } // var stream = new Stream(); @@ -886,7 +886,7 @@ Stream.prototype.connect = function () { self._connecting = true; // set false in doConnect - var port = toPort(arguments[0]) + var port = toPort(arguments[0]); if (port === false) { // UNIX self.fd = socket('unix'); @@ -1102,7 +1102,7 @@ Server.prototype.listen = function () { self.addListener('listening', lastArg); } - var port = toPort(arguments[0]) + var port = toPort(arguments[0]); if (port === false) { // the first argument specifies a path self.fd = socket('unix'); @@ -1176,7 +1176,7 @@ Server.prototype._startWatcher = function () { Server.prototype._doListen = function () { listen(this.fd, 128); this._startWatcher(); -} +}; diff --git a/lib/path.js b/lib/path.js index 6238625680..d0b3788b79 100644 --- a/lib/path.js +++ b/lib/path.js @@ -27,7 +27,7 @@ exports.normalizeArray = function (parts, keepBlanks) { && (prev !== "" || keepBlanks) ) { directories.pop(); - prev = directories.slice(-1)[0] + prev = directories.slice(-1)[0]; } else { if (prev === ".") directories.pop(); directories.push(directory); @@ -84,7 +84,7 @@ exports.exists = function (path, callback) { exports.existsSync = function (path) { try { - process.binding('fs').stat(path) + process.binding('fs').stat(path); return true; } catch(e){ return false; diff --git a/lib/readline.js b/lib/readline.js index 26c04cca40..d3b63e7d7c 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -28,7 +28,7 @@ function Interface (output, completer) { this.enabled = output.fd < 3; // Looks like a TTY. - if (parseInt(process.env['NODE_NO_READLINE'])) { + if (parseInt(process.env['NODE_NO_READLINE'], 10)) { this.enabled = false; } @@ -211,7 +211,7 @@ Interface.prototype._tabComplete = function () { // If there is a common prefix to all matches, then apply that // portion. var prefix = commonPrefix( - completions.filter(function(e) { if (e) return e })); + completions.filter(function(e) { if (e) return e; })); if (prefix.length > completeOn.length) { self._insertString(prefix.slice(completeOn.length)); } diff --git a/lib/repl.js b/lib/repl.js index ca4e3d7a2f..5e6de2f720 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -58,7 +58,7 @@ function REPLServer(prompt, stream) { // Turn on ANSI coloring. exports.writer = function(obj, showHidden, depth) { return sys.inspect(obj, showHidden, depth, true); - } + }; } rli.setPrompt(self.prompt); @@ -306,7 +306,7 @@ REPLServer.prototype.complete = function (line) { "false", "finally", "for", "function", "if", "import", "in", "instanceof", "let", "new", "null", "return", "switch", "this", "throw", "true", "try", "typeof", "undefined", "var", "void", - "while", "with", "yield"]) + "while", "with", "yield"]); } } else { try { diff --git a/lib/sys.js b/lib/sys.js index ca97a88495..e8985d25fa 100644 --- a/lib/sys.js +++ b/lib/sys.js @@ -315,7 +315,7 @@ exports.log = function (msg) { var execWarning; exports.exec = function () { if (!execWarning) { - execWarning = 'sys.exec has moved to the "child_process" module. Please update your source code.' + execWarning = 'sys.exec has moved to the "child_process" module. Please update your source code.'; error(execWarning); } return require('child_process').exec.apply(this, arguments); @@ -332,8 +332,8 @@ exports.pump = function (readStream, writeStream, callback) { } } - if (!readStream.pause) readStream.pause = function () {readStream.emit("pause")}; - if (!readStream.resume) readStream.resume = function () {readStream.emit("resume")}; + if (!readStream.pause) readStream.pause = function () {readStream.emit("pause");}; + if (!readStream.resume) readStream.resume = function () {readStream.emit("resume");}; readStream.addListener("data", function (chunk) { if (writeStream.write(chunk) === false) readStream.pause(); diff --git a/lib/url.js b/lib/url.js index 45dea833b2..2a9a5cfd70 100644 --- a/lib/url.js +++ b/lib/url.js @@ -284,7 +284,7 @@ function urlResolveObject (source, relative) { mustEndAbs = mustEndAbs || (source.host && srcPath.length); - if (mustEndAbs && srcPath[0] !== "") srcPath.unshift("") + if (mustEndAbs && srcPath[0] !== "") srcPath.unshift(""); source.pathname = srcPath.join("/"); diff --git a/src/node.js b/src/node.js index 1ad5576bc9..6d53ea3425 100644 --- a/src/node.js +++ b/src/node.js @@ -10,8 +10,8 @@ global.root = global; function removed (reason) { return function () { - throw new Error(reason) - } + throw new Error(reason); + }; } process.debug = removed("process.debug() has moved. Use require('sys') to bring it back."); @@ -156,7 +156,7 @@ var module = (function () { function index (ext) { return path.join(dir, id, 'index' + ext); } inDir = [ function () { return exts.map(direct); }, - function () { return exts.map(index); }, + function () { return exts.map(index); } ]; head = [path.join(dir, id)]; return next(); @@ -335,7 +335,7 @@ var module = (function () { // Load the main module--the command line argument. process.mainModule = new Module("."); process.mainModule.load(process.argv[1]); - } + }; return exports; })(); @@ -551,7 +551,7 @@ global.console.assert = function(expression){ var arr = Array.prototype.slice.call(arguments, 1); process.assert(false, format.apply(this, arr)); } -} +}; global.Buffer = module.requireNative('buffer').Buffer; diff --git a/test/disabled/test-dns.js b/test/disabled/test-dns.js index e5f2d7092e..e9cd0e6ee8 100644 --- a/test/disabled/test-dns.js +++ b/test/disabled/test-dns.js @@ -1,5 +1,5 @@ common = require("../common"); -assert = common.assert +assert = common.assert; var dns = require("dns"), child_process = require("child_process"), diff --git a/test/disabled/test-eio-race3.js b/test/disabled/test-eio-race3.js index 7dc239fb1a..458c3dacd4 100644 --- a/test/disabled/test-eio-race3.js +++ b/test/disabled/test-eio-race3.js @@ -1,7 +1,7 @@ /* XXX Can this test be modified to not call the now-removed wait()? */ common = require("../common"); -assert = common.assert +assert = common.assert; console.log('first stat ...'); diff --git a/test/disabled/test-fs-sendfile.js b/test/disabled/test-fs-sendfile.js index e70463ad23..b442841fde 100644 --- a/test/disabled/test-fs-sendfile.js +++ b/test/disabled/test-fs-sendfile.js @@ -1,5 +1,5 @@ common = require("../common"); -assert = common.assert +assert = common.assert; tcp = require("tcp"); sys = require("sys"); diff --git a/test/disabled/test-http-big-proxy-responses.js b/test/disabled/test-http-big-proxy-responses.js index 7026d56db5..b1ccc7e79c 100644 --- a/test/disabled/test-http-big-proxy-responses.js +++ b/test/disabled/test-http-big-proxy-responses.js @@ -1,5 +1,5 @@ common = require("../common"); -assert = common.assert +assert = common.assert; var sys = require("sys"), fs = require("fs"), http = require("http"), @@ -9,7 +9,7 @@ var chunk = '01234567890123456789'; // Produce a very large response. var chargen = http.createServer(function (req, res) { - var len = parseInt(req.headers['x-len']); + var len = parseInt(req.headers['x-len'], 10); assert.ok(len > 0); res.writeHead(200, {"transfer-encoding":"chunked"}); for (var i=0; i 0); var sent = 0; diff --git a/test/disabled/test-http-head-request.js b/test/disabled/test-http-head-request.js index c6e9084fbc..da288be16c 100644 --- a/test/disabled/test-http-head-request.js +++ b/test/disabled/test-http-head-request.js @@ -1,5 +1,5 @@ common = require("../common"); -assert = common.assert +assert = common.assert; var assert = require("assert"); var http = require("http"); diff --git a/test/disabled/test-http-stress.js b/test/disabled/test-http-stress.js index 42f244f616..d8778d8a9b 100644 --- a/test/disabled/test-http-stress.js +++ b/test/disabled/test-http-stress.js @@ -1,5 +1,5 @@ common = require("../common"); -assert = common.assert +assert = common.assert; http = require("http"); @@ -23,7 +23,7 @@ server.addListener('listening', function () { if (err) { common.print("-"); } else { - assert.equal(body, content) + assert.equal(body, content); common.print("."); requests_ok++; } diff --git a/test/disabled/test-idle-watcher.js b/test/disabled/test-idle-watcher.js index cc66621719..274d27acbd 100644 --- a/test/disabled/test-idle-watcher.js +++ b/test/disabled/test-idle-watcher.js @@ -1,5 +1,5 @@ common = require("../common"); -assert = common.assert +assert = common.assert; var complete = false; var idle = new process.IdleWatcher(); diff --git a/test/disabled/test-process-title.js b/test/disabled/test-process-title.js index d0223d9a1c..d09bd60d1d 100644 --- a/test/disabled/test-process-title.js +++ b/test/disabled/test-process-title.js @@ -4,7 +4,7 @@ var spawn = require('child_process').spawn; if (process.title === '') { console.log('skipping test -- not implemented for the host platform'); - return; + //return; } // disabled because of two things diff --git a/test/disabled/test-remote-module-loading.js b/test/disabled/test-remote-module-loading.js index 36f3d9831a..c0842dccbf 100644 --- a/test/disabled/test-remote-module-loading.js +++ b/test/disabled/test-remote-module-loading.js @@ -1,5 +1,5 @@ common = require("../common"); -assert = common.assert +assert = common.assert; var http = require('http'); var sys = require('sys'); diff --git a/test/disabled/test-setuidgid.js b/test/disabled/test-setuidgid.js index 76fb2b2295..1f505cd8f0 100644 --- a/test/disabled/test-setuidgid.js +++ b/test/disabled/test-setuidgid.js @@ -1,6 +1,6 @@ // Requires special privlages common = require("../common"); -assert = common.assert +assert = common.assert; var assert = require('assert'); var oldgid = process.getgid(); diff --git a/test/disabled/tls_client.js b/test/disabled/tls_client.js index 6859675f00..17e77696bd 100644 --- a/test/disabled/tls_client.js +++ b/test/disabled/tls_client.js @@ -1,5 +1,5 @@ common = require("../common"); -assert = common.assert +assert = common.assert; var sys=require('sys'); var net=require('net'); var fs=require('fs'); diff --git a/test/disabled/tls_server.js b/test/disabled/tls_server.js index 9a3f6f8199..892be69b53 100644 --- a/test/disabled/tls_server.js +++ b/test/disabled/tls_server.js @@ -1,5 +1,5 @@ common = require("../common"); -assert = common.assert +assert = common.assert; var sys=require('sys'); var net=require('net'); diff --git a/test/fixtures/echo.js b/test/fixtures/echo.js index 9274f8cf7e..f206b515c7 100644 --- a/test/fixtures/echo.js +++ b/test/fixtures/echo.js @@ -1,5 +1,5 @@ common = require("../common"); -assert = common.assert +assert = common.assert; common.print("hello world\r\n");