Permalink
Browse files

Update pre-commit hook, increase linting strictness

  • Loading branch information...
legastero committed May 2, 2014
1 parent 5a2e65b commit 654e99110cde6760247f9e01a696cc25fb40dbb6
Showing with 223 additions and 194 deletions.
  1. +17 −14 .jshintrc
  2. +1 −1 Gruntfile.js
  3. +1 −1 index.js
  4. +6 −10 lib/bosh.js
  5. +10 −6 lib/client.js
  6. +1 −1 lib/jid.js
  7. +1 −5 lib/old-websocket.js
  8. +2 −1 lib/plugins/attention.js
  9. +9 −4 lib/plugins/avatar.js
  10. +1 −1 lib/plugins/blocking.js
  11. +5 −3 lib/plugins/bookmarks.js
  12. +6 −3 lib/plugins/carbons.js
  13. +3 −2 lib/plugins/chatstates.js
  14. +3 −2 lib/plugins/command.js
  15. +2 −1 lib/plugins/correction.js
  16. +2 −1 lib/plugins/dataforms.js
  17. +3 −2 lib/plugins/delayed.js
  18. +7 −7 lib/plugins/disco.js
  19. +2 −2 lib/plugins/extdisco.js
  20. +2 −2 lib/plugins/forwarding.js
  21. +9 −4 lib/plugins/geoloc.js
  22. +1 −1 lib/plugins/hashes.js
  23. +1 −1 lib/plugins/idle.js
  24. +1 −1 lib/plugins/index-browser.js
  25. +1 −1 lib/plugins/index.js
  26. +1 −1 lib/plugins/invisible.js
  27. +4 −4 lib/plugins/jingle.js
  28. +3 −2 lib/plugins/json.js
  29. +1 −1 lib/plugins/keepalive.js
  30. +6 −3 lib/plugins/mam.js
  31. +11 −6 lib/plugins/muc.js
  32. +9 −4 lib/plugins/nick.js
  33. +3 −2 lib/plugins/oob.js
  34. +4 −3 lib/plugins/ping.js
  35. +2 −2 lib/plugins/private.js
  36. +2 −1 lib/plugins/psa.js
  37. +2 −2 lib/plugins/pubsub.js
  38. +12 −5 lib/plugins/reach.js
  39. +1 −1 lib/plugins/receipts.js
  40. +2 −2 lib/plugins/roster.js
  41. +2 −2 lib/plugins/time.js
  42. +3 −2 lib/plugins/vcard.js
  43. +1 −1 lib/plugins/version.js
  44. +3 −3 lib/sm.js
  45. +1 −1 lib/stanza/avatar.js
  46. +4 −3 lib/stanza/blocking.js
  47. +1 −1 lib/stanza/bosh.js
  48. +2 −2 lib/stanza/chatstates.js
  49. +4 −2 lib/stanza/command.js
  50. +1 −4 lib/stanza/dataforms.js
  51. +1 −2 lib/stanza/disco.js
  52. +1 −2 lib/stanza/error.js
  53. +1 −1 lib/stanza/framing.js
  54. +1 −1 lib/stanza/geoloc.js
  55. +1 −1 lib/stanza/hash.js
  56. +0 −2 lib/stanza/iceUdp.js
  57. +1 −1 lib/stanza/iq.js
  58. +1 −3 lib/stanza/jingle.js
  59. +1 −1 lib/stanza/json.js
  60. +1 −1 lib/stanza/mam.js
  61. +1 −2 lib/stanza/message.js
  62. +1 −1 lib/stanza/nick.js
  63. +1 −1 lib/stanza/oob.js
  64. +4 −3 lib/stanza/presence.js
  65. +1 −1 lib/stanza/psa.js
  66. +1 −2 lib/stanza/pubsub.js
  67. +1 −1 lib/stanza/reach.js
  68. +1 −2 lib/stanza/roster.js
  69. +1 −2 lib/stanza/rsm.js
  70. +7 −7 lib/stanza/rtp.js
  71. +1 −3 lib/stanza/sasl.js
  72. +0 −1 lib/stanza/sm.js
  73. +1 −1 lib/stanza/stream.js
  74. +1 −2 lib/stanza/streamError.js
  75. +2 −1 lib/stanza/streamFeatures.js
  76. +2 −2 lib/stanza/time.js
  77. +1 −1 lib/stanza/util.js
  78. +1 −1 lib/stanza/vcard.js
  79. +2 −6 lib/websocket.js
  80. +1 −1 package.json
  81. +1 −1 test/connection.js
