From 2a27b1d51f4d82ff79ca7ed2c5e36d981a400c44 Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Sun, 26 May 2019 18:51:58 +0100 Subject: [PATCH] Move to resin-lint 3 and fix lint errors This is a massive commit, but nothing related to runtime has actually changed, only the lint errors have changed. Change-type: patch Signed-off-by: Cameron Diver --- package-lock.json | 245 ++++++++++++++++++++++----------- package.json | 4 +- src/api-binder.ts | 6 +- src/application-manager.d.ts | 6 +- src/compose/images.ts | 4 +- src/compose/service-manager.ts | 4 +- src/compose/service.ts | 4 +- src/compose/utils.ts | 2 +- src/config/index.ts | 12 +- src/config/types.ts | 8 +- src/device-api/v2.ts | 4 +- src/device-config.ts | 4 +- src/lib/conversions.ts | 2 +- src/lib/fs-utils.ts | 6 +- src/local-mode.ts | 6 +- src/logging/balena-backend.ts | 2 +- src/logging/container.ts | 4 +- src/logging/local-backend.ts | 6 +- tslint.json | 3 + typings/dbus-native.d.ts | 4 +- typings/docker-delta.d.ts | 2 +- typings/duration-js.d.ts | 1 + typings/global.d.ts | 4 +- 23 files changed, 213 insertions(+), 130 deletions(-) create mode 100644 tslint.json diff --git a/package-lock.json b/package-lock.json index 322a7360..4eae4b79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,63 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", + "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", + "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "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==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, "@iamstarkov/listr-update-renderer": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@iamstarkov/listr-update-renderer/-/listr-update-renderer-0.4.1.tgz", @@ -269,14 +326,14 @@ }, "@types/optimist": { "version": "0.0.29", - "resolved": "http://registry.npmjs.org/@types/optimist/-/optimist-0.0.29.tgz", + "resolved": "https://registry.npmjs.org/@types/optimist/-/optimist-0.0.29.tgz", "integrity": "sha1-qIc1gLOoS2msHmhzI7Ffu+uQR5o=", "dev": true }, "@types/prettier": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-1.15.2.tgz", - "integrity": "sha512-XIB0ZCaFZmWUHAa9dBqP5UKXXHwuukmVlP+XcyU94dui2k+l2lG+CHAbt2ffenHPUqoIs5Beh8Pdf2YEq/CZ7A==", + "version": "1.16.4", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-1.16.4.tgz", + "integrity": "sha512-MG7ExKBo7AQ5UrL1awyYLNinNM/kyXgE4iP4Ul9fB+T7n768Z5Xem8IZeP6Bna0xze8gkDly49Rgge2HOEw4xA==", "dev": true }, "@types/range-parser": { @@ -1881,18 +1938,6 @@ "string-width": "^1.0.1", "strip-ansi": "^3.0.1", "wrap-ansi": "^2.0.0" - }, - "dependencies": { - "wrap-ansi": { - "version": "2.1.0", - "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", - "dev": true, - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" - } - } } }, "clone": { @@ -1931,7 +1976,7 @@ "dependencies": { "coffee-script": { "version": "1.11.1", - "resolved": "http://registry.npmjs.org/coffee-script/-/coffee-script-1.11.1.tgz", + "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.11.1.tgz", "integrity": "sha1-vxxHrWREOg2V0S3ysUfMCk2q1uk=", "dev": true }, @@ -3731,14 +3776,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3753,20 +3796,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -3883,8 +3923,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -3896,7 +3935,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3911,7 +3949,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3919,14 +3956,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3945,7 +3980,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -4026,8 +4060,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -4039,7 +4072,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -4161,7 +4193,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -6302,7 +6333,7 @@ }, "load-json-file": { "version": "2.0.0", - "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", "dev": true, "requires": { @@ -6323,7 +6354,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true } @@ -7524,7 +7555,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", "dev": true } @@ -8189,7 +8220,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, @@ -8323,7 +8354,7 @@ }, "require-npm4-to-publish": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/require-npm4-to-publish/-/require-npm4-to-publish-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/require-npm4-to-publish/-/require-npm4-to-publish-1.0.0.tgz", "integrity": "sha1-5Z7D5ikQFT3Fu90MpA20IrLE2ec=", "dev": true, "requires": { @@ -8436,18 +8467,18 @@ } }, "resin-lint": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/resin-lint/-/resin-lint-2.0.1.tgz", - "integrity": "sha512-gH+HZyK9ctksCX7xt4g86+sl2ae/5SPS0H81ukbYAy8eNuDuOeCHuspF66CDtxi607xE13d/ei7opcBkIK8/LA==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/resin-lint/-/resin-lint-3.0.4.tgz", + "integrity": "sha512-TVxY7SaJqQRZcLubJn5yO49db/M4eRXRr7FbA4xwqSYxQSqujNql8ThMoNMoRrx+1F7NrfSdhIsLEaMqCea4VA==", "dev": true, "requires": { - "@types/bluebird": "^3.5.20", + "@types/bluebird": "^3.5.26", "@types/depcheck": "^0.6.0", "@types/glob": "^5.0.35", - "@types/node": "^8.5.2", + "@types/node": "^8.10.45", "@types/optimist": "0.0.29", - "@types/prettier": "^1.13.2", - "bluebird": "^3.5.0", + "@types/prettier": "^1.16.1", + "bluebird": "^3.5.4", "coffee-script": "^1.10.0", "coffeelint": "^1.15.0", "coffeescope2": "^0.4.5", @@ -8455,16 +8486,29 @@ "glob": "^7.0.3", "merge": "^1.2.0", "optimist": "^0.6.1", - "prettier": "^1.14.2", - "tslint": "^5.8.0", - "tslint-config-prettier": "^1.15.0", - "typescript": "^2.6.2" + "prettier": "^1.16.4", + "tslint": "^5.15.0", + "tslint-config-prettier": "^1.18.0", + "tslint-no-unused-expression-chai": "^0.1.4", + "typescript": "^3.4.3" }, "dependencies": { + "@types/bluebird": { + "version": "3.5.27", + "resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.27.tgz", + "integrity": "sha512-6BmYWSBea18+tSjjSC3QIyV93ZKAeNWGM7R6aYt1ryTZXrlHF+QLV0G2yV0viEGVyRkyQsWfMoJ0k/YghBX5sQ==", + "dev": true + }, "@types/node": { - "version": "8.10.38", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.38.tgz", - "integrity": "sha512-EibsnbJerd0hBFaDjJStFrVbVBAtOy4dgL8zZFw0uOvPqzBAX59Ci8cgjg3+RgJIWhsB5A4c+pi+D4P9tQQh/A==", + "version": "8.10.48", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.48.tgz", + "integrity": "sha512-c35YEBTkL4rzXY2ucpSKy+UYHjUBIIkuJbWYbsGIrKLEWU5dgJMmLkkIb3qeC3O3Tpb1ZQCwecscvJTDjDjkRw==", + "dev": true + }, + "bluebird": { + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", + "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==", "dev": true }, "coffee-script": { @@ -8473,10 +8517,16 @@ "integrity": "sha512-fLeEhqwymYat/MpTPUjSKHVYYl0ec2mOyALEMLmzr5i1isuG+6jfI2j2d5oBO3VIzgUXgBVIcOT9uH1TFxBckw==", "dev": true }, + "prettier": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.17.1.tgz", + "integrity": "sha512-TzGRNvuUSmPgwivDqkZ9tM/qTGW9hqDKWOE9YHiyQdixlKbv7kvEqsmDPrcHJTKwthU774TQwZXVtaQ/mMsvjg==", + "dev": true + }, "typescript": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", - "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "version": "3.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.5.tgz", + "integrity": "sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==", "dev": true } } @@ -9897,23 +9947,24 @@ "dev": true }, "tslint": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.11.0.tgz", - "integrity": "sha1-mPMMAurjzecAYgHkwzywi0hYHu0=", + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.16.0.tgz", + "integrity": "sha512-UxG2yNxJ5pgGwmMzPMYh/CCnCnh0HfPgtlVRDs1ykZklufFBL1ZoTlWFRz2NQjcoEiDoRp+JyT0lhBbbH/obyA==", "dev": true, "requires": { - "babel-code-frame": "^6.22.0", + "@babel/code-frame": "^7.0.0", "builtin-modules": "^1.1.1", "chalk": "^2.3.0", "commander": "^2.12.1", "diff": "^3.2.0", "glob": "^7.1.1", - "js-yaml": "^3.7.0", + "js-yaml": "^3.13.0", "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", "resolve": "^1.3.2", "semver": "^5.3.0", "tslib": "^1.8.0", - "tsutils": "^2.27.2" + "tsutils": "^2.29.0" }, "dependencies": { "ansi-styles": { @@ -9926,9 +9977,9 @@ } }, "chalk": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", - "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, "requires": { "ansi-styles": "^3.2.1", @@ -9936,13 +9987,23 @@ "supports-color": "^5.3.0" } }, - "resolve": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", - "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { - "path-parse": "^1.0.5" + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "resolve": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.0.tgz", + "integrity": "sha512-WL2pBDjqT6pGUNSUzMw00o4T7If+z4H2x3Gz893WoUQ5KW8Vr9txp00ykiP16VBaZF5+j/OcXJHZ9+PCvdiDKw==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" } }, "supports-color": { @@ -9957,11 +10018,31 @@ } }, "tslint-config-prettier": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.17.0.tgz", - "integrity": "sha512-NKWNkThwqE4Snn4Cm6SZB7lV5RMDDFsBwz6fWUkTxOKGjMx8ycOHnjIbhn7dZd5XmssW3CwqUjlANR6EhP9YQw==", + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz", + "integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==", "dev": true }, + "tslint-no-unused-expression-chai": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/tslint-no-unused-expression-chai/-/tslint-no-unused-expression-chai-0.1.4.tgz", + "integrity": "sha512-frEWKNTcq7VsaWKgUxMDOB2N/cmQadVkUtUGIut+2K4nv/uFXPfgJyPjuNC/cHyfUVqIkHMAvHOCL+d/McU3nQ==", + "dev": true, + "requires": { + "tsutils": "^3.0.0" + }, + "dependencies": { + "tsutils": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.10.0.tgz", + "integrity": "sha512-q20XSMq7jutbGB8luhKKsQldRKWvyBO2BGqni3p4yq8Ys9bEP/xQw3KepKmMRt9gJ4lvQSScrihJrcKdKoSU7Q==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + } + } + }, "tsutils": { "version": "2.29.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", @@ -11316,6 +11397,16 @@ "errno": "~0.1.7" } }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index 36001c09..b8835314 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "test:debug": "npm run test:build && mocha --inspect-brk", "coverage": "istanbul report text && istanbul report html" }, - "private": "true", + "private": true, "dependencies": { "sqlite3": "^4.0.8" }, @@ -89,7 +89,7 @@ "prettier": "^1.15.3", "pretty-ms": "^4.0.0", "request": "^2.51.0", - "resin-lint": "^2.0.1", + "resin-lint": "^3.0.0", "resin-register-device": "^3.0.0", "resumable-request": "^2.0.0", "rimraf": "^2.6.2", diff --git a/src/api-binder.ts b/src/api-binder.ts index c06fadc7..c36ce534 100644 --- a/src/api-binder.ts +++ b/src/api-binder.ts @@ -737,13 +737,13 @@ export class APIBinder { // If we have an existing device key we first check if it's // valid, becaise of it is we can just use that if (opts.deviceApiKey != null) { - const device = await this.fetchDevice( + const deviceFromApi = await this.fetchDevice( uuid, opts.deviceApiKey, apiTimeout, ); - if (device != null) { - return device; + if (deviceFromApi != null) { + return deviceFromApi; } } diff --git a/src/application-manager.d.ts b/src/application-manager.d.ts index 8c2bc342..b3100a91 100644 --- a/src/application-manager.d.ts +++ b/src/application-manager.d.ts @@ -2,17 +2,17 @@ import * as Bluebird from 'bluebird'; import { EventEmitter } from 'events'; import { ServiceAction } from './device-api/common'; -import { DeviceApplicationState } from './types/state'; -import { Logger } from './logger'; import { EventTracker } from './event-tracker'; +import { Logger } from './logger'; +import { DeviceApplicationState } from './types/state'; import Images from './compose/images'; import ServiceManager from './compose/service-manager'; import DB from './db'; +import { APIBinder } from './api-binder'; import { Service } from './compose/service'; import Config from './config'; -import { APIBinder } from './api-binder'; declare interface Options { force?: boolean; diff --git a/src/compose/images.ts b/src/compose/images.ts index 375cba4d..e57028e6 100644 --- a/src/compose/images.ts +++ b/src/compose/images.ts @@ -60,9 +60,7 @@ type NormalisedDockerImage = Docker.ImageInfo & { NormalisedRepoTags: string[]; }; -export class Images extends (EventEmitter as { - new (): ImageEventEmitter; -}) { +export class Images extends (EventEmitter as new () => ImageEventEmitter) { private docker: DockerUtils; private logger: Logger; private db: Database; diff --git a/src/compose/service-manager.ts b/src/compose/service-manager.ts index 6cc78ad2..7f6968fd 100644 --- a/src/compose/service-manager.ts +++ b/src/compose/service-manager.ts @@ -41,9 +41,7 @@ interface KillOpts { wait?: boolean; } -export class ServiceManager extends (EventEmitter as { - new (): ServiceManagerEventEmitter; -}) { +export class ServiceManager extends (EventEmitter as new () => ServiceManagerEventEmitter) { private docker: Docker; private logger: Logger; private config: Config; diff --git a/src/compose/service.ts b/src/compose/service.ts index dd68c8e7..6154f834 100644 --- a/src/compose/service.ts +++ b/src/compose/service.ts @@ -654,8 +654,8 @@ export class Service { sameConfig && _.every(Service.configArrayFields, (field: keyof ServiceConfig) => { const eq = _.isEqual( - _.sortBy(this.config[field] as Array), - _.sortBy(service.config[field] as Array), + _.sortBy(this.config[field] as unknown[]), + _.sortBy(service.config[field] as unknown[]), ); if (!eq) { differentArrayFields.push(field); diff --git a/src/compose/utils.ts b/src/compose/utils.ts index ec2c7866..c8854f9e 100644 --- a/src/compose/utils.ts +++ b/src/compose/utils.ts @@ -26,7 +26,7 @@ export function camelCaseConfig( if (!_.isArray(config.networks)) { const networksTmp = _.cloneDeep(config.networks); _.each(networksTmp, (v, k) => { - config.networks[k] = _.mapKeys(v, (_v, k) => _.camelCase(k)); + config.networks[k] = _.mapKeys(v, (_v, key) => _.camelCase(key)); }); } diff --git a/src/config/index.ts b/src/config/index.ts index c122ad3f..48019f11 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -37,9 +37,7 @@ interface ConfigEvents { type ConfigEventEmitter = StrictEventEmitter; -export class Config extends (EventEmitter as { - new (): ConfigEventEmitter; -}) { +export class Config extends (EventEmitter as new () => ConfigEventEmitter) { private db: DB; private configJsonBackend: ConfigJsonConfigBackend; @@ -76,10 +74,12 @@ export class Config extends (EventEmitter as { // schema key is for the meta nullOrUndefined value. We check this // by first decoding the value undefined with the default type, and // then return undefined - const decoded = (defaultValue as t.Type).decode(undefined); + const maybeDecoded = (defaultValue as t.Type).decode( + undefined, + ); - this.checkValueDecode(decoded, key, undefined); - return decoded.value; + this.checkValueDecode(maybeDecoded, key, undefined); + return maybeDecoded.value; } return defaultValue as SchemaReturn; } diff --git a/src/config/types.ts b/src/config/types.ts index e28215ee..4335ffd0 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -76,7 +76,7 @@ export const PermissiveNumber = new t.Type( // Define this differently, so that we can add a generic to it export class StringJSON extends t.Type { - readonly _tag: 'StringJSON' = 'StringJSON'; + public readonly _tag: 'StringJSON' = 'StringJSON'; constructor(type: t.InterfaceType) { super( 'StringJSON', @@ -102,12 +102,6 @@ export class StringJSON extends t.Type { ); }, ); - // super( - // 'string', - // (m): m is string => typeof m === 'string', - // (m, c) => (this.is(m) ? t.success(m) : t.failure(m, c)), - // t.identity, - // ); } } diff --git a/src/device-api/v2.ts b/src/device-api/v2.ts index 72c6385a..5d82a7e5 100644 --- a/src/device-api/v2.ts +++ b/src/device-api/v2.ts @@ -198,8 +198,8 @@ export function createV2Api(router: Router, applications: ApplicationManager) { return; } - const svc = _.find(services, (svc: Service) => { - return svc.imageId === img.imageId; + const svc = _.find(services, (service: Service) => { + return service.imageId === img.imageId; }); let status: string; diff --git a/src/device-config.ts b/src/device-config.ts index 5cf2a7f7..7572cb00 100644 --- a/src/device-config.ts +++ b/src/device-config.ts @@ -131,7 +131,7 @@ export class DeviceConfig { }, }; - static validKeys = [ + public static validKeys = [ 'SUPERVISOR_VPN_CONTROL', 'OVERRIDE_LOCK', ..._.map(DeviceConfig.configKeys, 'envVarName'), @@ -292,7 +292,7 @@ export class DeviceConfig { SUPERVISOR_VPN_CONTROL: vpnStatus != null ? vpnStatus.toString() : 'true', }; - for (const key in DeviceConfig.configKeys) { + for (const key of _.keys(DeviceConfig.configKeys)) { const { envVarName } = DeviceConfig.configKeys[key]; const confValue = conf[key as SchemaTypeKey]; currentConf[envVarName] = confValue != null ? confValue.toString() : ''; diff --git a/src/lib/conversions.ts b/src/lib/conversions.ts index 4be0aa8a..4bb2d652 100644 --- a/src/lib/conversions.ts +++ b/src/lib/conversions.ts @@ -17,7 +17,7 @@ export function envArrayToObject(env: string[]): EnvVarObject { return _(env) .map(toPair) - .filter(([_, v]) => v != null) + .filter(([_k, v]) => v != null) .fromPairs() .value(); } diff --git a/src/lib/fs-utils.ts b/src/lib/fs-utils.ts index d1ab50f1..d598b195 100644 --- a/src/lib/fs-utils.ts +++ b/src/lib/fs-utils.ts @@ -1,6 +1,6 @@ import * as Bluebird from 'bluebird'; import { fs } from 'mz'; -import * as path from 'path'; +import * as Path from 'path'; import * as constants from './constants'; import { ENOENT } from './errors'; @@ -20,13 +20,13 @@ export function writeFileAtomic(path: string, data: string): Bluebird { export function safeRename(src: string, dest: string): Bluebird { return Bluebird.resolve(fs.rename(src, dest)) - .then(() => fs.open(path.dirname(dest), 'r')) + .then(() => fs.open(Path.dirname(dest), 'r')) .tap(fs.fsync) .then(fs.close); } export function pathExistsOnHost(p: string): Bluebird { - return Bluebird.resolve(fs.stat(path.join(constants.rootMountPoint, p))) + return Bluebird.resolve(fs.stat(Path.join(constants.rootMountPoint, p))) .return(true) .catchReturn(ENOENT, false); } diff --git a/src/local-mode.ts b/src/local-mode.ts index 870d4b6f..7bfa09b4 100644 --- a/src/local-mode.ts +++ b/src/local-mode.ts @@ -26,14 +26,14 @@ export class LocalModeManager { // Setup a listener to catch state changes relating to local mode this.config.on('change', changed => { if (changed.localMode != null) { - const localMode = changed.localMode || false; + const local = changed.localMode || false; // First switch the logger to it's correct state - this.logger.switchBackend(localMode); + this.logger.switchBackend(local); // If we're leaving local mode, make sure to remove all of the // leftover artifacts - if (!localMode) { + if (!local) { this.removeLocalModeArtifacts(); } } diff --git a/src/logging/balena-backend.ts b/src/logging/balena-backend.ts index ce43ad2f..f9cce7fc 100644 --- a/src/logging/balena-backend.ts +++ b/src/logging/balena-backend.ts @@ -27,7 +27,7 @@ export class BalenaLogBackend extends LogBackend { private gzip: zlib.Gzip | null = null; private opts: Options; private stream: stream.PassThrough; - timeout: NodeJS.Timer; + private timeout: NodeJS.Timer; public constructor(apiEndpoint: string, uuid: string, deviceApiKey: string) { super(); diff --git a/src/logging/container.ts b/src/logging/container.ts index bb20a3af..d4278616 100644 --- a/src/logging/container.ts +++ b/src/logging/container.ts @@ -20,9 +20,7 @@ interface LogsEvents { type LogsEventEmitter = StrictEventEmitter; -export class ContainerLogs extends (EventEmitter as { - new (): LogsEventEmitter; -}) { +export class ContainerLogs extends (EventEmitter as new () => LogsEventEmitter) { public constructor(public containerId: string, private docker: Docker) { super(); } diff --git a/src/logging/local-backend.ts b/src/logging/local-backend.ts index e308f909..29f2e2d9 100644 --- a/src/logging/local-backend.ts +++ b/src/logging/local-backend.ts @@ -36,10 +36,10 @@ export class LocalLogBackend extends LogBackend { return message; } }) - .then((message: LogMessage | null) => { - if (message != null) { + .then((msg: LogMessage | null) => { + if (msg != null) { _.each(this.globalListeners, listener => { - listener.push(`${JSON.stringify(message)}\n`); + listener.push(`${JSON.stringify(msg)}\n`); }); } }) diff --git a/tslint.json b/tslint.json new file mode 100644 index 00000000..34478831 --- /dev/null +++ b/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["resin-lint/config/tslint-prettier.json"] +} diff --git a/typings/dbus-native.d.ts b/typings/dbus-native.d.ts index 100847fc..77b2db0d 100644 --- a/typings/dbus-native.d.ts +++ b/typings/dbus-native.d.ts @@ -1,4 +1,6 @@ -// Adapted from: https://gist.github.com/TianyiLi/a231afa2f804d8fa0805baa4830f9242 +// Adapted from: +// https://gist.github.com/TianyiLi/a231afa2f804d8fa0805baa4830f9242 +// tslint:disable declare module 'dbus-native' { import * as net from 'net'; import * as events from 'events'; diff --git a/typings/docker-delta.d.ts b/typings/docker-delta.d.ts index 39c25a8a..a30eb7e5 100644 --- a/typings/docker-delta.d.ts +++ b/typings/docker-delta.d.ts @@ -1,7 +1,7 @@ declare module 'docker-delta' { // Incomplete type definitions - import TypedError = require('typed-error'); import { Duplex } from 'stream'; + import TypedError = require('typed-error'); export class OutOfSyncError extends TypedError {} diff --git a/typings/duration-js.d.ts b/typings/duration-js.d.ts index 21cfdeb4..b2924765 100644 --- a/typings/duration-js.d.ts +++ b/typings/duration-js.d.ts @@ -1,5 +1,6 @@ // From: https://github.com/icholy/Duration.js/pull/15 // Once the above is merged, use the inbuilt module types +// tslint:disable declare module 'duration-js' { type DurationLike = Duration | string | number; type DateLike = Date | number; diff --git a/typings/global.d.ts b/typings/global.d.ts index c303f6fe..6c7b4b43 100644 --- a/typings/global.d.ts +++ b/typings/global.d.ts @@ -2,8 +2,6 @@ interface Dictionary { [key: string]: T; } -interface Callback { - (err?: Error, res?: T): void; -} +type Callback = (err?: Error, res?: T) => void; type Nullable = T | null | undefined;