Permalink
Browse files

Replace babel+eslint with Typescript+TSLint

  • Loading branch information...
legastero committed Nov 28, 2018
1 parent afb1baf commit 4139667e0c20bd8cd85c06d2b9c84c095afa98ec
Showing with 1,377 additions and 1,271 deletions.
  1. +8 −51 package.json
  2. +19 −19 src/client.js
  3. +9 −9 src/plugins/avatar.js
  4. +2 −2 src/plugins/bind.js
  5. +4 −4 src/plugins/blocking.js
  6. +3 −3 src/plugins/bob.js
  7. +6 −5 src/plugins/carbons.js
  8. +4 −4 src/plugins/chatstates.js
  9. +39 −39 src/plugins/disco.js
  10. +6 −6 src/plugins/extdisco.js
  11. +4 −4 src/plugins/features.js
  12. +2 −2 src/plugins/geoloc.js
  13. +5 −8 src/plugins/hostmeta.js
  14. +2 −2 src/plugins/invisible.js
  15. +2 −2 src/plugins/jidprep.js
  16. +7 −2 src/plugins/jingle.js
  17. +2 −2 src/plugins/logging.js
  18. +12 −12 src/plugins/mam.js
  19. +6 −6 src/plugins/markers.js
  20. +2 −2 src/plugins/mood.js
  21. +41 −41 src/plugins/muc.js
  22. +2 −2 src/plugins/ping.js
  23. +4 −4 src/plugins/private.js
  24. +57 −57 src/plugins/pubsub.js
  25. +4 −4 src/plugins/push.js
  26. +4 −4 src/plugins/reach.js
  27. +5 −5 src/plugins/receipts.js
  28. +7 −7 src/plugins/register.js
  29. +6 −6 src/plugins/roster.js
  30. +2 −2 src/plugins/session.js
  31. +4 −4 src/plugins/time.js
  32. +2 −2 src/protocol/shortcuts.js
  33. +7 −7 src/protocol/stanzas/addresses.js
  34. +8 −8 src/protocol/stanzas/avatar.js
  35. +5 −5 src/protocol/stanzas/bind.js
  36. +9 −9 src/protocol/stanzas/blocking.js
  37. +5 −5 src/protocol/stanzas/bob.js
  38. +6 −6 src/protocol/stanzas/bookmarks.js
  39. +27 −24 src/protocol/stanzas/bosh.js
  40. +13 −13 src/protocol/stanzas/carbons.js
  41. +17 −11 src/protocol/stanzas/command.js
  42. +6 −6 src/protocol/stanzas/csi.js
  43. +62 −56 src/protocol/stanzas/dataforms.js
  44. +5 −5 src/protocol/stanzas/delayed.js
  45. +24 −24 src/protocol/stanzas/disco.js
  46. +3 −3 src/protocol/stanzas/eme.js
  47. +14 −14 src/protocol/stanzas/error.js
  48. +10 −10 src/protocol/stanzas/extdisco.js
  49. +33 −26 src/protocol/stanzas/file.js
  50. +21 −19 src/protocol/stanzas/file3.js
  51. +2 −2 src/protocol/stanzas/forwarded.js
  52. +11 −11 src/protocol/stanzas/framing.js
  53. +4 −4 src/protocol/stanzas/geoloc.js
  54. +3 −3 src/protocol/stanzas/hash.js
  55. +5 −5 src/protocol/stanzas/hats.js
  56. +2 −2 src/protocol/stanzas/hints.js
  57. +16 −14 src/protocol/stanzas/ibb.js
  58. +24 −21 src/protocol/stanzas/iceUdp.js
  59. +6 −6 src/protocol/stanzas/iq.js
  60. +32 −26 src/protocol/stanzas/jingle.js
  61. +14 −14 src/protocol/stanzas/logging.js
  62. +25 −17 src/protocol/stanzas/mam.js
  63. +14 −14 src/protocol/stanzas/message.js
  64. +3 −3 src/protocol/stanzas/mood.js
  65. +75 −68 src/protocol/stanzas/muc.js
  66. +20 −20 src/protocol/stanzas/omemo.js
  67. +10 −10 src/protocol/stanzas/oob.js
  68. +2 −2 src/protocol/stanzas/ping.js
  69. +35 −32 src/protocol/stanzas/presence.js
  70. +2 −2 src/protocol/stanzas/private.js
  71. +5 −5 src/protocol/stanzas/psa.js
  72. +56 −54 src/protocol/stanzas/pubsub.js
  73. +28 −25 src/protocol/stanzas/pubsubEvents.js
  74. +30 −26 src/protocol/stanzas/pubsubOwner.js
  75. +7 −7 src/protocol/stanzas/push.js
  76. +5 −5 src/protocol/stanzas/reach.js
  77. +6 −6 src/protocol/stanzas/references.js
  78. +18 −18 src/protocol/stanzas/register.js
  79. +9 −9 src/protocol/stanzas/roster.js
  80. +3 −3 src/protocol/stanzas/rsm.js
  81. +63 −51 src/protocol/stanzas/rtp.js
  82. +9 −9 src/protocol/stanzas/rtt.js
  83. +38 −38 src/protocol/stanzas/sasl.js
  84. +5 −5 src/protocol/stanzas/session.js
  85. +31 −31 src/protocol/stanzas/sm.js
  86. +6 −6 src/protocol/stanzas/stream.js
  87. +10 −10 src/protocol/stanzas/streamError.js
  88. +5 −5 src/protocol/stanzas/streamFeatures.js
  89. +5 −5 src/protocol/stanzas/time.js
  90. +3 −3 src/protocol/stanzas/tune.js
  91. +40 −40 src/protocol/stanzas/vcard.js
  92. +5 −5 src/protocol/stanzas/version.js
  93. +12 −12 src/protocol/stanzas/xrd.js
  94. +2 −1 src/protocol/types.js
  95. +3 −1 src/sasl/anonymous.js
  96. +1 −1 src/sasl/digest-md5.js
  97. +3 −1 src/sasl/external.js
  98. +1 −1 src/sasl/index.js
  99. +3 −1 src/sasl/plain.js
  100. +5 −2 src/sasl/scram-sha-1.js
  101. +3 −1 src/sasl/x-oauth2.js
  102. +5 −5 src/sm.js
  103. +22 −21 src/transports/bosh.js
  104. +3 −1 src/transports/old-websocket.js
  105. +5 −4 src/transports/websocket.js
  106. +15 −0 tsconfig.json
  107. +42 −0 tslint.json
  108. +3 −4 webpack.config.js