View
@@ -1,16 +1,19 @@
{
"asi": false,
"expr": true,
"loopfunc": true,
"curly": false,
"evil": true,
"white": true,
"undef": true,
"browser": true,
"node": true,
"trailing": true,
"indent": 4,
"latedef": true,
"newcap": true,
"strict": true
"node": true,
"nonbsp": true,
"bitwise": true,
"camelcase": true,
"browser": true,
"curly": true,
"latedef": true,
"quotmark": true,
"undef": "strict",
"unused": true,
"trailing": true,
"indent": 4,
"noarg": true,
"newcap": true,
"immed": true,
"freeze": true,
"eqeqeq": true
}
View
@@ -1,4 +1,4 @@
"use strict";
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
View
@@ -1,4 +1,4 @@
"use strict";
'use strict';
exports.Stream = require('./lib/stanza/stream');
exports.BOSH = require('./lib/stanza/bosh');
View
@@ -1,18 +1,14 @@
"use strict";
'use strict';
var _ = require('underscore');
var util = require('util');
var async = require('async');
var Promise = require('bluebird');
var request = Promise.promisify(require('request'));
var WildEmitter = require('wildemitter');
var stanza = require('jxt');
var BOSH = require('./stanza/bosh');
var StreamError = require('./stanza/streamError');
var Message = require('./stanza/message');
var Presence = require('./stanza/presence');
var Iq = require('./stanza/iq');
function ConnectionError() {}
@@ -33,7 +29,7 @@ function retryRequest(opts, timeout, allowedRetries, retries) {
throw new ConnectionError('Dead Connection, exceeded timeout limit');
}).catch(Promise.CancellationError, function () {
return; // We only cancel on manual disconnect, so let things die silently
}).catch(function (err) {
}).catch(function () {
if (retries < allowedRetries) {
return Promise.delay(100).then(function () {
return retryRequest(opts, timeout, allowedRetries, retries + 1);
@@ -98,7 +94,7 @@ function BOSHConnection(sm) {
self.emit('stream:data', stanzaObj);
});
if (bosh.type == 'terminate') {
if (bosh.type === 'terminate') {
self.rid = undefined;
self.sid = undefined;
self.emit('bosh:terminate', bosh);
@@ -175,12 +171,12 @@ BOSHConnection.prototype.send = function (data) {
};
BOSHConnection.prototype.longPoll = function () {
var self = this;
var canReceive = this.requests.length === 0;
var canSend = this.sendQueue.length > 0 && this.requests.length < this.maxRequests;
if (!this.sid || (!canReceive && !canSend)) return;
if (!this.sid || (!canReceive && !canSend)) {
return;
}
var stanzas = this.sendQueue;
this.sendQueue = [];
View
@@ -1,4 +1,4 @@
"use strict";
'use strict';
var _ = require('underscore');
var WildEmitter = require('wildemitter');
@@ -275,7 +275,7 @@ function Client(opts) {
cb();
});
self.on('stream:management:failed', 'sm', function (failed) {
self.on('stream:management:failed', 'sm', function () {
self.sm.failed();
self.emit('session:end');
self.releaseGroup('session');
@@ -318,7 +318,7 @@ function Client(opts) {
if (iq.type === 'get' || iq.type === 'set') {
// Invalid request
if (xmlChildCount != 1) {
if (xmlChildCount !== 1) {
return self.sendIq(iq.errorReply({
error: {
type: 'modify',
@@ -392,7 +392,9 @@ Client.prototype.nextId = function () {
Client.prototype.discoverBindings = function (server, cb) {
getHostMeta(server, function (err, data) {
if (err) return cb(err, []);
if (err) {
return cb(err, []);
}
var results = {
websocket: [],
@@ -480,7 +482,7 @@ Client.prototype.connect = function (opts) {
for (var i = 0, len = (endpoints[transport] || []).length; i < len; i++) {
var uri = endpoints[transport][i];
if (uri.indexOf('wss://') === 0 || uri.indexOf('https://') === 0) {
if (transport == 'websocket') {
if (transport === 'websocket') {
self.config.wsURL = uri;
} else {
self.config.boshURL = uri;
@@ -567,7 +569,9 @@ Client.prototype.sendIq = function (data, cb) {
respEvent = 'id:' + data.id;
result = new Promise(function (resolve, reject) {
var handler = function (res) {
if (!allowed[res.from.full]) return;
if (!allowed[res.from.full]) {
return;
}
self.off(respEvent, handler);
if (!res.error) {
View
@@ -1,4 +1,4 @@
"use strict";
'use strict';
function JID(jid) {
jid = jid || '';
View
@@ -1,16 +1,12 @@
"use strict";
'use strict';
var WSConnection = require('./websocket');
var _ = require('underscore');
var util = require('util');
var stanza = require('jxt');
var Stream = require('./stanza/stream');
var StreamError = require('./stanza/streamError');
var Message = require('./stanza/message');
var Presence = require('./stanza/presence');
var Iq = require('./stanza/iq');
var WS_OPEN = 1;
function OldWSConnection(sm) {
View
@@ -1,4 +1,5 @@
"use strict";
'use strict';
module.exports = function (client) {
client.disco.addFeature('urn:xmpp:attention:0');
View
@@ -1,13 +1,18 @@
"use strict";
'use strict';
require('../stanza/avatar');
var stanzas = require('../stanza/avatar');
module.exports = function (client) {
client.disco.addFeature('urn:xmpp:avatar:metadata+notify');
client.on('pubsub:event', function (msg) {
if (!msg.event.updated) return;
if (msg.event.updated.node !== 'urn:xmpp:avatar:metadata') return;
if (!msg.event.updated) {
return;
}
if (msg.event.updated.node !== 'urn:xmpp:avatar:metadata') {
return;
}
client.emit('avatar', {
jid: msg.from,
View
@@ -1,4 +1,4 @@
"use strict";
'use strict';
require('../stanza/blocking');
View
@@ -1,9 +1,11 @@
"use strict";
'use strict';
require('../stanza/bookmarks');
var _ = require('underscore');
var stanzas = require('../stanza/bookmarks');
var JID = require('../jid');
module.exports = function (client) {
client.getBookmarks = function (cb) {
return this.getPrivateData({bookmarks: {}}, cb);
@@ -19,7 +21,7 @@ module.exports = function (client) {
return this.getBookmarks().then(function (res) {
var bookmarks = res.privateStorage.bookmarks.conferences || [];
var existing = _.filter(bookmarks, function (bm) {
return bm.jid.bare == bookmark.jid.bare;
return bm.jid.bare === bookmark.jid.bare;
});
if (existing.length) {
View
@@ -1,6 +1,7 @@
"use strict";
'use strict';
require('../stanza/carbons');
var stanzas = require('../stanza/carbons');
module.exports = function (client) {
client.disco.addFeature('urn:xmpp:carbons:2');
@@ -31,7 +32,9 @@ module.exports = function (client) {
client.on('carbon:*', function (name, carbon) {
var dir = name.split(':')[1];
if (carbon.from.bare !== client.jid.bare) return;
if (carbon.from.bare !== client.jid.bare) {
return;
}
var msg, delay;
if (dir === 'received') {
@@ -1,6 +1,7 @@
"use strict";
'use strict';
require('../stanza/chatstates');
var stanzas = require('../stanza/chatstates');
module.exports = function (client) {
client.disco.addFeature('http://jabber.org/protocol/chatstates');
View
@@ -1,7 +1,8 @@
"use strict";
'use strict';
require('../stanza/command');
var NS = 'http://jabber.org/protocol/commands';
var stanzas = require('../stanza/command');
module.exports = function (client) {
@@ -1,4 +1,5 @@
"use strict";
'use strict';
module.exports = function (client) {
client.disco.addFeature('urn:xmpp:message-correct:0');
View
@@ -1,7 +1,8 @@
"use strict";
'use strict';
require('../stanza/dataforms');
module.exports = function (client) {
client.disco.addFeature('jabber:x:data');
client.disco.addFeature('urn:xmpp:media-element');
View
@@ -1,6 +1,7 @@
"use strict";
'use strict';
require('../stanza/delayed');
var stanzas = require('../stanza/delayed');
module.exports = function (client) {
client.disco.addFeature('urn:xmpp:delay');
View
@@ -1,6 +1,6 @@
/*global unescape, escape */
"use strict";
'use strict';
var _ = require('underscore');
var crypto = require('crypto');
@@ -40,7 +40,7 @@ function generateVerString(info, hash) {
identities = _.unique(identities, true);
features = _.unique(features, true);
if (featureLen != features.length || idLen != identities.length) {
if (featureLen !== features.length || idLen !== identities.length) {
return false;
}
@@ -53,7 +53,7 @@ function generateVerString(info, hash) {
_.forEach(info.extensions, function (ext) {
var fields = ext.fields;
for (var i = 0, len = fields.length; i < len; i++) {
if (fields[i].name == 'FORM_TYPE' && fields[i].type == 'hidden') {
if (fields[i].name === 'FORM_TYPE' && fields[i].type === 'hidden') {
var name = fields[i].value;
if (formTypes[name]) {
illFormed = true;
@@ -80,9 +80,9 @@ function generateVerString(info, hash) {
_.forEach(ext.fields, function (field) {
var fieldName = field.name;
if (fieldName != 'FORM_TYPE') {
if (fieldName !== 'FORM_TYPE') {
var values = field.value || '';
if (typeof values != 'object') {
if (typeof values !== 'object') {
values = values.split('\n');
}
fields[fieldName] = values.sort();
@@ -121,11 +121,11 @@ function verifyVerString(info, hash, check) {
hash = 'sha1';
}
var computed = generateVerString(info, hash);
return computed && computed == check;
return computed && computed === check;
}
function Disco(client) {
function Disco() {
this.features = {};
this.identities = {};
this.extensions = {};
View
@@ -1,6 +1,6 @@
"use strict";
'use strict';
var stanzas = require('../stanza/extdisco');
require('../stanza/extdisco');
module.exports = function (client) {
@@ -1,6 +1,6 @@
"use strict";
'use strict';
var stanzas = require('../stanza/forwarded');
require('../stanza/forwarded');
module.exports = function (client) {
Oops, something went wrong.

0 comments on commit 654e991

Please sign in to comment.