diff --git a/babel.config.cjs b/babel.config.cjs index 12861b7e..170c70d9 100644 --- a/babel.config.cjs +++ b/babel.config.cjs @@ -26,21 +26,7 @@ module.exports = function config(api) { } return { - presets: [ - [ - "@babel/preset-env", - { - targets: { - ie: "10", - }, - loose: true, - }, - ], - ], - plugins: [ - "@babel/plugin-transform-runtime", - "babel-plugin-transform-async-to-promises", - "@babel/plugin-proposal-object-rest-spread", - ], + presets: [["@babel/preset-env"]], + plugins: ["@babel/plugin-transform-runtime"], }; }; diff --git a/eslint.config.js b/eslint.config.js index dff1ff48..88a10dee 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -33,16 +33,17 @@ export default [ rules: { strict: ["error", "global"], "no-empty": ["error", { allowEmptyCatch: true }], - // "no-multi-assign": 0, + // "no-multi-assign": "off", "func-names": ["error", "as-needed"], "operator-linebreak": [ "error", "after", { overrides: { "?": "before", ":": "before" } }, ], - "capitalized-comments": 0, + "capitalized-comments": "off", "prefer-rest-params": ["error"], "prefer-spread": ["error"], + "prefer-object-spread": ["error"], "prefer-destructuring": [ "error", { @@ -55,30 +56,26 @@ export default [ // node // https://github.com/eslint-community/eslint-plugin-n/ - "n/no-unpublished-require": 0, // doesn't play nice with monorepo + "n/no-unpublished-require": "off", // doesn't play nice with monorepo "n/no-extraneous-require": ["error", { allowModules: ["@xmpp/test"] }], "n/no-extraneous-import": ["error", { allowModules: ["@xmpp/test"] }], "n/hashbang": "off", // promise // https://github.com/xjamundx/eslint-plugin-promise - // promise/prefer-await-to-then: [error] - // promise/prefer-await-to-callbacks: [error] - // unicorn https://github.com/sindresorhus/eslint-plugin-unicorn + "promise/prefer-await-to-then": "off", + "promise/prefer-await-to-callbacks": "off", // unicorn // https://github.com/sindresorhus/eslint-plugin-unicorn - "unicorn/filename-case": 0, + "unicorn/filename-case": "off", "unicorn/catch-error-name": ["error", { name: "err" }], - "unicorn/prevent-abbreviations": 0, - "unicorn/prefer-number-properties": 0, - "unicorn/no-useless-undefined": 0, - "unicorn/no-null": 0, - "unicorn/prefer-module": 0, - "unicorn/numeric-separators-style": 0, // Requires Node.js 12.8 - "unicorn/prefer-event-target": 0, - "unicorn/prefer-top-level-await": 0, - "unicorn/prefer-node-protocol": 0, + "unicorn/prevent-abbreviations": "off", + "unicorn/no-useless-undefined": "off", + "unicorn/no-null": "off", + "unicorn/prefer-event-target": "off", + // "unicorn/prefer-top-level-await": "off", + "unicorn/prefer-node-protocol": "off", "unicorn/prefer-export-from": "off", }, }, @@ -107,7 +104,7 @@ export default [ // { // alwaysAwait: true, // // For jest-extended expect().pass - // minArgs: 0, + // minArgs: "off", // }, // ], "promise/no-callback-in-promise": "off", diff --git a/package-lock.json b/package-lock.json index ae8cc837..6ed97b14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ ], "devDependencies": { "@babel/core": "^7.26.0", - "@babel/plugin-proposal-object-rest-spread": "^7.16.5", "@babel/plugin-transform-modules-commonjs": "^7.26.3", "@babel/plugin-transform-react-jsx": "^7.25.9", "@babel/plugin-transform-runtime": "^7.25.9", @@ -17,7 +16,6 @@ "@babel/runtime": "^7.26.0", "babel-jest": "^29.7.0", "babel-plugin-jsx-pragmatic": "^1.0.2", - "babel-plugin-transform-async-to-promises": "^0.8.18", "babelify": "^10.0.0", "babylon": "^6.18.0", "browser-pack-flat": "^3.5.0", @@ -491,24 +489,6 @@ "@babel/core": "^7.0.0" } }, - "node_modules/@babel/plugin-proposal-object-rest-spread": { - "version": "7.16.5", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/compat-data": "^7.16.4", - "@babel/helper-compilation-targets": "^7.16.3", - "@babel/helper-plugin-utils": "^7.16.5", - "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-transform-parameters": "^7.16.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, "node_modules/@babel/plugin-proposal-private-property-in-object": { "version": "7.21.0-placeholder-for-preset-env.2", "dev": true, @@ -4656,11 +4636,6 @@ "dev": true, "license": "MIT" }, - "node_modules/babel-plugin-transform-async-to-promises": { - "version": "0.8.18", - "dev": true, - "license": "MIT" - }, "node_modules/babel-preset-current-node-syntax": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.1.0.tgz", diff --git a/package.json b/package.json index b6cf6b30..e04c3cf7 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,6 @@ "type": "module", "devDependencies": { "@babel/core": "^7.26.0", - "@babel/plugin-proposal-object-rest-spread": "^7.16.5", "@babel/plugin-transform-modules-commonjs": "^7.26.3", "@babel/plugin-transform-react-jsx": "^7.25.9", "@babel/plugin-transform-runtime": "^7.25.9", @@ -11,7 +10,6 @@ "@babel/runtime": "^7.26.0", "babel-jest": "^29.7.0", "babel-plugin-jsx-pragmatic": "^1.0.2", - "babel-plugin-transform-async-to-promises": "^0.8.18", "babelify": "^10.0.0", "babylon": "^6.18.0", "browser-pack-flat": "^3.5.0", @@ -49,11 +47,12 @@ "bundlesize": [ { "path": "./packages/client/dist/xmpp.min.js", - "maxSize": "17 KB" + "maxSize": "15 KB" } ], "lint-staged": { "*.{js,cjs,mjs}": "eslint --cache --fix", "*.{json,md,html,css,yaml,yml}": "prettier --write" - } + }, + "browserslist": "defaults" } diff --git a/packages/client/example.js b/packages/client/example.js index 59abc50d..7effe6cf 100644 --- a/packages/client/example.js +++ b/packages/client/example.js @@ -47,4 +47,4 @@ xmpp.on("online", async (address) => { await xmpp.send(message); }); -xmpp.start().catch(console.error); +await xmpp.start(); diff --git a/packages/component/example.js b/packages/component/example.js index d29293c7..ce5847b5 100644 --- a/packages/component/example.js +++ b/packages/component/example.js @@ -36,4 +36,4 @@ xmpp.on("online", async (address) => { await xmpp.send(message); }); -xmpp.start().catch(console.error); +await xmpp.start(); diff --git a/packages/id/test.js b/packages/id/test.js index 8bd67b4d..314ef058 100644 --- a/packages/id/test.js +++ b/packages/id/test.js @@ -7,7 +7,7 @@ test("returns a non empty string", () => { test("duplicates", () => { const id = xid(); - for (let i = 0; i < 10000; i++) { + for (let i = 0; i < 10_000; i++) { expect(id).not.toBe(xid()); } }); diff --git a/packages/jid/lib/JID.js b/packages/jid/lib/JID.js index 54d2e859..490a1419 100644 --- a/packages/jid/lib/JID.js +++ b/packages/jid/lib/JID.js @@ -21,7 +21,7 @@ class JID { [Symbol.toPrimitive](hint) { if (hint === "number") { - return NaN; + return Number.NaN; } return this.toString(); diff --git a/packages/jid/test/toPrimitive.js b/packages/jid/test/toPrimitive.js index 90664eb2..9990aac6 100644 --- a/packages/jid/test/toPrimitive.js +++ b/packages/jid/test/toPrimitive.js @@ -9,6 +9,5 @@ test("cocerce to string", () => { test("cocerce to NaN", () => { const addr = new JID("foo", "bar"); - expect(isNaN(+addr)).toBe(true); - expect(isNaN(addr + 4)).toBe(true); + expect(Number.isNaN(+addr)).toBe(true); }); diff --git a/packages/resolve/example.js b/packages/resolve/example.js index c5b6efa3..21d2d30c 100644 --- a/packages/resolve/example.js +++ b/packages/resolve/example.js @@ -1,3 +1,4 @@ import { resolve } from "@xmpp/resolve"; -resolve("jabberfr.org").then(console.log).catch(console.error); +const result = await resolve("jabberfr.org"); +console.log(result); diff --git a/packages/tls/lib/Connection.js b/packages/tls/lib/Connection.js index c1fa7d23..40cb0053 100644 --- a/packages/tls/lib/Connection.js +++ b/packages/tls/lib/Connection.js @@ -1,4 +1,4 @@ -import { parseURI } from "@xmpp/connection/lib/util"; +import { parseURI } from "@xmpp/connection/lib/util.js"; import ConnectionTCP from "@xmpp/connection-tcp"; import Socket from "./Socket.js"; diff --git a/packages/xml/README.md b/packages/xml/README.md index 30597fe7..fa4d8a7f 100644 --- a/packages/xml/README.md +++ b/packages/xml/README.md @@ -145,7 +145,6 @@ The `attrs` property is an object that holds xml attributes of the element. ```js message.attrs.type = "chat"; -Object.assign(message.attrs, { type: "chat" }); ``` ### text diff --git a/packages/xmpp.js/test.js b/packages/xmpp.js/test.js index bb0cdb89..667a91ff 100644 --- a/packages/xmpp.js/test.js +++ b/packages/xmpp.js/test.js @@ -1,3 +1,4 @@ +/* eslint-disable unicorn/prefer-module */ import fs from "fs"; import path from "path"; diff --git a/server/ctl.js b/server/ctl.js index 37b0a12d..44cb5a9f 100755 --- a/server/ctl.js +++ b/server/ctl.js @@ -25,7 +25,7 @@ const commands = { }; if (commands[method]) { - commands[method]().catch(console.error); + await commands[method](); } else { console.error("Valid commands are start/stop/restart/status."); }