@@ -3,14 +3,6 @@
"description": "Modern XMPP in the browser, with a JSON API",
"version": "9.3.0",
"author": "Lance Stout <lancestout@gmail.com>",
"babel": {
"presets": [
"@babel/preset-env"
],
"plugins": [
"@babel/plugin-transform-runtime"
]
},
"browser": {
"request": "xhr",
"faye-websocket": false
@@ -21,7 +13,6 @@
"Steven Lloyd Watkin <lloyd@evilprofessor.co.uk>"
],
"dependencies": {
"@babel/runtime": "^7.1.2",
"async": "^2.5.0",
"create-hash": "^1.2.0",
"create-hmac": "^1.1.7",
@@ -31,19 +22,13 @@
"jxt": "^3.1.0",
"randombytes": "^2.0.6",
"request": "^2.53.0",
"tslib": "^1.9.3",
"uuid": "^3.0.1",
"wildemitter": "^1.0.1",
"xhr": "^2.0.1",
"xmpp-jid": "^1.0.0"
},
"devDependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/node": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"babel-loader": "^8.0.4",
"eslint": "^5.8.0",
"husky": "^1.1.3",
"prettier": "^1.14.3",
"pretty-quick": "^1.8.0",
@@ -52,42 +37,14 @@
"string-replace-loader": "^2.1.1",
"tap-spec": "^5.0.0",
"tape": "^4.8.0",
"ts-loader": "^5.3.0",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"typescript": "^3.1.6",
"webpack": "^4.25.0",
"webpack-bundle-analyzer": "^3.0.3",
"webpack-cli": "^3.1.2"
},
"eslintConfig": {
"extends": "eslint:recommended",
"env": {
"browser": true,
"node": true,
"es6": true
},
"rules": {
"indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"prefer-const": "error",
"no-console": 0,
"no-var": "error",
"semi": [
"error",
"always"
]
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": "2018"
}
},
"eslintIgnore": [
"build/*",
"lib/*"
],
"homepage": "https://stanza.io",
"husky": {
"hooks": {
@@ -117,10 +74,10 @@
},
"scripts": {
"build": "webpack --mode production",
"compile": "rimraf lib && babel --optional runtime -sd lib/ src/",
"lint": "eslint .",
"compile": "rimraf lib && tsc -p .",
"lint": "tslint -p .",
"prepare": "npm run compile",
"test": "babel-node test/index.js | tap-spec",
"test": "ts-node test/index.js | tap-spec",
"validate": "npm ls"
}
}
@@ -15,12 +15,12 @@ import Bind from './plugins/bind';
import Session from './plugins/session';
const SASL_MECHS = {
external: SASL.External,
'scram-sha-1': SASL.ScramSha1,
anonymous: SASL.Anonymous,
'digest-md5': SASL.DigestMD5,
'x-oauth2': SASL.XOauth2,
external: SASL.External,
plain: SASL.Plain,
anonymous: SASL.Anonymous
'scram-sha-1': SASL.ScramSha1,
'x-oauth2': SASL.XOauth2
};
function timeoutRequest(targetPromise, id, delay) {
@@ -30,11 +30,11 @@ function timeoutRequest(targetPromise, id, delay) {
new Promise(function(resolve, reject) {
timeoutRef = setTimeout(function() {
reject({
id: id,
type: 'error',
error: {
condition: 'timeout'
}
},
id: id,
type: 'error'
});
}, delay);
})
@@ -129,8 +129,8 @@ export default class Client extends WildEmitter {
return this.sendIq(
iq.errorReply({
error: {
type: 'modify',
condition: 'bad-request'
condition: 'bad-request',
type: 'modify'
}
})
);
@@ -141,8 +141,8 @@ export default class Client extends WildEmitter {
return this.sendIq(
iq.errorReply({
error: {
type: 'cancel',
condition: 'service-unavailable'
condition: 'service-unavailable',
type: 'cancel'
}
})
);
@@ -156,8 +156,8 @@ export default class Client extends WildEmitter {
this.sendIq(
iq.errorReply({
error: {
type: 'cancel',
condition: 'service-unavailable'
condition: 'service-unavailable',
type: 'cancel'
}
})
);
@@ -194,9 +194,9 @@ export default class Client extends WildEmitter {
_initConfig(opts) {
const currConfig = this.config || {};
this.config = {
useStreamManagement: true,
transports: ['websocket', 'bosh'],
sasl: ['external', 'scram-sha-1', 'digest-md5', 'plain', 'anonymous'],
transports: ['websocket', 'bosh'],
useStreamManagement: true,
...currConfig,
...opts
};
@@ -253,13 +253,13 @@ export default class Client extends WildEmitter {
const username = creds.username || requestedJID.local;
const server = creds.server || requestedJID.domain;
return {
username: username,
password: this.config.password,
server: server,
host: server,
password: this.config.password,
realm: server,
serviceType: 'xmpp',
server: server,
serviceName: server,
serviceType: 'xmpp',
username: username,
...creds
};
}
@@ -12,22 +12,22 @@ export default function(client) {
}
client.emit('avatar', {
avatars: msg.event.updated.published[0].avatars,
jid: msg.from,
source: 'pubsub',
avatars: msg.event.updated.published[0].avatars
source: 'pubsub'
});
});
client.on('presence', function(pres) {
if (pres.avatarId) {
client.emit('avatar', {
jid: pres.from,
source: 'vcard',
avatars: [
{
id: pres.avatarId
}
]
],
jid: pres.from,
source: 'vcard'
});
}
});
@@ -37,8 +37,8 @@ export default function(client) {
'',
Namespaces.AVATAR_DATA,
{
id: id,
avatarData: data
avatarData: data,
id: id
},
cb
);
@@ -49,8 +49,8 @@ export default function(client) {
'',
Namespaces.AVATAR_METADATA,
{
id: 'current',
avatars: info
avatars: info,
id: 'current'
},
cb
);
@@ -4,10 +4,10 @@ export default function(client, stanzas, config) {
client.registerFeature('bind', 300, function(features, cb) {
client.sendIq(
{
type: 'set',
bind: {
resource: config.resource
}
},
type: 'set'
},
function(err, resp) {
if (err) {
@@ -6,10 +6,10 @@ export default function(client) {
client.block = function(jid, cb) {
return client.sendIq(
{
type: 'set',
block: {
jids: [jid]
}
},
type: 'set'
},
cb
);
@@ -30,8 +30,8 @@ export default function(client) {
client.getBlocked = function(cb) {
return client.sendIq(
{
type: 'get',
blockList: true
blockList: true,
type: 'get'
},
cb
);
@@ -6,11 +6,11 @@ export default function(client) {
client.getBits = function(jid, cid, cb) {
return client.sendIq(
{
to: jid,
type: 'get',
bob: {
cid: cid
}
},
to: jid,
type: 'get'
},
cb
);
@@ -6,8 +6,8 @@ export default function(client) {
client.enableCarbons = function(cb) {
return this.sendIq(
{
type: 'set',
enableCarbons: true
enableCarbons: true,
type: 'set'
},
cb
);
@@ -16,8 +16,8 @@ export default function(client) {
client.disableCarbons = function(cb) {
return this.sendIq(
{
type: 'set',
disableCarbons: true
disableCarbons: true,
type: 'set'
},
cb
);
@@ -39,7 +39,8 @@ export default function(client) {
return;
}
let msg, delay;
let msg;
let delay;
if (dir === 'received') {
msg = carbon.carbonReceived.forwarded.message;
delay = carbon.carbonReceived.forwarded.delay;
@@ -12,14 +12,14 @@ export default function(client) {
if (msg.chatState) {
client.emit('chat:state', {
to: msg.to,
chatState: msg.chatState,
from: msg.from,
chatState: msg.chatState
to: msg.to
});
client.emit('chatState', {
to: msg.to,
chatState: msg.chatState,
from: msg.from,
chatState: msg.chatState
to: msg.to
});
}
});
Oops, something went wrong.

0 comments on commit 4139667

Please sign in to comment.