diff --git a/.eslintrc.js b/.eslintrc.js index 4661de637cb..ed4f0cc694f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,9 +6,13 @@ module.exports = { project: "./tsconfig.json", }, extends: [ - "plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin - "prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier - "plugin:prettier/recommended", // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. + // Use the recommended rules from the @typescript-eslint/eslint-plugin + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier + "prettier/@typescript-eslint", + // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. + "plugin:prettier/recommended", ], plugins: [], rules: { @@ -30,24 +34,55 @@ module.exports = { argsIgnorePattern: "^_", }, ], - "@typescript-eslint/explicit-function-return-type": [ - "warn", - { - allowExpressions: true, - allowTypedFunctionExpressions: true, - }, - ], + // "@typescript-eslint/explicit-function-return-type": [ + // "warn", + // { + // allowExpressions: true, + // allowTypedFunctionExpressions: true, + // }, + // ], "@typescript-eslint/no-object-literal-type-assertion": "off", "@typescript-eslint/interface-name-prefix": "off", "@typescript-eslint/no-non-null-assertion": "off", // This is necessary for Map.has()/get()! "@typescript-eslint/no-inferrable-types": [ "error", { - "ignoreProperties": true, - "ignoreParameters": true - } + ignoreProperties: true, + ignoreParameters: true, + }, + ], + "@typescript-eslint/ban-ts-comment": [ + "error", + { + "ts-expect-error": false, + "ts-ignore": true, + "ts-nocheck": true, + "ts-check": false, + }, + ], + "@typescript-eslint/restrict-template-expressions": [ + "error", + { + allowNumber: true, + allowBoolean: true, + // This is necessary to log errors + // TODO: Consider switching to false when we may annotate catch clauses + allowAny: true, + allowNullish: true, + }, ], - "@typescript-eslint/ban-ts-ignore": "warn", + "@typescript-eslint/no-misused-promises": [ + "error", + { + checksVoidReturn: false, + }, + ], + // We can turn this on from time to time but in general these rules + // make our lives harder instead of easier + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-return": "off", + "@typescript-eslint/no-unsafe-call": "off", }, overrides: [ { @@ -55,14 +90,22 @@ module.exports = { rules: { "@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/ban-ts-ignore": "off", + "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-member-return": "off", + "@typescript-eslint/no-unsafe-return": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/require-await": "off", + "@typescript-eslint/unbound-method": "warn", }, }, { files: ["*.js"], rules: { - "@typescript-eslint/*": "off" - } - } + "@typescript-eslint/*": "off", + }, + }, ], }; diff --git a/package-lock.json b/package-lock.json index dcfbd1b656e..c862a28674b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5463,23 +5463,18 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "2.30.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.30.0.tgz", - "integrity": "sha512-PGejii0qIZ9Q40RB2jIHyUpRWs1GJuHP1pkoCiaeicfwO9z7Fx03NQzupuyzAmv+q9/gFNHu7lo1ByMXe8PNyg==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.0.2.tgz", + "integrity": "sha512-ER3bSS/A/pKQT/hjMGCK8UQzlL0yLjuCZ/G8CDFJFVTfl3X65fvq2lNYqOG8JPTfrPa2RULCdwfOyFjZEMNExQ==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "2.30.0", + "@typescript-eslint/experimental-utils": "3.0.2", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", + "semver": "^7.3.2", "tsutils": "^3.17.1" }, "dependencies": { - "regexpp": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", - "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", - "dev": true - }, "tsutils": { "version": "3.17.1", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", @@ -5492,44 +5487,33 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "2.30.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.30.0.tgz", - "integrity": "sha512-L3/tS9t+hAHksy8xuorhOzhdefN0ERPDWmR9CclsIGOUqGKy6tqc/P+SoXeJRye5gazkuPO0cK9MQRnolykzkA==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.0.2.tgz", + "integrity": "sha512-4Wc4EczvoY183SSEnKgqAfkj1eLtRgBQ04AAeG+m4RhTVyaazxc1uI8IHf0qLmu7xXe9j1nn+UoDJjbmGmuqXQ==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.30.0", + "@typescript-eslint/typescript-estree": "3.0.2", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" - }, - "dependencies": { - "eslint-utils": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.0.0.tgz", - "integrity": "sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^1.1.0" - } - } } }, "@typescript-eslint/parser": { - "version": "2.30.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.30.0.tgz", - "integrity": "sha512-9kDOxzp0K85UnpmPJqUzdWaCNorYYgk1yZmf4IKzpeTlSAclnFsrLjfwD9mQExctLoLoGAUXq1co+fbr+3HeFw==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.0.2.tgz", + "integrity": "sha512-80Z7s83e8QXHNUspqVlWwb4t5gdz/1bBBmafElbK1wwAwiD/yvJsFyHRxlEpNrt4rdK6eB3p+2WEFkEDHAKk9w==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.30.0", - "@typescript-eslint/typescript-estree": "2.30.0", + "@typescript-eslint/experimental-utils": "3.0.2", + "@typescript-eslint/typescript-estree": "3.0.2", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/typescript-estree": { - "version": "2.30.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.30.0.tgz", - "integrity": "sha512-nI5WOechrA0qAhnr+DzqwmqHsx7Ulr/+0H7bWCcClDhhWkSyZR5BmTvnBEyONwJCTWHfc5PAQExX24VD26IAVw==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.0.2.tgz", + "integrity": "sha512-cs84mxgC9zQ6viV8MEcigfIKQmKtBkZNDYf8Gru2M+MhnA6z9q0NFMZm2IEzKqAwN8lY5mFVd1Z8DiHj6zQ3Tw==", "dev": true, "requires": { "debug": "^4.1.1", @@ -5537,7 +5521,7 @@ "glob": "^7.1.6", "is-glob": "^4.0.1", "lodash": "^4.17.15", - "semver": "^6.3.0", + "semver": "^7.3.2", "tsutils": "^3.17.1" }, "dependencies": { @@ -5555,12 +5539,6 @@ "path-is-absolute": "^1.0.0" } }, - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - }, "tsutils": { "version": "3.17.1", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", @@ -5613,9 +5591,9 @@ } }, "acorn-jsx": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.1.0.tgz", - "integrity": "sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.2.0.tgz", + "integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==", "dev": true }, "acorn-walk": { @@ -7637,9 +7615,9 @@ "dev": true }, "emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, "enabled": { @@ -7744,22 +7722,22 @@ } }, "eslint": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", - "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.1.0.tgz", + "integrity": "sha512-DfS3b8iHMK5z/YLSme8K5cge168I8j8o1uiVmFCgnnjxZQbCGyraF8bMl7Ju4yfBmCuxD7shOF7eqGkcuIHfsA==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", "ajv": "^6.10.0", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", "debug": "^4.0.1", "doctrine": "^3.0.0", "eslint-scope": "^5.0.0", - "eslint-utils": "^1.4.3", + "eslint-utils": "^2.0.0", "eslint-visitor-keys": "^1.1.0", - "espree": "^6.1.2", - "esquery": "^1.0.1", + "espree": "^7.0.0", + "esquery": "^1.2.0", "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", @@ -7772,98 +7750,192 @@ "is-glob": "^4.0.0", "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", + "levn": "^0.4.1", "lodash": "^4.17.14", "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", - "optionator": "^0.8.3", + "optionator": "^0.9.1", "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^6.1.2", - "strip-ansi": "^5.2.0", - "strip-json-comments": "^3.0.1", + "regexpp": "^3.1.0", + "semver": "^7.2.1", + "strip-ansi": "^6.0.0", + "strip-json-comments": "^3.1.0", "table": "^5.2.3", "text-table": "^0.2.0", "v8-compile-cache": "^2.0.3" }, "dependencies": { "ajv": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", - "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "version": "6.12.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.2.tgz", + "integrity": "sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ==", "dev": true, "requires": { - "fast-deep-equal": "^2.0.1", + "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", + "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "fast-deep-equal": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz", + "integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==", "dev": true }, "glob-parent": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", - "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", + "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", "dev": true, "requires": { "is-glob": "^4.0.1" } }, "globals": { - "version": "12.3.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-12.3.0.tgz", - "integrity": "sha512-wAfjdLgFsPZsklLJvOBUBmzYE8/CwhEqSBEMRXA3qxIiNtyqvjYurAtIfDh6chlEPUfmTY3MnZh5Hfh4q0UlIw==", + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", + "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", "dev": true, "requires": { "type-fest": "^0.8.1" } }, + "levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + } + }, "optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", "dev": true, "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" } }, - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", "dev": true, "requires": { - "ansi-regex": "^4.1.0" + "ansi-regex": "^5.0.0" } }, "strip-json-comments": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", - "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.0.tgz", + "integrity": "sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w==", "dev": true }, - "type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", - "dev": true + "type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } } } }, @@ -7896,9 +7968,9 @@ } }, "eslint-utils": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", - "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.0.0.tgz", + "integrity": "sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA==", "dev": true, "requires": { "eslint-visitor-keys": "^1.1.0" @@ -7911,13 +7983,13 @@ "dev": true }, "espree": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.2.tgz", - "integrity": "sha512-2iUPuuPP+yW1PZaMSDM9eyVf8D5P0Hi8h83YtZ5bPc/zHYjII5khoixIUTMO794NOY8F/ThF1Bo8ncZILarUTA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-7.0.0.tgz", + "integrity": "sha512-/r2XEx5Mw4pgKdyb7GNLQNsu++asx/dltf/CI8RFi9oGHxmQFgvLbc5Op4U6i8Oaj+kdslhJtVlEZeAqH5qOTw==", "dev": true, "requires": { - "acorn": "^7.1.0", - "acorn-jsx": "^5.1.0", + "acorn": "^7.1.1", + "acorn-jsx": "^5.2.0", "eslint-visitor-keys": "^1.1.0" } }, @@ -7928,12 +8000,20 @@ "dev": true }, "esquery": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", - "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz", + "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==", "dev": true, "requires": { - "estraverse": "^4.0.0" + "estraverse": "^5.1.0" + }, + "dependencies": { + "estraverse": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.1.0.tgz", + "integrity": "sha512-FyohXK+R0vE+y1nHLoBM7ZTyqRpqAlhdZHCWIWEviFLiGB8b04H6bQs8G+XTthacvT8VuwvteiP7RJSxMs8UEw==", + "dev": true + } } }, "esrecurse": { @@ -8467,9 +8547,9 @@ } }, "flatted": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", - "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", + "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==", "dev": true }, "flush-write-stream": { @@ -9990,33 +10070,33 @@ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, "inquirer": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.1.tgz", - "integrity": "sha512-V1FFQ3TIO15det8PijPLFR9M9baSlnRs9nL7zWu1MNVA2T9YVl9ZbrHJhYs7e9X8jeMZ3lr2JH/rdHFgNCBdYw==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.1.0.tgz", + "integrity": "sha512-5fJMWEmikSYu0nv/flMc475MhGbB7TSPd/2IpFV4I4rMklboCH2rQjYY5kKiYGHqUF9gvaambupcJFFG9dvReg==", "dev": true, "requires": { "ansi-escapes": "^4.2.1", - "chalk": "^2.4.2", + "chalk": "^3.0.0", "cli-cursor": "^3.1.0", "cli-width": "^2.0.0", "external-editor": "^3.0.3", "figures": "^3.0.0", "lodash": "^4.17.15", "mute-stream": "0.0.8", - "run-async": "^2.2.0", + "run-async": "^2.4.0", "rxjs": "^6.5.3", "string-width": "^4.1.0", - "strip-ansi": "^5.1.0", + "strip-ansi": "^6.0.0", "through": "^2.3.6" }, "dependencies": { "ansi-escapes": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.0.tgz", - "integrity": "sha512-EiYhwo0v255HUL6eDyuLrXEkTi7WwVCLAw+SeOQ7M7qdun1z1pum4DEm/nuqIVbPvi9RPPc9k9LbyBv6H0DwVg==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz", + "integrity": "sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA==", "dev": true, "requires": { - "type-fest": "^0.8.1" + "type-fest": "^0.11.0" } }, "ansi-regex": { @@ -10025,15 +10105,24 @@ "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true }, + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", "dev": true, "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" } }, "cli-cursor": { @@ -10045,16 +10134,25 @@ "restore-cursor": "^3.1.0" } }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, "figures": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-3.1.0.tgz", - "integrity": "sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", + "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", "dev": true, "requires": { "escape-string-regexp": "^1.0.5" @@ -10097,14 +10195,11 @@ "signal-exit": "^3.0.2" } }, - "rxjs": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.3.tgz", - "integrity": "sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==", - "dev": true, - "requires": { - "tslib": "^1.9.0" - } + "run-async": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", + "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", + "dev": true }, "string-width": { "version": "4.2.0", @@ -10115,49 +10210,21 @@ "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.0" - }, - "dependencies": { - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - } } }, "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - } - } - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "ansi-regex": "^5.0.0" } }, "type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.11.0.tgz", + "integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==", "dev": true } } @@ -15488,9 +15555,9 @@ } }, "regexpp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", + "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", "dev": true }, "regexpu-core": { @@ -16458,12 +16525,12 @@ }, "dependencies": { "ajv": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", - "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "version": "6.12.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.2.tgz", + "integrity": "sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ==", "dev": true, "requires": { - "fast-deep-equal": "^2.0.1", + "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" @@ -16475,6 +16542,18 @@ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "dev": true }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "fast-deep-equal": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz", + "integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==", + "dev": true + }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", @@ -16892,9 +16971,9 @@ } }, "typescript": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", - "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==", + "version": "3.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.3.tgz", + "integrity": "sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==", "dev": true }, "unc-path-regex": { diff --git a/package.json b/package.json index 3c189513cc7..643cbf1b313 100644 --- a/package.json +++ b/package.json @@ -77,14 +77,14 @@ "@types/serialport": "^8.0.0", "@types/triple-beam": "^1.3.0", "@types/yargs": "^15.0.4", - "@typescript-eslint/eslint-plugin": "^2.30.0", - "@typescript-eslint/parser": "^2.30.0", + "@typescript-eslint/eslint-plugin": "^3.0.2", + "@typescript-eslint/parser": "^3.0.2", "axios": "^0.19.2", "clipboardy": "^2.3.0", "commitizen": "^4.0.4", "coveralls": "^3.1.0", "cz-conventional-changelog": "^3.1.0", - "eslint": "^6.8.0", + "eslint": "^7.1.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-prettier": "^3.1.3", "gulp": "^4.0.2", @@ -98,7 +98,7 @@ "semver": "^7.3.2", "supports-color": "^7.1.0", "ts-node": "^8.9.1", - "typescript": "^3.8.3", + "typescript": "^3.9.3", "yargs": "^15.3.1" }, "dependencies": { diff --git a/src/index.ts b/src/index.ts index dde26fe7457..0badbb77753 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,13 +30,18 @@ function isZWaveError( err: Error | string | null | undefined, ): err is ZWaveError { if (!err || typeof err === "string") return false; + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access return "code" in err && typeof (err as any).code === "number"; } // Parse package.json and init sentry +// eslint-disable-next-line @typescript-eslint/no-floating-promises fs.readFile(path.join(libraryRootDir, "package.json"), "utf8").then( (fileContents) => { - const packageJson = JSON.parse(fileContents); + const packageJson = JSON.parse(fileContents) as { + name: string; + version: string; + }; Sentry.init({ release: `${packageJson.name}@${packageJson.version}`, dsn: "https://841e902ca32842beadada39343a72479@sentry.io/1839595", diff --git a/src/lib/commandclass/API.test.ts b/src/lib/commandclass/API.test.ts index 0fb99ba7eec..63700ac27bf 100644 --- a/src/lib/commandclass/API.test.ts +++ b/src/lib/commandclass/API.test.ts @@ -6,7 +6,7 @@ import { API } from "./CommandClass"; const fakeDriver = (createEmptyMockDriver() as unknown) as Driver; const node = new ZWaveNode(1, fakeDriver as any); -(fakeDriver.controller!.nodes as any).set(node.id, node); +(fakeDriver.controller.nodes as any).set(node.id, node); @API(0xff) export class DummyCCAPI extends CCAPI {} diff --git a/src/lib/commandclass/AssociationCC.ts b/src/lib/commandclass/AssociationCC.ts index ed64d1c1cbf..215b443f555 100644 --- a/src/lib/commandclass/AssociationCC.ts +++ b/src/lib/commandclass/AssociationCC.ts @@ -122,7 +122,7 @@ export class AssociationCCAPI extends CCAPI { /** * Returns information about an association group. */ - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getGroup(groupId: number) { this.assertSupportsCommand(AssociationCommand, AssociationCommand.Get); @@ -459,7 +459,9 @@ export class AssociationCCRemove extends AssociationCC { if (!options.groupId) { if (this.version === 1) { throw new ZWaveError( - `Node ${this.nodeId} only supports AssociationCC V1 which requires the group Id to be set`, + `Node ${ + this.nodeId as number + } only supports AssociationCC V1 which requires the group Id to be set`, ZWaveErrorCodes.Argument_Invalid, ); } diff --git a/src/lib/commandclass/AssociationGroupInfoCC.test.ts b/src/lib/commandclass/AssociationGroupInfoCC.test.ts index 557a174530b..fa1b13fde91 100644 --- a/src/lib/commandclass/AssociationGroupInfoCC.test.ts +++ b/src/lib/commandclass/AssociationGroupInfoCC.test.ts @@ -17,7 +17,7 @@ import { CommandClasses } from "./CommandClasses"; const fakeDriver = (createEmptyMockDriver() as unknown) as Driver; const node1 = new ZWaveNode(1, fakeDriver as any); -(fakeDriver.controller!.nodes as any).set(1, node1); +(fakeDriver.controller.nodes as any).set(1, node1); function buildCCBuffer(payload: Buffer): Buffer { return Buffer.concat([ diff --git a/src/lib/commandclass/AssociationGroupInfoCC.ts b/src/lib/commandclass/AssociationGroupInfoCC.ts index af8c1cedd90..67614aab09e 100644 --- a/src/lib/commandclass/AssociationGroupInfoCC.ts +++ b/src/lib/commandclass/AssociationGroupInfoCC.ts @@ -295,7 +295,7 @@ export class AssociationGroupInfoCCAPI extends CCAPI { return response.name; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getGroupInfo(groupId: number, refreshCache: boolean = false) { this.assertSupportsCommand( AssociationGroupInfoCommand, @@ -319,7 +319,7 @@ export class AssociationGroupInfoCCAPI extends CCAPI { }; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getCommands( groupId: number, allowCache: boolean = true, diff --git a/src/lib/commandclass/BasicCC.ts b/src/lib/commandclass/BasicCC.ts index ac9629f8b54..383638ed99c 100644 --- a/src/lib/commandclass/BasicCC.ts +++ b/src/lib/commandclass/BasicCC.ts @@ -58,7 +58,7 @@ export class BasicCCAPI extends CCAPI { await this.get(); }; - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get() { this.assertSupportsCommand(BasicCommand, BasicCommand.Get); @@ -121,7 +121,7 @@ current value: ${basicResponse.currentValue}`; if (basicResponse.targetValue != undefined) { logMessage += ` target value: ${basicResponse.targetValue} -remaining duration: ${basicResponse.duration}`; +remaining duration: ${basicResponse.duration?.toString() ?? "undefined"}`; } log.controller.logNode(node.id, { endpoint: this.endpointIndex, @@ -165,7 +165,8 @@ type BasicCCReportOptions = CCCommandOptions & ({ currentValue: number; } & ( - | {} + | // eslint-disable-next-line @typescript-eslint/ban-types + {} | { targetValue: number; duration: Duration; diff --git a/src/lib/commandclass/BatteryCC.ts b/src/lib/commandclass/BatteryCC.ts index 0a88a3a98d0..500b6bf5bf9 100644 --- a/src/lib/commandclass/BatteryCC.ts +++ b/src/lib/commandclass/BatteryCC.ts @@ -57,7 +57,7 @@ export class BatteryCCAPI extends CCAPI { return super.supportsCommand(cmd); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get() { this.assertSupportsCommand(BatteryCommand, BatteryCommand.Get); @@ -79,7 +79,7 @@ export class BatteryCCAPI extends CCAPI { }; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getHealth() { this.assertSupportsCommand(BatteryCommand, BatteryCommand.HealthGet); diff --git a/src/lib/commandclass/BinarySensorCC.ts b/src/lib/commandclass/BinarySensorCC.ts index 5136881aeee..05914e45a6a 100644 --- a/src/lib/commandclass/BinarySensorCC.ts +++ b/src/lib/commandclass/BinarySensorCC.ts @@ -104,7 +104,7 @@ export class BinarySensorCCAPI extends CCAPI { return response.value; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getSupportedSensorTypes() { this.assertSupportsCommand( BinarySensorCommand, @@ -152,7 +152,8 @@ export class BinarySensorCC extends CommandClass { supportedSensorTypes = await api.getSupportedSensorTypes(); const logMessage = `received supported sensor types: ${supportedSensorTypes .map((type) => getEnumMemberName(BinarySensorType, type)) - .map((name) => "\n· " + name)}`; + .map((name) => `\n· ${name}`) + .join("")}`; log.controller.logNode(node.id, { endpoint: this.endpointIndex, message: logMessage, diff --git a/src/lib/commandclass/BinarySwitchCC.ts b/src/lib/commandclass/BinarySwitchCC.ts index ade78b30c25..6d9a1016889 100644 --- a/src/lib/commandclass/BinarySwitchCC.ts +++ b/src/lib/commandclass/BinarySwitchCC.ts @@ -45,7 +45,7 @@ export class BinarySwitchCCAPI extends CCAPI { return super.supportsCommand(cmd); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get() { this.assertSupportsCommand( BinarySwitchCommand, @@ -136,7 +136,9 @@ current value: ${binarySwitchResponse.currentValue}`; if (binarySwitchResponse.targetValue != undefined) { logMessage += ` target value: ${binarySwitchResponse.targetValue} -remaining duration: ${binarySwitchResponse.duration}`; +remaining duration: ${ + binarySwitchResponse.duration?.toString() ?? "undefined" + }`; } log.controller.logNode(node.id, { endpoint: this.endpointIndex, diff --git a/src/lib/commandclass/CentralSceneCC.test.ts b/src/lib/commandclass/CentralSceneCC.test.ts index ba8fc02106a..0994cfbad41 100644 --- a/src/lib/commandclass/CentralSceneCC.test.ts +++ b/src/lib/commandclass/CentralSceneCC.test.ts @@ -16,7 +16,7 @@ import { CommandClasses } from "./CommandClasses"; const fakeDriver = (createEmptyMockDriver() as unknown) as Driver; const node1 = new ZWaveNode(1, fakeDriver as any); -(fakeDriver.controller!.nodes as any).set(1, node1); +(fakeDriver.controller.nodes as any).set(1, node1); function buildCCBuffer(payload: Buffer): Buffer { return Buffer.concat([ diff --git a/src/lib/commandclass/CentralSceneCC.ts b/src/lib/commandclass/CentralSceneCC.ts index 3c659304259..bcd58f7ac5d 100644 --- a/src/lib/commandclass/CentralSceneCC.ts +++ b/src/lib/commandclass/CentralSceneCC.ts @@ -77,7 +77,7 @@ export class CentralSceneCCAPI extends CCAPI { return super.supportsCommand(cmd); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getSupported() { this.assertSupportsCommand( CentralSceneCommand, @@ -98,7 +98,7 @@ export class CentralSceneCCAPI extends CCAPI { }; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getConfiguration() { this.assertSupportsCommand( CentralSceneCommand, diff --git a/src/lib/commandclass/ClimateControlScheduleCC.ts b/src/lib/commandclass/ClimateControlScheduleCC.ts index 343c22d7596..166352f7095 100644 --- a/src/lib/commandclass/ClimateControlScheduleCC.ts +++ b/src/lib/commandclass/ClimateControlScheduleCC.ts @@ -114,7 +114,7 @@ export class ClimateControlScheduleCCAPI extends CCAPI { return response.changeCounter; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getOverride() { this.assertSupportsCommand( ClimateControlScheduleCommand, diff --git a/src/lib/commandclass/ClockCC.ts b/src/lib/commandclass/ClockCC.ts index a30f517ab8b..07ea8af5ef3 100644 --- a/src/lib/commandclass/ClockCC.ts +++ b/src/lib/commandclass/ClockCC.ts @@ -51,7 +51,7 @@ export class ClockCCAPI extends CCAPI { return super.supportsCommand(cmd); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get() { this.assertSupportsCommand(ClockCommand, ClockCommand.Get); diff --git a/src/lib/commandclass/ColorSwitchCC.test.ts b/src/lib/commandclass/ColorSwitchCC.test.ts index 6dcdb570c56..9b2a5388493 100644 --- a/src/lib/commandclass/ColorSwitchCC.test.ts +++ b/src/lib/commandclass/ColorSwitchCC.test.ts @@ -17,7 +17,7 @@ import { CommandClasses } from "./CommandClasses"; const fakeDriver = (createEmptyMockDriver() as unknown) as Driver; const node1 = new ZWaveNode(1, fakeDriver as any); -(fakeDriver.controller!.nodes as any).set(1, node1); +(fakeDriver.controller.nodes as any).set(1, node1); function buildCCBuffer(payload: Buffer): Buffer { return Buffer.concat([ diff --git a/src/lib/commandclass/ColorSwitchCC.ts b/src/lib/commandclass/ColorSwitchCC.ts index bf6b5d87ab6..6794dc6e9e9 100644 --- a/src/lib/commandclass/ColorSwitchCC.ts +++ b/src/lib/commandclass/ColorSwitchCC.ts @@ -167,7 +167,7 @@ export class ColorSwitchCCAPI extends CCAPI { return response.supportedColorComponents; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get(component: ColorComponent) { this.assertSupportsCommand(ColorSwitchCommand, ColorSwitchCommand.Get); @@ -288,9 +288,9 @@ export class ColorSwitchCC extends CommandClass { supportedColors = await api.getSupported(); log.controller.logNode(node.id, { endpoint: this.endpointIndex, - message: `received supported colors:${supportedColors.map( - (c) => `\n· ${getEnumMemberName(ColorComponent, c)}`, - )}`, + message: `received supported colors:${supportedColors + .map((c) => `\n· ${getEnumMemberName(ColorComponent, c)}`) + .join("")}`, direction: "outbound", }); diff --git a/src/lib/commandclass/CommandClass.ts b/src/lib/commandclass/CommandClass.ts index a00f2f18bc9..da2d2c577ca 100644 --- a/src/lib/commandclass/CommandClass.ts +++ b/src/lib/commandclass/CommandClass.ts @@ -45,9 +45,9 @@ export type CommandClassDeserializationOptions = { data: Buffer } & ( ); export function gotDeserializationOptions( - options: any, + options: CommandClassOptions, ): options is CommandClassDeserializationOptions { - return Buffer.isBuffer(options.data); + return "data" in options && Buffer.isBuffer(options.data); } export interface CCCommandOptions { @@ -775,7 +775,6 @@ export type MulticastCC = T & { // ======================= // use decorators to link command class values to actual command classes -/* eslint-disable @typescript-eslint/camelcase */ const METADATA_commandClass = Symbol("commandClass"); const METADATA_commandClassMap = Symbol("commandClassMap"); const METADATA_ccResponse = Symbol("ccResponse"); @@ -787,7 +786,6 @@ const METADATA_ccValueMeta = Symbol("ccValueMeta"); const METADATA_version = Symbol("version"); const METADATA_API = Symbol("API"); const METADATA_APIMap = Symbol("APIMap"); -/* eslint-enable @typescript-eslint/camelcase */ export interface Constructable { new ( @@ -901,10 +899,9 @@ export function getCommandClassStatic>( classConstructor: T, ): CommandClasses { // retrieve the current metadata - const ret: CommandClasses | undefined = Reflect.getMetadata( - METADATA_commandClass, - classConstructor, - ); + const ret = Reflect.getMetadata(METADATA_commandClass, classConstructor) as + | CommandClasses + | undefined; if (ret == undefined) { throw new ZWaveError( `No command class defined for ${classConstructor.name}!`, @@ -927,10 +924,9 @@ export function getCCConstructor( cc: CommandClasses, ): Constructable | undefined { // Retrieve the constructor map from the CommandClass class - const map: CommandClassMap | undefined = Reflect.getMetadata( - METADATA_commandClassMap, - CommandClass, - ); + const map = Reflect.getMetadata(METADATA_commandClassMap, CommandClass) as + | CommandClassMap + | undefined; if (map != undefined) return map.get(cc); } @@ -982,8 +978,10 @@ export function getImplementedVersionStatic< T extends Constructable >(classConstructor: T): number { // retrieve the current metadata - const ret: number = - Reflect.getMetadata(METADATA_version, classConstructor) || 0; + const ret = + (Reflect.getMetadata(METADATA_version, classConstructor) as + | number + | undefined) || 0; log.reflection.lookup( classConstructor.name, @@ -1031,10 +1029,9 @@ function getCCCommand(cc: T): number | undefined { const constrName = constr.name; // retrieve the current metadata - const ret: number | undefined = Reflect.getMetadata( - METADATA_ccCommand, - constr, - ); + const ret = Reflect.getMetadata(METADATA_ccCommand, constr) as + | number + | undefined; log.reflection.lookup(constrName, "CC Command", `${ret} (${num2hex(ret)})`); return ret; @@ -1049,10 +1046,9 @@ function getCCCommandConstructor( ccCommand: number, ): Constructable | undefined { // Retrieve the constructor map from the CommandClass class - const map: CCCommandMap | undefined = Reflect.getMetadata( - METADATA_ccCommandMap, - CommandClass, - ); + const map = Reflect.getMetadata(METADATA_ccCommandMap, CommandClass) as + | CCCommandMap + | undefined; if (map != undefined) return (map.get(getCCCommandMapKey(ccId, ccCommand)) as unknown) as | Constructable @@ -1119,11 +1115,11 @@ export function getExpectedCCResponse( // get the class constructor const constr = ccClass.constructor; // retrieve the current metadata - const ret: + const ret = Reflect.getMetadata(METADATA_ccResponse, constr) as | typeof CommandClass | DynamicCCResponse | CCResponsePredicate - | undefined = Reflect.getMetadata(METADATA_ccResponse, constr); + | undefined; if (!ret || staticExtends(ret, CommandClass)) { log.reflection.lookup( constr.name, @@ -1173,7 +1169,7 @@ export function ccValue(options?: CCValueOptions): PropertyDecorator { const cc = getCommandClassStatic(constr); // retrieve the current metadata const metadata = - Reflect.getMetadata(METADATA_ccValues, CommandClass) || {}; + Reflect.getMetadata(METADATA_ccValues, CommandClass) ?? {}; if (!(cc in metadata)) metadata[cc] = new Map(); // And add the variable const variables: Map = metadata[cc]; @@ -1294,8 +1290,8 @@ export function API(cc: CommandClasses): ClassDecorator { Reflect.defineMetadata(METADATA_API, cc, apiClass); // also store a map in the CCAPI metadata for lookup. - const map: APIMap = - Reflect.getMetadata(METADATA_APIMap, CCAPI) || new Map(); + const map = (Reflect.getMetadata(METADATA_APIMap, CCAPI) || + new Map()) as APIMap; map.set(cc, (apiClass as any) as APIConstructor); Reflect.defineMetadata(METADATA_APIMap, map, CCAPI); }; @@ -1306,7 +1302,9 @@ export function API(cc: CommandClasses): ClassDecorator { */ export function getAPI(cc: CommandClasses): APIConstructor | undefined { // Retrieve the constructor map from the CCAPI class - const map: APIMap | undefined = Reflect.getMetadata(METADATA_APIMap, CCAPI); + const map = Reflect.getMetadata(METADATA_APIMap, CCAPI) as + | APIMap + | undefined; const ret = map?.get(cc); log.reflection.lookup( diff --git a/src/lib/commandclass/ConfigurationCC.ts b/src/lib/commandclass/ConfigurationCC.ts index eef6508dff6..f3fce0520ba 100644 --- a/src/lib/commandclass/ConfigurationCC.ts +++ b/src/lib/commandclass/ConfigurationCC.ts @@ -257,7 +257,9 @@ export class ConfigurationCCAPI extends CCAPI { ); } log.controller.logNode(this.endpoint.nodeId, { - message: `Received unexpected ConfigurationReport (param = ${response.parameter}, value = ${response.value})`, + message: `Received unexpected ConfigurationReport (param = ${ + response.parameter + }, value = ${response.value.toString()})`, direction: "inbound", level: "error", }); @@ -365,7 +367,7 @@ export class ConfigurationCCAPI extends CCAPI { await this.driver.sendCommand(cc); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getProperties(parameter: number) { const cc = new ConfigurationCCPropertiesGet(this.driver, { nodeId: this.endpoint.nodeId, @@ -458,7 +460,7 @@ export class ConfigurationCCAPI extends CCAPI { const logMessage = ` Param ${param}: readable = true valueSize = ${ccInstance.getParamInformation(param).valueSize} - value = ${originalValue}`; + value = ${originalValue.toString()}`; log.controller.logNode(this.endpoint.nodeId, { message: logMessage, direction: "inbound", @@ -591,9 +593,9 @@ export class ConfigurationCC extends CommandClass { parameter name: ${name} value format: ${getEnumMemberName(ValueFormat, properties.valueFormat)} value size: ${properties.valueSize} bytes -min value: ${properties.minValue} -max value: ${properties.maxValue} -default value: ${properties.defaultValue} +min value: ${properties.minValue?.toString() ?? "undefined"} +max value: ${properties.maxValue?.toString() ?? "undefined"} +default value: ${properties.defaultValue?.toString() ?? "undefined"} is read-only: ${!!properties.isReadonly} is advanced (UI): ${!!properties.isAdvanced} has bulk support: ${!properties.noBulkSupport} @@ -1274,7 +1276,7 @@ export class ConfigurationCCBulkReport extends ConfigurationCC { return this._valueSize; } - private _values: Map = new Map(); + private _values = new Map(); public get values(): ReadonlyMap { return this._values; } diff --git a/src/lib/commandclass/IndicatorCC.ts b/src/lib/commandclass/IndicatorCC.ts index 7a420c0c4a1..af3523c75b9 100644 --- a/src/lib/commandclass/IndicatorCC.ts +++ b/src/lib/commandclass/IndicatorCC.ts @@ -212,7 +212,7 @@ export class IndicatorCCAPI extends CCAPI { await this.driver.sendCommand(cc); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getSupported( indicatorId: number, ): Promise<{ @@ -446,7 +446,9 @@ export class IndicatorCCSet extends IndicatorCC { if (this.version === 1) { if (!("value" in options)) { throw new ZWaveError( - `Node ${this.nodeId} only supports IndicatorCC V1 which requires a single value to be set`, + `Node ${ + this.nodeId as number + } only supports IndicatorCC V1 which requires a single value to be set`, ZWaveErrorCodes.Argument_Invalid, ); } diff --git a/src/lib/commandclass/LanguageCC.ts b/src/lib/commandclass/LanguageCC.ts index 614f229d177..17087ec4b73 100644 --- a/src/lib/commandclass/LanguageCC.ts +++ b/src/lib/commandclass/LanguageCC.ts @@ -36,7 +36,7 @@ export class LanguageCCAPI extends CCAPI { return super.supportsCommand(cmd); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get() { this.assertSupportsCommand(LanguageCommand, LanguageCommand.Get); diff --git a/src/lib/commandclass/ManufacturerProprietaryCC.ts b/src/lib/commandclass/ManufacturerProprietaryCC.ts index b1c086e41a8..a902773d388 100644 --- a/src/lib/commandclass/ManufacturerProprietaryCC.ts +++ b/src/lib/commandclass/ManufacturerProprietaryCC.ts @@ -40,12 +40,12 @@ export class ManufacturerProprietaryCCAPI extends CCAPI { await this.driver.sendCommand(cc); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async fibaroVenetianBlindsGet() { const { FibaroVenetianBlindCCGet, // eslint-disable-next-line @typescript-eslint/no-var-requires - } = require("./manufacturerProprietary/Fibaro"); + } = require("./manufacturerProprietary/Fibaro") as typeof import("./manufacturerProprietary/Fibaro"); const cc = new FibaroVenetianBlindCCGet(this.driver, { nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, @@ -63,7 +63,7 @@ export class ManufacturerProprietaryCCAPI extends CCAPI { const { FibaroVenetianBlindCCSet, // eslint-disable-next-line @typescript-eslint/no-var-requires - } = require("./manufacturerProprietary/Fibaro"); + } = require("./manufacturerProprietary/Fibaro") as typeof import("./manufacturerProprietary/Fibaro"); const cc = new FibaroVenetianBlindCCSet(this.driver, { nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, @@ -76,7 +76,7 @@ export class ManufacturerProprietaryCCAPI extends CCAPI { const { FibaroVenetianBlindCCSet, // eslint-disable-next-line @typescript-eslint/no-var-requires - } = require("./manufacturerProprietary/Fibaro"); + } = require("./manufacturerProprietary/Fibaro") as typeof import("./manufacturerProprietary/Fibaro"); const cc = new FibaroVenetianBlindCCSet(this.driver, { nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, @@ -203,9 +203,10 @@ export class ManufacturerProprietaryCC extends CommandClass { isArray(proprietaryConfig.fibaroCCs) && proprietaryConfig.fibaroCCs.includes(0x26 /* Venetian Blinds */) ) { - const FibaroVenetianBlindCC = require("./manufacturerProprietary/Fibaro") + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + const FibaroVenetianBlindCC = (require("./manufacturerProprietary/Fibaro") as typeof import("./manufacturerProprietary/Fibaro")) .FibaroVenetianBlindCC; - return new FibaroVenetianBlindCC(this.driver, { + await new FibaroVenetianBlindCC(this.driver, { nodeId: this.nodeId, endpoint: this.endpointIndex, }).interview(complete); diff --git a/src/lib/commandclass/ManufacturerSpecificCC.ts b/src/lib/commandclass/ManufacturerSpecificCC.ts index 4c8b19746df..1fcc48f8b63 100644 --- a/src/lib/commandclass/ManufacturerSpecificCC.ts +++ b/src/lib/commandclass/ManufacturerSpecificCC.ts @@ -96,7 +96,7 @@ export class ManufacturerSpecificCCAPI extends CCAPI { return super.supportsCommand(cmd); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get() { this.assertSupportsCommand( ManufacturerSpecificCommand, diff --git a/src/lib/commandclass/MeterCC.ts b/src/lib/commandclass/MeterCC.ts index 6e14d6c347d..9a4143eb5aa 100644 --- a/src/lib/commandclass/MeterCC.ts +++ b/src/lib/commandclass/MeterCC.ts @@ -125,7 +125,7 @@ export class MeterCCAPI extends CCAPI { return super.supportsCommand(cmd); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get(options?: MeterCCGetOptions) { this.assertSupportsCommand(MeterCommand, MeterCommand.Get); @@ -145,7 +145,7 @@ export class MeterCCAPI extends CCAPI { }; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getSupported() { this.assertSupportsCommand(MeterCommand, MeterCommand.SupportedGet); @@ -221,10 +221,12 @@ export class MeterCC extends CommandClass { type: ${getMeterTypeName(type)} supported scales: ${supportedScales .map((s) => lookupMeterScale(type, s).label) - .map((label) => `\n· ${label}`)} + .map((label) => `\n· ${label}`) + .join("")} supported rate types: ${supportedRateTypes .map((rt) => getEnumMemberName(RateType, rt)) - .map((label) => `\n· ${label}`)} + .map((label) => `\n· ${label}`) + .join("")} supports reset: ${supportsReset}`; log.controller.logNode(node.id, { endpoint: this.endpointIndex, diff --git a/src/lib/commandclass/MultiChannelAssociationCC.ts b/src/lib/commandclass/MultiChannelAssociationCC.ts index ed79b1c54bf..c9012a392e8 100644 --- a/src/lib/commandclass/MultiChannelAssociationCC.ts +++ b/src/lib/commandclass/MultiChannelAssociationCC.ts @@ -64,11 +64,9 @@ export function getGroupCountValueId(): ValueID { }; } -export type EndpointBitMask = (1 | 2 | 3 | 4 | 5 | 6 | 7)[]; - export interface EndpointAddress { nodeId: number; - endpoint: number | EndpointBitMask; + endpoint: number | number[]; } const MULTI_CHANNEL_ASSOCIATION_MARKER = 0x00; @@ -131,7 +129,7 @@ function deserializeMultiChannelAssociationDestination( const isBitMask = !!(data[i + 1] & 0b1000_0000); const destination = data[i + 1] & 0b0111_1111; const endpoint = isBitMask - ? (parseBitMask(Buffer.from([destination])) as any) + ? parseBitMask(Buffer.from([destination])) : destination; endpoints.push({ nodeId, endpoint }); @@ -193,7 +191,7 @@ export class MultiChannelAssociationCCAPI extends CCAPI { /** * Returns information about an association group. */ - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getGroup(groupId: number) { this.assertSupportsCommand( MultiChannelAssociationCommand, @@ -412,13 +410,15 @@ export class MultiChannelAssociationCC extends CommandClass { const logMessage = `received information for association group #${groupId}: maximum # of nodes: ${group.maxNodes} currently assigned nodes: ${group.nodeIds.map(String).join(", ")} -currently assigned endpoints: ${group.endpoints.map(({ nodeId, endpoint }) => { - if (typeof endpoint === "number") { - return `${nodeId}:${endpoint}`; - } else { - return `${nodeId}:[${endpoint.map(String).join(", ")}]`; - } - })}`; +currently assigned endpoints: ${group.endpoints + .map(({ nodeId, endpoint }) => { + if (typeof endpoint === "number") { + return `${nodeId}:${endpoint}`; + } else { + return `${nodeId}:[${endpoint.map(String).join(", ")}]`; + } + }) + .join("")}`; log.controller.logNode(node.id, { endpoint: this.endpointIndex, message: logMessage, @@ -617,7 +617,9 @@ export class MultiChannelAssociationCCRemove extends MultiChannelAssociationCC { if (!options.groupId) { if (this.version === 1) { throw new ZWaveError( - `Node ${this.nodeId} only supports MultiChannelAssociationCC V1 which requires the group Id to be set`, + `Node ${ + this.nodeId as number + } only supports MultiChannelAssociationCC V1 which requires the group Id to be set`, ZWaveErrorCodes.Argument_Invalid, ); } diff --git a/src/lib/commandclass/MultiChannelCC.ts b/src/lib/commandclass/MultiChannelCC.ts index 771089d7445..82c0da9652c 100644 --- a/src/lib/commandclass/MultiChannelCC.ts +++ b/src/lib/commandclass/MultiChannelCC.ts @@ -109,7 +109,7 @@ export class MultiChannelCCAPI extends CCAPI { return super.supportsCommand(cmd); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getEndpoints() { this.assertSupportsCommand( MultiChannelCommand, diff --git a/src/lib/commandclass/MultilevelSensorCC.ts b/src/lib/commandclass/MultilevelSensorCC.ts index bba47a4a277..a72cb77c73e 100644 --- a/src/lib/commandclass/MultilevelSensorCC.ts +++ b/src/lib/commandclass/MultilevelSensorCC.ts @@ -62,7 +62,7 @@ export class MultilevelSensorCCAPI extends CCAPI { public async get(): Promise; public async get(sensorType: number, scale: number): Promise; - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get(sensorType?: number, scale?: number) { this.assertSupportsCommand( MultilevelSensorCommand, diff --git a/src/lib/commandclass/MultilevelSwitchCC.ts b/src/lib/commandclass/MultilevelSwitchCC.ts index ae318ee65d9..dba07eb6912 100644 --- a/src/lib/commandclass/MultilevelSwitchCC.ts +++ b/src/lib/commandclass/MultilevelSwitchCC.ts @@ -96,7 +96,7 @@ export class MultilevelSwitchCCAPI extends CCAPI { return super.supportsCommand(cmd); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get() { this.assertSupportsCommand( MultilevelSwitchCommand, @@ -122,7 +122,7 @@ export class MultilevelSwitchCCAPI extends CCAPI { * @param targetValue The new target value for the switch * @param duration The optional duration to reach the target value. Available in V2+ */ - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async set(targetValue: number, duration?: Duration) { this.assertSupportsCommand( MultilevelSwitchCommand, @@ -147,7 +147,7 @@ export class MultilevelSwitchCCAPI extends CCAPI { status === SupervisionStatus.Working || status === SupervisionStatus.Success ) { - this.get(); + void this.get(); } }, }, diff --git a/src/lib/commandclass/NotificationCC.ts b/src/lib/commandclass/NotificationCC.ts index 5997f3b5011..0eb03b31d65 100644 --- a/src/lib/commandclass/NotificationCC.ts +++ b/src/lib/commandclass/NotificationCC.ts @@ -72,7 +72,7 @@ export class NotificationCCAPI extends CCAPI { return (await this.driver.sendCommand(cc))!; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get(options: NotificationCCGetSpecificOptions) { const response = await this.getInternal(options); return { @@ -103,7 +103,7 @@ export class NotificationCCAPI extends CCAPI { await this.driver.sendCommand(cc); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getSupported() { this.assertSupportsCommand( NotificationCommand, @@ -123,7 +123,7 @@ export class NotificationCCAPI extends CCAPI { }; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getSupportedEvents(notificationType: number) { this.assertSupportsCommand( NotificationCommand, @@ -245,9 +245,9 @@ export class NotificationCC extends CommandClass { ({ supportedNotificationTypes } = await api.getSupported()); supportedNotificationNames = lookupNotificationNames(); - const logMessage = - "received supported notification types:" + - supportedNotificationNames.map((name) => "\n· " + name); + const logMessage = `received supported notification types:${supportedNotificationNames + .map((name) => `\n· ${name}`) + .join("")}`; log.controller.logNode(node.id, { endpoint: this.endpointIndex, message: logMessage, @@ -287,7 +287,7 @@ export class NotificationCC extends CommandClass { supportedEvents, ); for (const [key, metadata] of metadataMap.entries()) { - const valueId: ValueID = JSON.parse(key); + const valueId = JSON.parse(key) as ValueID; node.valueDB.setMetadata(valueId, metadata); } } diff --git a/src/lib/commandclass/SecurityCC.ts b/src/lib/commandclass/SecurityCC.ts index a840e74d895..2dc0a40f8e4 100644 --- a/src/lib/commandclass/SecurityCC.ts +++ b/src/lib/commandclass/SecurityCC.ts @@ -207,7 +207,7 @@ export class SecurityCCAPI extends CCAPI { await this.driver.sendCommand(cc); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getSupportedCommands() { this.assertSupportsCommand( SecurityCommand, diff --git a/src/lib/commandclass/ThermostatModeCC.ts b/src/lib/commandclass/ThermostatModeCC.ts index fa9e9363f6c..a90a53387cc 100644 --- a/src/lib/commandclass/ThermostatModeCC.ts +++ b/src/lib/commandclass/ThermostatModeCC.ts @@ -86,7 +86,7 @@ export class ThermostatModeCCAPI extends CCAPI { await this.get(); }; - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get() { this.assertSupportsCommand( ThermostatModeCommand, @@ -117,7 +117,11 @@ export class ThermostatModeCCAPI extends CCAPI { manufacturerData: Buffer, ): Promise; - public async set(mode: any, manufacturerData?: any): Promise { + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + public async set( + mode: ThermostatMode, + manufacturerData?: any, + ): Promise { this.assertSupportsCommand( ThermostatModeCommand, ThermostatModeCommand.Set, @@ -127,6 +131,7 @@ export class ThermostatModeCCAPI extends CCAPI { nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, mode, + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment manufacturerData, }); await this.driver.sendCommand(cc); @@ -177,11 +182,9 @@ export class ThermostatModeCC extends CommandClass { const supportedModes = await api.getSupportedModes(); - const logMessage = - `received supported thermostat modes:` + - supportedModes.map( - (mode) => "\n· " + getEnumMemberName(ThermostatMode, mode), - ); + const logMessage = `received supported thermostat modes:${supportedModes + .map((mode) => `\n· ${getEnumMemberName(ThermostatMode, mode)}`) + .join("")}`; log.controller.logNode(node.id, { endpoint: this.endpointIndex, message: logMessage, diff --git a/src/lib/commandclass/ThermostatSetbackCC.ts b/src/lib/commandclass/ThermostatSetbackCC.ts index 92ba34b0a8f..f839506ea98 100644 --- a/src/lib/commandclass/ThermostatSetbackCC.ts +++ b/src/lib/commandclass/ThermostatSetbackCC.ts @@ -54,7 +54,7 @@ export class ThermostatSetbackCCAPI extends CCAPI { return super.supportsCommand(cmd); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get() { this.assertSupportsCommand( ThermostatSetbackCommand, diff --git a/src/lib/commandclass/ThermostatSetpointCC.ts b/src/lib/commandclass/ThermostatSetpointCC.ts index 87df866c906..bda4895c744 100644 --- a/src/lib/commandclass/ThermostatSetpointCC.ts +++ b/src/lib/commandclass/ThermostatSetpointCC.ts @@ -145,7 +145,7 @@ export class ThermostatSetpointCCAPI extends CCAPI { await this.get(propertyKey); }; - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get(setpointType: ThermostatSetpointType) { this.assertSupportsCommand( ThermostatSetpointCommand, @@ -190,7 +190,7 @@ export class ThermostatSetpointCCAPI extends CCAPI { await this.driver.sendCommand(cc); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getCapabilities(setpointType: ThermostatSetpointType) { this.assertSupportsCommand( ThermostatSetpointCommand, @@ -385,7 +385,7 @@ export class ThermostatSetpointCC extends CommandClass { // The setpoint type is not supported, switch to interpretation A log.controller.logNode(node.id, { endpoint: this.endpointIndex, - message: `the setpoint type ${setpointTypes} is unsupported, switching to interpretation A`, + message: `the setpoint type ${type} is unsupported, switching to interpretation A`, direction: "none", }); switchToInterpretationA(); diff --git a/src/lib/commandclass/TimeCC.ts b/src/lib/commandclass/TimeCC.ts index 72f1ec5af19..0fd48938aa0 100644 --- a/src/lib/commandclass/TimeCC.ts +++ b/src/lib/commandclass/TimeCC.ts @@ -46,7 +46,7 @@ export class TimeCCAPI extends CCAPI { return super.supportsCommand(cmd); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getTime() { this.assertSupportsCommand(TimeCommand, TimeCommand.TimeGet); @@ -62,7 +62,7 @@ export class TimeCCAPI extends CCAPI { }; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getDate() { this.assertSupportsCommand(TimeCommand, TimeCommand.DateGet); diff --git a/src/lib/commandclass/TimeParametersCC.ts b/src/lib/commandclass/TimeParametersCC.ts index 29f3b4571f7..b426a535c7b 100644 --- a/src/lib/commandclass/TimeParametersCC.ts +++ b/src/lib/commandclass/TimeParametersCC.ts @@ -85,12 +85,12 @@ function segmentsToDate(segments: DateSegments, local: boolean): Date { function dateToSegments(date: Date, local: boolean): DateSegments { return { - year: (date as any)[`get${local ? "" : "UTC"}FullYear`](), - month: (date as any)[`get${local ? "" : "UTC"}Month`]() + 1, - day: (date as any)[`get${local ? "" : "UTC"}Date`](), - hour: (date as any)[`get${local ? "" : "UTC"}Hours`](), - minute: (date as any)[`get${local ? "" : "UTC"}Minutes`](), - second: (date as any)[`get${local ? "" : "UTC"}Seconds`](), + year: (date as any)[`get${local ? "" : "UTC"}FullYear`]() as number, + month: ((date as any)[`get${local ? "" : "UTC"}Month`]() as number) + 1, + day: (date as any)[`get${local ? "" : "UTC"}Date`]() as number, + hour: (date as any)[`get${local ? "" : "UTC"}Hours`]() as number, + minute: (date as any)[`get${local ? "" : "UTC"}Minutes`]() as number, + second: (date as any)[`get${local ? "" : "UTC"}Seconds`]() as number, }; } diff --git a/src/lib/commandclass/VersionCC.ts b/src/lib/commandclass/VersionCC.ts index c7478ff1a27..9471035dfca 100644 --- a/src/lib/commandclass/VersionCC.ts +++ b/src/lib/commandclass/VersionCC.ts @@ -82,7 +82,7 @@ export class VersionCCAPI extends CCAPI { return super.supportsCommand(cmd); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get() { this.assertSupportsCommand(VersionCommand, VersionCommand.Get); @@ -116,7 +116,7 @@ export class VersionCCAPI extends CCAPI { return response.ccVersion; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getCapabilities() { this.assertSupportsCommand( VersionCommand, @@ -135,7 +135,7 @@ export class VersionCCAPI extends CCAPI { }; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getZWaveSoftware() { this.assertSupportsCommand( VersionCommand, diff --git a/src/lib/commandclass/WakeUpCC.ts b/src/lib/commandclass/WakeUpCC.ts index 33e0f9eac94..dd214662e06 100644 --- a/src/lib/commandclass/WakeUpCC.ts +++ b/src/lib/commandclass/WakeUpCC.ts @@ -76,7 +76,7 @@ export class WakeUpCCAPI extends CCAPI { await this.getInterval(); }; - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getInterval() { this.assertSupportsCommand(WakeUpCommand, WakeUpCommand.IntervalGet); @@ -93,7 +93,7 @@ export class WakeUpCCAPI extends CCAPI { }; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async getIntervalCapabilities() { this.assertSupportsCommand( WakeUpCommand, diff --git a/src/lib/commandclass/ZWavePlusCC.ts b/src/lib/commandclass/ZWavePlusCC.ts index 5b087a1b9ff..5282c416f78 100644 --- a/src/lib/commandclass/ZWavePlusCC.ts +++ b/src/lib/commandclass/ZWavePlusCC.ts @@ -68,7 +68,7 @@ export class ZWavePlusCCAPI extends CCAPI { return super.supportsCommand(cmd); } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async get() { this.assertSupportsCommand(ZWavePlusCommand, ZWavePlusCommand.Get); diff --git a/src/lib/commandclass/manufacturerProprietary/Fibaro.test.ts b/src/lib/commandclass/manufacturerProprietary/Fibaro.test.ts index 6b4ec6ed45c..be4520c1be0 100644 --- a/src/lib/commandclass/manufacturerProprietary/Fibaro.test.ts +++ b/src/lib/commandclass/manufacturerProprietary/Fibaro.test.ts @@ -179,6 +179,7 @@ describe("lib/commandclass/manufacturerProprietary/Fibaro => ", () => { // we expect an error, since there will be no response }); + // eslint-disable-next-line @typescript-eslint/unbound-method expect(fakeDriver.sendCommand).toHaveBeenCalledTimes(1); expect( (fakeDriver.sendCommand as jest.Mock).mock.calls[0][0], diff --git a/src/lib/config/Devices.ts b/src/lib/config/Devices.ts index 21078260c36..3e71b1a0dc7 100644 --- a/src/lib/config/Devices.ts +++ b/src/lib/config/Devices.ts @@ -244,7 +244,7 @@ paramInformation is not an object`, for (const [key, paramDefinition] of entries( definition.paramInformation, )) { - const match = key.match(/^(\d+)(?:\[0x([0-9a-fA-F]+)\])?$/); + const match = /^(\d+)(?:\[0x([0-9a-fA-F]+)\])?$/.exec(key); if (!match) { throwInvalidConfig( `device`, @@ -457,7 +457,7 @@ Parameter #${parameterNumber} has a non-string label`, if ( definition.description != undefined && - typeof definition.label !== "string" + typeof definition.description !== "string" ) { throwInvalidConfig( "devices", diff --git a/src/lib/config/Indicators.ts b/src/lib/config/Indicators.ts index 1617b692bc5..25dd869aa80 100644 --- a/src/lib/config/Indicators.ts +++ b/src/lib/config/Indicators.ts @@ -28,7 +28,7 @@ export async function loadIndicatorsInternal(): Promise<{ try { const fileContents = await readFile(configPath, "utf8"); - const definition = JSON5.parse(fileContents); + const definition = JSON5.parse(fileContents) as unknown; if (!isObject(definition)) { throwInvalidConfig("indicators", "the database is not an object"); } diff --git a/src/lib/config/Manufacturers.ts b/src/lib/config/Manufacturers.ts index f7f95953316..82b8f100b9c 100644 --- a/src/lib/config/Manufacturers.ts +++ b/src/lib/config/Manufacturers.ts @@ -20,7 +20,7 @@ export async function loadManufacturersInternal(): Promise { } try { const fileContents = await readFile(configPath, "utf8"); - const definition = JSON5.parse(fileContents); + const definition = JSON5.parse(fileContents) as unknown; if (!isObject(definition)) { throwInvalidConfig( "manufacturers", diff --git a/src/lib/config/Meters.ts b/src/lib/config/Meters.ts index 3f735840706..9c76702d59c 100644 --- a/src/lib/config/Meters.ts +++ b/src/lib/config/Meters.ts @@ -23,7 +23,7 @@ export async function loadMetersInternal(): Promise { try { const fileContents = await readFile(configPath, "utf8"); - const definition = JSON5.parse(fileContents); + const definition = JSON5.parse(fileContents) as unknown; if (!isObject(definition)) { throwInvalidConfig("meters", "the database is not an object"); } diff --git a/src/lib/config/Notifications.ts b/src/lib/config/Notifications.ts index 351a69f9883..9bd89d7db35 100644 --- a/src/lib/config/Notifications.ts +++ b/src/lib/config/Notifications.ts @@ -43,7 +43,7 @@ export async function loadNotificationsInternal(): Promise { try { const fileContents = await readFile(configPath, "utf8"); - const definition = JSON5.parse(fileContents); + const definition = JSON5.parse(fileContents) as unknown; if (!isObject(definition)) { throwInvalidConfig( "notifications", diff --git a/src/lib/config/Scales.ts b/src/lib/config/Scales.ts index ae49f9cc80a..c6991bf772f 100644 --- a/src/lib/config/Scales.ts +++ b/src/lib/config/Scales.ts @@ -25,7 +25,7 @@ export async function loadNamedScalesInternal(): Promise< try { const fileContents = await readFile(configPath, "utf8"); - const definition = JSON5.parse(fileContents); + const definition = JSON5.parse(fileContents) as unknown; if (!isObject(definition)) { throwInvalidConfig( "named scales", diff --git a/src/lib/config/SensorTypes.ts b/src/lib/config/SensorTypes.ts index c8edce1c3dc..e4d763eefce 100644 --- a/src/lib/config/SensorTypes.ts +++ b/src/lib/config/SensorTypes.ts @@ -24,7 +24,7 @@ export async function loadSensorTypesInternal(): Promise { try { const fileContents = await readFile(configPath, "utf8"); - const definition = JSON5.parse(fileContents); + const definition = JSON5.parse(fileContents) as unknown; if (!isObject(definition)) { throwInvalidConfig( "sensor types", diff --git a/src/lib/config/utils.ts b/src/lib/config/utils.ts index 80cd39882cd..151117bd77b 100644 --- a/src/lib/config/utils.ts +++ b/src/lib/config/utils.ts @@ -11,8 +11,8 @@ export const hexKeyRegex2Digits = /^0x[a-fA-F0-9]{2}$/; export function throwInvalidConfig(which: string, reason?: string): never { throw new ZWaveError( - `The ${which ? which + " " : ""}config file is malformed!` + reason - ? "\n" + reason + `The ${which ? which + " " : ""}config file is malformed!${reason}` + ? `\n${reason}` : "", ZWaveErrorCodes.Config_Invalid, ); diff --git a/src/lib/controller/ApplicationUpdateRequest.ts b/src/lib/controller/ApplicationUpdateRequest.ts index 55838603b5b..1ed5210e829 100644 --- a/src/lib/controller/ApplicationUpdateRequest.ts +++ b/src/lib/controller/ApplicationUpdateRequest.ts @@ -8,7 +8,6 @@ import { import { NodeUpdatePayload, parseNodeUpdatePayload } from "../node/NodeInfo"; import type { JSONObject } from "../util/misc"; -/* eslint-disable @typescript-eslint/camelcase */ export enum ApplicationUpdateTypes { NodeInfo_Received = 0x84, NodeInfo_RequestDone = 0x82, @@ -18,7 +17,6 @@ export enum ApplicationUpdateTypes { DeleteDone = 0x20, SUC_IdChanged = 0x10, } -/* eslint-enable @typescript-eslint/camelcase */ @messageTypes(MessageType.Request, FunctionType.ApplicationUpdateRequest) // this is only received, not sent! diff --git a/src/lib/controller/Controller.ts b/src/lib/controller/Controller.ts index daa0a8eb213..6b28a0815c5 100644 --- a/src/lib/controller/Controller.ts +++ b/src/lib/controller/Controller.ts @@ -991,7 +991,7 @@ export class ZWaveController extends EventEmitter { } // Do the heal process in the background - (async () => { + void (async () => { const tasks = [...this._healNetworkProgress] .filter(([, status]) => status === "pending") .map(async ([nodeId]) => { @@ -1725,7 +1725,7 @@ ${associatedNodes.join(", ")}`, nodes: composeObject( [...this.nodes.entries()].map( ([id, node]) => - [id.toString(), node.serialize()] as [string, object], + [id.toString(), node.serialize()] as [string, unknown], ), ), }; diff --git a/src/lib/controller/GetNodeProtocolInfoMessages.ts b/src/lib/controller/GetNodeProtocolInfoMessages.ts index 557a4f84929..fdd5ddd7e3c 100644 --- a/src/lib/controller/GetNodeProtocolInfoMessages.ts +++ b/src/lib/controller/GetNodeProtocolInfoMessages.ts @@ -21,7 +21,6 @@ import { import type { INodeQuery } from "../node/INodeQuery"; import type { JSONObject } from "../util/misc"; -/* eslint-disable @typescript-eslint/camelcase */ enum NodeCapabilityFlags { Listening = 0b10_000_000, Routing = 0b01_000_000, @@ -33,7 +32,6 @@ enum NodeCapabilityFlags { VersionMask = 0b111, } -/* eslint-enable @typescript-eslint/camelcase */ enum SecurityFlags { Security = 1 << 0, diff --git a/src/lib/driver/Driver.test.ts b/src/lib/driver/Driver.test.ts index 5487aa326a3..a4833a33673 100644 --- a/src/lib/driver/Driver.test.ts +++ b/src/lib/driver/Driver.test.ts @@ -73,7 +73,7 @@ describe("lib/driver/Driver => ", () => { const portInstance = MockSerialPort.getInstance(PORT_ADDRESS)!; portInstance.doOpen(); - await expect(startPromise); + await expect(startPromise).toResolve(); driver.destroy(); }); diff --git a/src/lib/driver/Driver.ts b/src/lib/driver/Driver.ts index 2bd973b795e..8793886f5f6 100644 --- a/src/lib/driver/Driver.ts +++ b/src/lib/driver/Driver.ts @@ -73,7 +73,7 @@ import type { ValueMetadata } from "../values/Metadata"; import type { FileSystem } from "./FileSystem"; import { MAX_SEND_ATTEMPTS, Transaction } from "./Transaction"; -// eslint-disable-next-line @typescript-eslint/no-var-requires +// eslint-disable-next-line const { version: libVersion } = require("../../../package.json"); // This is made with cfonts: const libNameString = ` @@ -410,12 +410,12 @@ export class Driver extends EventEmitter { }) .on("data", this.serialport_onData.bind(this)) .on("error", (err) => { - log.driver.print("serial port errored: " + err, "error"); + log.driver.print(`serial port errored: ${err}`, "error"); if (this._isOpen) { this.serialport_onError(err); } else { spOpenPromise.reject(err); - this.destroy(); + void this.destroy(); } }); this.serial.open(); @@ -578,7 +578,7 @@ export class Driver extends EventEmitter { node.id, setTimeout(() => { this.retryNodeInterviewTimeouts.delete(node.id); - this.interviewNode(node); + void this.interviewNode(node); }, retryTimeout).unref(), ); } else { @@ -605,7 +605,7 @@ export class Driver extends EventEmitter { } log.controller.logNode( node.id, - "Error during node interview: " + e, + `Error during node interview: ${e.message}`, "error", ); } else { @@ -687,7 +687,7 @@ export class Driver extends EventEmitter { } /** Checks if all nodes are ready and emits the "all nodes ready" event if they are */ - private async checkAllNodesReady(): Promise { + private checkAllNodesReady(): void { // Only emit "all nodes ready" once if (this._nodesReadyEventEmitted) return; @@ -860,7 +860,7 @@ export class Driver extends EventEmitter { } private _cleanupHandler = (): void => { - this.destroy(); + void this.destroy(); }; /** @@ -918,7 +918,6 @@ export class Driver extends EventEmitter { } } - // eslint-disable-next-line @typescript-eslint/camelcase private serialport_onError(err: Error): void { this.emit("error", err); } @@ -926,7 +925,6 @@ export class Driver extends EventEmitter { /** * Is called when the serial port has received any data */ - // eslint-disable-next-line @typescript-eslint/camelcase private async serialport_onData(data: Buffer): Promise { // append the new data to our receive buffer this.receiveBuffer = @@ -1437,7 +1435,7 @@ ${handlers.length} left`, await this.controller.removeFailedNode(msg.command.nodeId); } catch (e) { log.controller.logNode(msg.command.nodeId, { - message: "removing the node failed: " + e, + message: `removing the node failed: ${e}`, level: "error", }); } @@ -1882,7 +1880,9 @@ ${handlers.length} left`, // Check if the target supports this command if (!command.getNode()?.supportsCC(CommandClasses.Supervision)) { throw new ZWaveError( - `Node ${command.nodeId} does not support the Supervision CC!`, + `Node ${ + command.nodeId as number + } does not support the Supervision CC!`, ZWaveErrorCodes.CC_NotSupported, ); } @@ -2248,8 +2248,7 @@ ${handlers.length} left`, cacheFile, "utf8", ); - const cacheObj = JSON.parse(cacheString); - await this.controller.deserialize(cacheObj); + await this.controller.deserialize(JSON.parse(cacheString)); log.driver.print( `Restoring the network from cache was successful!`, ); @@ -2275,7 +2274,9 @@ ${handlers.length} left`, const sendNodeToSleep = (node: ZWaveNode): void => { this.sendNodeToSleepTimers.delete(node.id); if (!this.hasPendingMessages(node)) { - node.sendNoMoreInformation(); + void node.sendNoMoreInformation().catch(() => { + /* ignore errors */ + }); } }; diff --git a/src/lib/error/ZWaveError.ts b/src/lib/error/ZWaveError.ts index 6e090a54795..74b8385db33 100644 --- a/src/lib/error/ZWaveError.ts +++ b/src/lib/error/ZWaveError.ts @@ -1,5 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ - /** * Used to identify errors from this library without relying on the error message */ diff --git a/src/lib/log/index.ts b/src/lib/log/index.ts index bfb26a8d50d..4338f8a61d9 100644 --- a/src/lib/log/index.ts +++ b/src/lib/log/index.ts @@ -7,7 +7,7 @@ interface LogIndex { controller: typeof import("./Controller"); reflection: typeof import("./Reflection"); } -const logger: LogIndex = {} as any; +const logger = {} as LogIndex; Object.defineProperties(logger, { serial: { get() { diff --git a/src/lib/log/shared.ts b/src/lib/log/shared.ts index ac465d89ab8..0c60080f5af 100644 --- a/src/lib/log/shared.ts +++ b/src/lib/log/shared.ts @@ -36,7 +36,7 @@ export function shouldLogNode(nodeId: number): boolean { export type DataDirection = "inbound" | "outbound" | "none"; -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types export function getDirectionPrefix(direction: DataDirection) { return direction === "inbound" ? "« " @@ -205,13 +205,7 @@ export const logMessagePrinter: Format = { .join(" "); // The directional arrows and the optional grouping lines must be prepended // without adding spaces - firstLine = - info.timestamp + - " " + - info.label + - " " + - info.direction + - firstLine; + firstLine = `${info.timestamp} ${info.label} ${info.direction}${firstLine}`; const lines = [firstLine]; if (info.multiline) { // Format all message lines but the first diff --git a/src/lib/message/Constants.ts b/src/lib/message/Constants.ts index 0697e160475..4de1b40cbb2 100644 --- a/src/lib/message/Constants.ts +++ b/src/lib/message/Constants.ts @@ -1,5 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ - /** The priority of messages, sorted from high (0) to low (>0) */ export enum MessagePriority { // Controller commands are not to be interrupted and usually finish quickly @@ -24,7 +22,7 @@ export enum MessagePriority { // nothing else needs to be done Poll, } -export function isMessagePriority(val: any): val is MessagePriority { +export function isMessagePriority(val: unknown): val is MessagePriority { return typeof val === "number" && val in MessagePriority; } diff --git a/src/lib/message/Message.test.ts b/src/lib/message/Message.test.ts index a29df58e108..ced8e75a9e4 100644 --- a/src/lib/message/Message.test.ts +++ b/src/lib/message/Message.test.ts @@ -489,7 +489,7 @@ describe("lib/message", () => { controller: { nodes: new Map() }, } as any) as Driver; // @ts-ignore We need write access - fakeDriver.controller!.nodes.set(1, {} as any); + fakeDriver.controller.nodes.set(1, {} as any); const msg = new Message(fakeDriver, { type: MessageType.Request, @@ -499,7 +499,7 @@ describe("lib/message", () => { // This node exists ((msg as any) as INodeQuery).nodeId = 1; expect(msg.getNodeUnsafe()).toBe( - fakeDriver.controller!.nodes.get(1), + fakeDriver.controller.nodes.get(1), ); // This one does diff --git a/src/lib/message/Message.ts b/src/lib/message/Message.ts index 55c6e5ac281..4f57616b61e 100644 --- a/src/lib/message/Message.ts +++ b/src/lib/message/Message.ts @@ -30,7 +30,7 @@ export interface MessageDeserializationOptions { * Tests whether the given message constructor options contain a buffer for deserialization */ export function gotDeserializationOptions( - options: any, + options: Record | undefined, ): options is MessageDeserializationOptions { return options != undefined && Buffer.isBuffer(options.data); } @@ -252,7 +252,7 @@ export class Message { } private toJSONInternal(): JSONObject { - const ret: any = { + const ret: JSONObject = { name: this.constructor.name, type: MessageType[this.type], functionType: @@ -338,12 +338,10 @@ function computeChecksum(message: Buffer): number { // ======================= // use decorators to link function types to message classes -/* eslint-disable @typescript-eslint/camelcase */ const METADATA_messageTypes = Symbol("messageTypes"); const METADATA_messageTypeMap = Symbol("messageTypeMap"); const METADATA_expectedResponse = Symbol("expectedResponse"); const METADATA_priority = Symbol("priority"); -/* eslint-enable @typescript-eslint/camelcase */ type MessageTypeMap = Map>; interface MessageTypeMapEntry { @@ -396,8 +394,10 @@ export function messageTypes( ); // also store a map in the Message metadata for lookup. - const map: MessageTypeMap = - Reflect.getMetadata(METADATA_messageTypeMap, Message) || new Map(); + const map: MessageTypeMap = (Reflect.getMetadata( + METADATA_messageTypeMap, + Message, + ) || new Map()) as MessageTypeMap; map.set( getMessageTypeMapKey(messageType, functionType), (messageClass as any) as Constructable, @@ -415,10 +415,9 @@ export function getMessageType( // get the class constructor const constr = messageClass.constructor; // retrieve the current metadata - const meta: MessageTypeMapEntry | undefined = Reflect.getMetadata( - METADATA_messageTypes, - constr, - ); + const meta = Reflect.getMetadata(METADATA_messageTypes, constr) as + | MessageTypeMapEntry + | undefined; const ret = meta?.messageType; log.reflection.lookup(constr.name, "message type", num2hex(ret)); return ret; @@ -431,10 +430,10 @@ export function getMessageTypeStatic>( classConstructor: T, ): MessageType | undefined { // retrieve the current metadata - const meta: MessageTypeMapEntry | undefined = Reflect.getMetadata( + const meta = Reflect.getMetadata( METADATA_messageTypes, classConstructor, - ); + ) as MessageTypeMapEntry | undefined; const ret = meta?.messageType; log.reflection.lookup(classConstructor.name, "message type", num2hex(ret)); return ret; @@ -449,10 +448,9 @@ export function getFunctionType( // get the class constructor const constr = messageClass.constructor; // retrieve the current metadata - const meta: MessageTypeMapEntry | undefined = Reflect.getMetadata( - METADATA_messageTypes, - constr, - ); + const meta = Reflect.getMetadata(METADATA_messageTypes, constr) as + | MessageTypeMapEntry + | undefined; const ret = meta?.functionType; log.reflection.lookup(constr.name, "function type", num2hex(ret)); return ret; @@ -465,10 +463,10 @@ export function getFunctionTypeStatic>( classConstructor: T, ): FunctionType | undefined { // retrieve the current metadata - const meta: MessageTypeMapEntry | undefined = Reflect.getMetadata( + const meta = Reflect.getMetadata( METADATA_messageTypes, classConstructor, - ); + ) as MessageTypeMapEntry | undefined; const ret = meta?.functionType; log.reflection.lookup(classConstructor.name, "function type", num2hex(ret)); return ret; @@ -482,10 +480,10 @@ function getMessageConstructor( functionType: FunctionType, ): Constructable | undefined { // Retrieve the constructor map from the Message class - const functionTypeMap: MessageTypeMap | undefined = Reflect.getMetadata( + const functionTypeMap = Reflect.getMetadata( METADATA_messageTypeMap, Message, - ); + ) as MessageTypeMap | undefined; if (functionTypeMap != null) { return functionTypeMap.get( getMessageTypeMapKey(messageType, functionType), @@ -537,10 +535,10 @@ export function getExpectedResponse( // get the class constructor const constr = messageClass.constructor; // retrieve the current metadata - const ret: + const ret = Reflect.getMetadata(METADATA_expectedResponse, constr) as | FunctionType | ResponsePredicate - | undefined = Reflect.getMetadata(METADATA_expectedResponse, constr); + | undefined; if (typeof ret === "number") { log.reflection.lookup( constr.name, @@ -566,13 +564,10 @@ export function getExpectedResponseStatic>( classConstructor: T, ): FunctionType | ResponsePredicate | undefined { // retrieve the current metadata - const ret: - | FunctionType - | ResponsePredicate - | undefined = Reflect.getMetadata( + const ret = Reflect.getMetadata( METADATA_expectedResponse, classConstructor, - ); + ) as FunctionType | ResponsePredicate | undefined; if (typeof ret === "number") { log.reflection.lookup( classConstructor.name, @@ -619,10 +614,9 @@ export function getDefaultPriority( // get the class constructor const constr = messageClass.constructor; // retrieve the current metadata - const ret: MessagePriority | undefined = Reflect.getMetadata( - METADATA_priority, - constr, - ); + const ret = Reflect.getMetadata(METADATA_priority, constr) as + | MessagePriority + | undefined; if (ret) { log.reflection.lookup( constr.name, @@ -642,10 +636,9 @@ export function getDefaultPriorityStatic>( classConstructor: T, ): MessagePriority | undefined { // retrieve the current metadata - const ret: MessagePriority | undefined = Reflect.getMetadata( - METADATA_priority, - classConstructor, - ); + const ret = Reflect.getMetadata(METADATA_priority, classConstructor) as + | MessagePriority + | undefined; if (ret) { log.reflection.lookup( classConstructor.name, diff --git a/src/lib/node/INodeQuery.ts b/src/lib/node/INodeQuery.ts index 1314e9481a6..5083abccdf1 100644 --- a/src/lib/node/INodeQuery.ts +++ b/src/lib/node/INodeQuery.ts @@ -6,5 +6,6 @@ export interface INodeQuery { /** Tests if the given message is for a node or references a node */ export function isNodeQuery(msg: T): msg is T & INodeQuery { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access return typeof (msg as any).nodeId === "number"; } diff --git a/src/lib/node/Node.test.ts b/src/lib/node/Node.test.ts index ef5f685348b..b10e4be3d3a 100644 --- a/src/lib/node/Node.test.ts +++ b/src/lib/node/Node.test.ts @@ -486,10 +486,10 @@ describe("lib/node/Node", () => { interviewCCs: true, }; originalMethods = { - queryProtocolInfo: node.queryProtocolInfo, - queryNodeInfo: node.queryNodeInfo, - interviewCCs: node.interviewCCs, - queryNeighbors: node.queryNeighbors, + queryProtocolInfo: node.queryProtocolInfo.bind(node), + queryNodeInfo: node.queryNodeInfo.bind(node), + interviewCCs: node.interviewCCs.bind(node), + queryNeighbors: node.queryNeighbors.bind(node), }; for (const method of Object.keys( originalMethods, @@ -902,7 +902,7 @@ describe("lib/node/Node", () => { it("serializing a deserialized node should result in the original object", () => { const node = new ZWaveNode(1, fakeDriver); // @ts-ignore We need write access to the map - fakeDriver.controller!.nodes.set(1, node); + fakeDriver.controller.nodes.set(1, node); node.deserialize(serializedTestNode); expect(node.serialize()).toEqual(serializedTestNode); }); @@ -910,7 +910,7 @@ describe("lib/node/Node", () => { it("nodes with a completed interview don't get their stage reset when resuming from cache", () => { const node = new ZWaveNode(1, fakeDriver); // @ts-ignore We need write access to the map - fakeDriver.controller!.nodes.set(1, node); + fakeDriver.controller.nodes.set(1, node); node.deserialize(serializedTestNode); node.interviewStage = InterviewStage.RestartFromCache; expect(node.serialize().interviewStage).toEqual( @@ -946,7 +946,7 @@ describe("lib/node/Node", () => { const node = new ZWaveNode(1, fakeDriver); // @ts-ignore We need write access to the map - fakeDriver.controller!.nodes.set(1, node); + fakeDriver.controller.nodes.set(1, node); node.deserialize(input); expect( @@ -1351,7 +1351,7 @@ describe("lib/node/Node", () => { beforeEach(() => { node = new ZWaveNode(1, (fakeDriver as unknown) as Driver); - fakeDriver.controller!.nodes.set(1, node); + fakeDriver.controller.nodes.set(1, node); }); it("returns the defined metadata for the given value", () => { diff --git a/src/lib/node/Node.ts b/src/lib/node/Node.ts index b93c6e822b0..f8101459ee1 100644 --- a/src/lib/node/Node.ts +++ b/src/lib/node/Node.ts @@ -1,4 +1,4 @@ -import type { Comparer } from "alcalzone-shared/comparable"; +import type { Comparer, CompareResult } from "alcalzone-shared/comparable"; import { padStart } from "alcalzone-shared/strings"; import { isArray, isObject } from "alcalzone-shared/typeguards"; import { EventEmitter } from "events"; @@ -482,6 +482,7 @@ export class ZWaveNode extends Endpoint { // Access the CC API by name const endpointInstance = this.getEndpoint(valueId.endpoint || 0); if (!endpointInstance) return false; + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access const api = (endpointInstance.commandClasses as any)[ valueId.commandClass ] as CCAPI; @@ -854,7 +855,7 @@ version: ${this.version}`; direction: "inbound", }); } catch (e) { - log.controller.logNode(this.id, "ping failed: " + e.message); + log.controller.logNode(this.id, `ping failed: ${e.message}`); return false; } } @@ -1070,7 +1071,7 @@ version: ${this.version}`; const cc1IsApplicationCC = applicationCCs.includes(cc1); const cc2IsApplicationCC = applicationCCs.includes(cc2); return ((cc1IsApplicationCC ? 1 : 0) - - (cc2IsApplicationCC ? 1 : 0)) as any; + (cc2IsApplicationCC ? 1 : 0)) as CompareResult; }; try { rootInterviewOrder = topologicalSort( @@ -1189,7 +1190,7 @@ version: ${this.version}`; log.controller.logNode(this.nodeId, { message: `Node does not send unsolicited updates, refreshing actuator and sensor values...`, }); - this.refreshValues(); + void this.refreshValues(); } } @@ -1243,7 +1244,7 @@ version: ${this.version}`; this.manualRefreshTimers.set( cc, setInterval(() => { - this.refreshCCValues(cc); + void this.refreshCCValues(cc); }, timeout).unref(), ); } @@ -1367,7 +1368,7 @@ version: ${this.version}`; * @internal * Handles a CommandClass that was received from this node */ - public async handleCommand(command: CommandClass): Promise { + public handleCommand(command: CommandClass): Promise | void { // If the node sent us an unsolicited update, our initial assumption // was wrong. Stop querying it regularly for updates this.cancelManualValueRefresh(command.ccId); @@ -1439,9 +1440,9 @@ version: ${this.version}`; private lastCentralSceneNotificationSequenceNumber: number | undefined; /** Handles the receipt of a Central Scene notifification */ - private async handleCentralSceneNotification( + private handleCentralSceneNotification( command: CentralSceneCCNotification, - ): Promise { + ): void { // Did we already receive this command? if ( command.sequenceNumber === @@ -1594,6 +1595,7 @@ version: ${this.version}`; // Try to access the API - if it doesn't work, skip this option let API: CCAPI; try { + // eslint-disable-next-line API = (this.commandClasses as any)[ccName]; } catch { log.controller.logNode(this.id, { @@ -1610,6 +1612,7 @@ version: ${this.version}`; level: "warn", }); continue; + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access } else if (!(API as any)[apiMethod]) { log.controller.logNode(this.id, { message: `method ${apiMethod} not found on API, skipping query`, @@ -1620,6 +1623,7 @@ version: ${this.version}`; } // Retrieve the method + // eslint-disable-next-line const method = (API as any)[apiMethod].bind(API) as Function; // And replace "smart" arguments with their corresponding value const methodArgs = args.map((arg) => { @@ -1651,7 +1655,7 @@ version: ${this.version}`; } /** Handles the receipt of a BasicCC Set or Report */ - private async handleBasicCommand(command: BasicCC): Promise { + private handleBasicCommand(command: BasicCC): void { // Retrieve the endpoint the command is coming from const sourceEndpoint = this.getEndpoint(command.endpointIndex ?? 0) ?? this; @@ -1981,26 +1985,27 @@ version: ${this.version}`; for (const cc of sortedCCs) { const serializedCC = { name: CommandClasses[cc], - endpoints: {} as JSONObject, - } as JSONObject; + endpoints: {} as Record, + }; // We store the support and version information in this location rather than in the version CC // Therefore request the information from all endpoints for (const endpoint of this.getAllEndpoints()) { if (endpoint.implementedCommandClasses.has(cc)) { serializedCC.endpoints[ - endpoint.index - ] = endpoint.implementedCommandClasses.get(cc); + endpoint.index.toString() + ] = endpoint.implementedCommandClasses.get(cc)!; } } - ret.commandClasses[num2hex(cc)] = serializedCC; + ret.commandClasses[num2hex(cc)] = serializedCC as any; } - return ret; + return (ret as any) as JSONObject; } /** * @internal * Deserializes the information of this node from a cache. */ + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async deserialize(obj: any): Promise { if (obj.interviewStage in InterviewStage) { this.interviewStage = diff --git a/src/lib/node/ValueDB.ts b/src/lib/node/ValueDB.ts index 506da809da6..47fc9f6cdf4 100644 --- a/src/lib/node/ValueDB.ts +++ b/src/lib/node/ValueDB.ts @@ -42,7 +42,7 @@ interface ValueDBEventCallbacks { type ValueDBEvents = Extract; -export function isValueID(param: any): param is ValueID { +export function isValueID(param: Record): param is ValueID { // commandClass is mandatory and must be numeric if (typeof param.commandClass !== "number") return false; // property is mandatory and must be a number or string @@ -67,7 +67,9 @@ export function isValueID(param: any): param is ValueID { return true; } -export function assertValueID(param: any): asserts param is ValueID { +export function assertValueID( + param: Record, +): asserts param is ValueID { if (!isValueID(param)) { throw new ZWaveError( `Invalid ValueID passed!`, @@ -107,13 +109,13 @@ export function normalizeValueID(valueID: ValueID): ValueID { assertValueID(valueID); const { commandClass, endpoint, property, propertyKey } = valueID; - const jsonKey: Record = { + const jsonKey: ValueID = { commandClass, endpoint: endpoint ?? 0, property, }; if (propertyKey != undefined) jsonKey.propertyKey = propertyKey; - return jsonKey as any; + return jsonKey; } export function valueIdToString(valueID: ValueID): string { @@ -155,6 +157,7 @@ export class ValueDB extends EventEmitter { } private dbKeyToValueId(key: string): { nodeId: number } & ValueID { + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return JSON.parse(key); } diff --git a/src/lib/util/ObjectKeyMap.ts b/src/lib/util/ObjectKeyMap.ts index c16b30f310c..57779df774a 100644 --- a/src/lib/util/ObjectKeyMap.ts +++ b/src/lib/util/ObjectKeyMap.ts @@ -5,7 +5,6 @@ export class ObjectKeyMap, TValue> { entries?: [TKey, TValue][], defaultKeyProps?: Partial, ) { - this._map = new Map(); if (entries?.length) { for (const [key, value] of entries) { this.set(key, value); @@ -14,7 +13,7 @@ export class ObjectKeyMap, TValue> { this.defaultKeyProps = defaultKeyProps; } - private _map: Map; + private _map = new Map(); private defaultKeyProps: Partial | undefined; public has(key: TKey): boolean { @@ -51,10 +50,12 @@ export class ObjectKeyMap, TValue> { public entries(): IterableIterator<[TKey, TValue]> { const map = this._map; + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types return (function* () { const _entries = map.entries(); let entry = _entries.next(); while (!entry.done) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const objKey = JSON.parse(entry.value[0]); yield [objKey, entry.value[1]] as [TKey, TValue]; entry = _entries.next(); @@ -64,6 +65,7 @@ export class ObjectKeyMap, TValue> { public keys(): IterableIterator { const map = this._map; + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types return (function* () { const _keys = map.entries(); let key = _keys.next(); @@ -83,6 +85,7 @@ export class ObjectKeyMap, TValue> { const filledKey = { ...key }; if (this.defaultKeyProps) { for (const [required, def] of entries(this.defaultKeyProps)) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access if (!(required in filledKey)) filledKey[required as any] = def; } } diff --git a/src/lib/util/misc.ts b/src/lib/util/misc.ts index 6c173f7cb0c..ea8d9ec3702 100644 --- a/src/lib/util/misc.ts +++ b/src/lib/util/misc.ts @@ -8,15 +8,16 @@ export function isConsecutiveArray(values: number[]): boolean { } export type JSONObject = Record; +type Constructor = new (...args: any[]) => any; /** Tests if base is in the super chain of `constructor` */ export function staticExtends any>( - constructor: any, + constructor: unknown, base: T, ): constructor is T { while (constructor) { if (constructor === base) return true; - constructor = Object.getPrototypeOf(constructor); + constructor = Object.getPrototypeOf(constructor) as unknown; } return false; } @@ -45,12 +46,13 @@ export function validatePayload(...assertions: unknown[]): void { /** Decorator to support multi-inheritance using mixins */ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -export function Mixin(baseCtors: Function[]) { - return function (derivedCtor: Function): void { +export function Mixin(baseCtors: Constructor[]) { + return function (derivedCtor: Constructor): void { baseCtors.forEach((baseCtor) => { Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => { // Do not override the constructor if (name !== "constructor") { + // eslint-disable-next-line derivedCtor.prototype[name] = baseCtor.prototype[name]; } }); @@ -61,6 +63,7 @@ export function Mixin(baseCtors: Function[]) { export type DeepPartial = { [P in keyof T]+?: DeepPartial }; export function getEnumMemberName(enumeration: unknown, value: number): string { + // eslint-disable-next-line return (enumeration as any)[value] || `unknown (${num2hex(value)})`; } @@ -96,11 +99,11 @@ export function keysOf(obj: T): (keyof T)[] { } /** Returns a subset of `obj` that contains only the given keys */ -export function pick( +export function pick, K extends keyof T>( obj: T, keys: K[], ): Pick { - const ret = {} as any; + const ret = {} as Pick; for (const key of keys) { if (key in obj) ret[key] = obj[key]; } diff --git a/src/lib/util/strings.ts b/src/lib/util/strings.ts index 7ddfc52d608..d208e46e5af 100644 --- a/src/lib/util/strings.ts +++ b/src/lib/util/strings.ts @@ -16,6 +16,6 @@ export function num2hex( return "0x" + ret; } -export function stringify(arg: any): string { +export function stringify(arg: unknown): string { return JSON.stringify(arg, null, 4); } diff --git a/src/lib/values/Cache.ts b/src/lib/values/Cache.ts index bfb6ab5d373..a7ee8f3a1bd 100644 --- a/src/lib/values/Cache.ts +++ b/src/lib/values/Cache.ts @@ -56,12 +56,14 @@ export function serializeCacheValue(value: unknown): SerializedValue { /** Deserializes a value that was serialized by serializeCacheValue */ export function deserializeCacheValue(value: SerializedValue): unknown { if (isObject(value)) { - const specialType = (value as Record)[SPECIAL_TYPE_KEY]; + const specialType = (value as Record)[ + SPECIAL_TYPE_KEY + ]; // Convert objects which used to be a map back to a Map if (specialType === "map") { const { [SPECIAL_TYPE_KEY]: _, ...rest } = value as Record< any, - any + SerializedValue >; return new Map( entries(rest) diff --git a/src/lib/values/Primitive.ts b/src/lib/values/Primitive.ts index 926459bce3b..745428ed28a 100644 --- a/src/lib/values/Primitive.ts +++ b/src/lib/values/Primitive.ts @@ -94,6 +94,7 @@ export function getIntegerLimits( size: 1 | 2 | 3 | 4, signed: boolean, ): { min: number; max: number } { + // eslint-disable-next-line return (IntegerLimits as any)[`${signed ? "" : "U"}Int${size * 8}`]; }