Skip to content

Commit

Permalink
update dependencies (#891)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp authored Mar 14, 2021
1 parent 42f9072 commit 3128387
Show file tree
Hide file tree
Showing 20 changed files with 2,914 additions and 2,653 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module.exports = {
"eslint:recommended",
"plugin:unicorn/recommended",
"plugin:node/recommended",
"plugin:prettier/recommended",
"plugin:promise/recommended",
"plugin:prettier/recommended",
],

env: {
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ server/prosody-modules/
npm-debug.log
lerna-debug.log
yarn-error.log

.eslintcache
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ setup:
node bundle.js

lint:
./node_modules/.bin/eslint .
./node_modules/.bin/eslint --cache .

test:
cd packages/xmpp.js/ && yarn run prepublish
Expand Down
54 changes: 33 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,41 @@
"private": true,
"devDependencies": {
"@ava/babel": "^1.0.1",
"@babel/core": "^7.12.10",
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
"@babel/plugin-transform-react-jsx": "^7.12.11",
"@babel/plugin-transform-runtime": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/runtime": "^7.12.5",
"ava": "^3.14.0",
"@babel/core": "^7.13.10",
"@babel/plugin-proposal-object-rest-spread": "^7.13.8",
"@babel/plugin-transform-react-jsx": "^7.12.17",
"@babel/plugin-transform-runtime": "^7.13.10",
"@babel/preset-env": "^7.13.10",
"@babel/runtime": "^7.13.10",
"ava": "^3.15.0",
"babel-plugin-jsx-pragmatic": "^1.0.2",
"babel-plugin-transform-async-to-promises": "^0.8.15",
"babelify": "^10.0.0",
"babylon": "^6.18.0",
"browser-pack-flat": "^3.4.2",
"browserify": "^17.0.0",
"bundlesize": "^0.18.0",
"bundlesize": "^0.18.1",
"common-shakeify": "^0.6.2",
"eslint": "^7.16.0",
"eslint-config-prettier": "^7.1.0",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-unicorn": "^24.0.0",
"exorcist": "^1.0.1",
"jsdom": "^16.4.0",
"lerna": "^3.22.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-unicorn": "^28.0.2",
"exorcist": "^2.0.0",
"husky": "4",
"jsdom": "^16.5.1",
"lerna": "^4.0.0",
"lint-staged": "^10.5.4",
"node-fetch": "^2.6.1",
"prettier": "^2.2.1",
"sinon": "^9.2.2",
"uglify-js": "^3.12.2"
"sinon": "^9.2.4",
"uglify-js": "^3.13.1"
},
"scripts": {
"bootstrap": "lerna bootstrap",
"test": "ava",
"lint": "eslint .",
"lint": "eslint --cache .",
"preversion": "make bundle"
},
"engines": {
Expand All @@ -47,7 +49,17 @@
"bundlesize": [
{
"path": "./packages/client/dist/xmpp.min.js",
"maxSize": "15 KB"
"maxSize": "16 KB"
}
]
],
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"pre-push": "make test"
}
},
"lint-staged": {
"*.{js,cjs,mjs}": "eslint --cache --fix",
"*.{json,md,html,css,yaml,yml}": "prettier --write"
}
}
8 changes: 4 additions & 4 deletions packages/connection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ class Connection extends EventEmitter {

_detachSocket() {
const { socketListeners, socket } = this;
Object.getOwnPropertyNames(socketListeners).forEach((k) => {
for (const k of Object.getOwnPropertyNames(socketListeners)) {
socket.removeListener(k, socketListeners[k]);
delete socketListeners[k];
});
}
this.socket = null;
return socket;
}
Expand Down Expand Up @@ -168,10 +168,10 @@ class Connection extends EventEmitter {

_detachParser() {
const listeners = this.parserListeners;
Object.getOwnPropertyNames(listeners).forEach((k) => {
for (const k of Object.getOwnPropertyNames(listeners)) {
this.parser.removeListener(k, listeners[k]);
delete listeners[k];
});
}
this.parser = null;
}

Expand Down
6 changes: 4 additions & 2 deletions packages/iq/caller.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ class IQCaller {
}

_childRequest(type, element, to, ...args) {
const { name } = element;
const { xmlns } = element.attrs;
const {
name,
attrs: { xmlns },
} = element;
return this.request(
xml("iq", { type, to }, element),
...args,
Expand Down
3 changes: 1 addition & 2 deletions packages/jid/lib/JID.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class JID {
return this;
}

getLocal(unescape) {
unescape = unescape || false;
getLocal(unescape = false) {
let local = null;

local = unescape ? escaping.unescape(this._local) : this._local;
Expand Down
2 changes: 1 addition & 1 deletion packages/resolve/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async function fallbackConnect(entity, uris) {
module.exports = function resolve({ entity }) {
const _connect = entity.connect;
entity.connect = async function connect(service) {
if (!service || service.match(/:\/\//)) {
if (!service || /:\/\//.test(service)) {
return _connect.call(this, service);
}

Expand Down
13 changes: 7 additions & 6 deletions packages/resolve/lib/dns.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable promise/no-nesting */
"use strict";

const dns = require("dns");
Expand All @@ -15,7 +16,7 @@ function lookup(domain, options = {}) {
}

const result = [];
addresses.forEach(({ family, address }) => {
for (const { family, address } of addresses) {
const uri = `://${family === 4 ? address : "[" + address + "]"}:`;
result.push(
{
Expand All @@ -29,7 +30,7 @@ function lookup(domain, options = {}) {
uri: "xmpp" + uri + "5222",
},
);
});
}
resolve(result);
});
});
Expand Down Expand Up @@ -100,7 +101,7 @@ function lookupSrvs(srvs, options) {
return Promise.all(
srvs.map(async (srv) => {
const srvAddresses = await lookup(srv.name, options);
srvAddresses.forEach((address) => {
for (const address of srvAddresses) {
const { port, service } = srv;
const addr = address.address;
addresses.push({
Expand All @@ -110,7 +111,7 @@ function lookupSrvs(srvs, options) {
address.family === 6 ? "[" + addr + "]" : addr
}:${port}`,
});
});
}
}),
).then(() => addresses);
}
Expand Down Expand Up @@ -170,10 +171,10 @@ function resolve(domain, options = {}) {
});
}),
)
.then((srvs) => sortSrv([].concat(...srvs)).concat(addresses))
.then((srvs) => [...sortSrv(srvs.flat()), ...addresses])
.then((records) => {
return resolveTxt(domain, options).then((txtRecords) => {
return records.concat(txtRecords);
return [...records, ...txtRecords];
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/resolve/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function resolve(...args) {
return Promise.all([
dns.resolve ? dns.resolve(...args) : Promise.resolve([]),
http.resolve(...args),
]).then(([records, endpoints]) => records.concat(endpoints));
]).then(([records, endpoints]) => [...records, ...endpoints]);
};

if (dns.resolve) {
Expand Down
4 changes: 2 additions & 2 deletions packages/starttls/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ async function negotiate(entity) {

module.exports = function starttls({ streamFeatures }) {
return streamFeatures.use("starttls", NS, async ({ entity }, next) => {
const { socket } = entity;
const { socket, options } = entity;
if (!canUpgrade(socket)) {
return next();
}

await negotiate(entity);
const tlsSocket = await upgrade(socket, { host: entity.options.domain });
const tlsSocket = await upgrade(socket, { host: options.domain });
entity._attachSocket(tlsSocket);

await entity.restart();
Expand Down
4 changes: 2 additions & 2 deletions packages/starttls/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function mockSocket() {
test("success", async (t) => {
const { entity } = mockClient();
entity.socket = mockSocket();
const { socket } = entity;
entity.options.domain = "foobar";
const { socket, options } = entity;
options.domain = "foobar";

const mockTLS = mock(tls);
const expectTLSConnect = mockTLS
Expand Down
22 changes: 12 additions & 10 deletions packages/stream-features/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ const { xml } = require("@xmpp/test");

test.skip("selectFeature", (t) => {
const features = [];
features.push({
priority: 1000,
run: () => {},
match: (el) => el.getChild("bind"),
});
features.push({
priority: 2000,
run: () => {},
match: (el) => el.getChild("bind"),
});
features.push(
{
priority: 1000,
run: () => {},
match: (el) => el.getChild("bind"),
},
{
priority: 2000,
run: () => {},
match: (el) => el.getChild("bind"),
},
);

const feature = streamfeatures.selectFeature(
features,
Expand Down
2 changes: 1 addition & 1 deletion packages/websocket/lib/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ConnectionWebSocket extends Connection {
}

socketParameters(service) {
return service.match(/^wss?:\/\//) ? service : undefined;
return /^wss?:\/\//.test(service) ? service : undefined;
}
}

Expand Down
9 changes: 5 additions & 4 deletions packages/websocket/lib/Socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ class Socket extends EventEmitter {

listeners.message = ({ data }) => this.emit("data", data);
listeners.error = (event) => {
const { url } = this;
// WS
let { error } = event;
// DOM
if (!error) {
error = new Error(`WebSocket ${CODE} ${this.url}`);
error = new Error(`WebSocket ${CODE} ${url}`);
error.errno = CODE;
error.code = CODE;
}

error.event = event;
error.url = this.url;
error.url = url;
this.emit("error", error);
};

Expand All @@ -54,10 +55,10 @@ class Socket extends EventEmitter {
_detachSocket() {
delete this.url;
const { socket, listeners } = this;
Object.getOwnPropertyNames(listeners).forEach((k) => {
for (const k of Object.getOwnPropertyNames(listeners)) {
socket.removeEventListener(k, listeners[k]);
delete listeners[k];
});
}
delete this.socket;
}

Expand Down
14 changes: 7 additions & 7 deletions packages/xml/lib/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@ class Element extends _Element {
if (typeof attrs === "string") {
this.attrs.xmlns = attrs;
} else if (attrs) {
Object.keys(attrs).forEach((key) => {
for (const key of Object.keys(attrs)) {
// https://github.com/facebook/react/pull/4596
// https://www.npmjs.com/package/babel-plugin-transform-react-jsx-source
if (key === "__source" || key === "__self") return;
if (key === "__source" || key === "__self") continue;
const val = attrs[key];
if (val !== undefined && val !== null)
this.attrs[key.toString()] = val.toString();
}, this);
}
}
}

append(nodes) {
nodes = Array.isArray(nodes) ? nodes : [nodes];
nodes.forEach((node) => {
for (const node of nodes) {
this.children.push(node);
if (typeof node === "object") {
node.parent = this;
}
});
}
return this;
}

prepend(nodes) {
nodes = Array.isArray(nodes) ? nodes : [nodes];
nodes.forEach((node) => {
for (const node of nodes) {
this.children.unshift(node);
if (typeof node === "object") {
node.parent = this;
}
});
}
return this;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/xml/lib/x.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function append(el, child) {
if (child instanceof Element) {
el.append(child);
} else if (Array.isArray(child)) {
child.forEach((c) => append(el, c));
for (const c of child) append(el, c);
} else {
el.append(String(child));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/xmpp.js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const packages = fs
// For some reason there's a "*" file on travis
.filter((p) => !["*"].includes(p) && !p.includes("."))
.map((name) => require(path.join(__dirname, "..", name, "package.json")))
// eslint-disable-next-line unicorn/no-reduce
// eslint-disable-next-line unicorn/no-array-reduce
.reduce((dict, pkg) => {
dict[pkg.name] = `^${pkg.version}`;
return dict;
Expand Down
1 change: 1 addition & 0 deletions test/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test.beforeEach((t) => {
const scriptEl = document.createElement("script");
scriptEl.textContent = xmppjs;
document.body.append(scriptEl);
// eslint-disable-next-line unicorn/consistent-destructuring
t.context = window.XMPP.client;
return server.restart();
});
Expand Down
Loading

0 comments on commit 3128387

Please sign in to comment.