diff --git a/.lintstagedrc b/.lintstagedrc index e877f3f7..0285f596 100644 --- a/.lintstagedrc +++ b/.lintstagedrc @@ -2,7 +2,10 @@ "*.coffee": [ "resin-lint" ], - "*.ts$|!(*webpack.config).js$": [ + "*.ts": [ + "resin-lint --typescript --fix", + ], + "*!(*webpack.config).js": [ "resin-lint --typescript --fix", ], "test/**/*.coffee": [ diff --git a/package.json b/package.json index 04238c9e..13144ac4 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "packagejson:copy": "cp package.json build/", "testitems:copy": "cp -r test/data build/test/", "lint:coffee": "balena-lint src/ test/", - "lint:typescript": "balena-lint -e ts -e js --typescript src/ test/ typings/ && tsc --noEmit" + "lint:typescript": "balena-lint -e ts -e js --typescript src/ test/ typings/ && tsc --noEmit && tsc --noEmit --project tsconfig.js.json" }, "private": true, "dependencies": { diff --git a/src/compose/images.ts b/src/compose/images.ts index b5c05c15..45e2fa8d 100644 --- a/src/compose/images.ts +++ b/src/compose/images.ts @@ -347,7 +347,7 @@ export class Images extends (EventEmitter as new () => ImageEventEmitter) { } private async getImagesForCleanup(): Promise { - const images = []; + const images: string[] = []; const [ supervisorImageInfo, diff --git a/src/device-api/v2.ts b/src/device-api/v2.ts index 59d996bc..3dfd20f9 100644 --- a/src/device-api/v2.ts +++ b/src/device-api/v2.ts @@ -420,7 +420,7 @@ export function createV2Api(router: Router, applications: ApplicationManager) { ); }); - let overallDownloadProgress = null; + let overallDownloadProgress: number | null = null; if (downloads > 0) { overallDownloadProgress = downloadProgressTotal / downloads; } diff --git a/src/device-state.ts b/src/device-state.ts index 825ad09d..697fdcd9 100644 --- a/src/device-state.ts +++ b/src/device-state.ts @@ -798,7 +798,7 @@ export class DeviceState extends (EventEmitter as new () => DeviceStateEventEmit // TODO: This function is a bit of a mess const pause = () => { return Bluebird.try(() => { - let res = null; + let res; this.applyBlocker = new Promise(resolve => { res = resolve; }); diff --git a/src/host-config.ts b/src/host-config.ts index 3e8ad972..99471c03 100644 --- a/src/host-config.ts +++ b/src/host-config.ts @@ -169,7 +169,7 @@ export function get(): Bluebird { } export function patch(conf: HostConfig, configModel: Config): Bluebird { - const promises = []; + const promises: Array> = []; if (conf != null && conf.network != null) { if (conf.network.proxy != null) { promises.push(setProxy(conf.network.proxy)); diff --git a/src/migrations/20171129013519_legacy.js b/src/migrations/20171129013519_legacy.js index 7f9f63ed..deb6da96 100644 --- a/src/migrations/20171129013519_legacy.js +++ b/src/migrations/20171129013519_legacy.js @@ -151,6 +151,6 @@ exports.up = function(knex, Promise) { ]); }; -exports.down = function(knex, Promise) { +exports.down = function(_knex, Promise) { return Promise.reject(new Error('Not implemented')); }; diff --git a/src/migrations/20171129064057_multicontainer.js b/src/migrations/20171129064057_multicontainer.js index b18f4d49..9df154c9 100644 --- a/src/migrations/20171129064057_multicontainer.js +++ b/src/migrations/20171129064057_multicontainer.js @@ -315,6 +315,6 @@ exports.up = function(knex, Promise) { }); }; -exports.down = function(knex, Promise) { +exports.down = function(_knex, Promise) { return Promise.reject(new Error('Not implemented')); }; diff --git a/src/migrations/20171214172530_image_docker_id.js b/src/migrations/20171214172530_image_docker_id.js index 2a6ea284..9c9e4648 100644 --- a/src/migrations/20171214172530_image_docker_id.js +++ b/src/migrations/20171214172530_image_docker_id.js @@ -1,10 +1,10 @@ // Adds a dockerImageId column to the image table to identify images downloaded with deltas -exports.up = function(knex, Promise) { +exports.up = function(knex) { return knex.schema.table('image', t => { t.string('dockerImageId'); }); }; -exports.down = function(knex, Promise) { +exports.down = function(_knex, Promise) { return Promise.reject(new Error('Not implemented')); }; diff --git a/src/migrations/20180516164000-endpoint-specific-apps.js b/src/migrations/20180516164000-endpoint-specific-apps.js index 75e20c7c..38472416 100644 --- a/src/migrations/20180516164000-endpoint-specific-apps.js +++ b/src/migrations/20180516164000-endpoint-specific-apps.js @@ -2,12 +2,12 @@ const fs = require('fs'); const configJsonPath = process.env.CONFIG_MOUNT_POINT; exports.up = function(knex, Promise) { - return new Promise((resolve, reject) => { + return new Promise(resolve => { if (!configJsonPath) { console.log( 'Unable to locate config.json! Things may fail unexpectedly!', ); - resolve({}); + return resolve({}); } fs.readFile(configJsonPath, (err, data) => { if (err) { @@ -40,6 +40,6 @@ exports.up = function(knex, Promise) { }); }; -exports.down = function(knex, Promise) { +exports.down = function(_knex, Promise) { return Promise.reject(new Error('Not Implemented')); }; diff --git a/src/migrations/20181907164000-endpoint-specific-logschannel.js b/src/migrations/20181907164000-endpoint-specific-logschannel.js index 9169e4da..1437d4ba 100644 --- a/src/migrations/20181907164000-endpoint-specific-logschannel.js +++ b/src/migrations/20181907164000-endpoint-specific-logschannel.js @@ -2,7 +2,7 @@ const fs = require('fs'); const configJsonPath = process.env.CONFIG_MOUNT_POINT; exports.up = function(knex, Promise) { - return new Promise((resolve, reject) => { + return new Promise(resolve => { if (!configJsonPath) { console.log( 'Unable to locate config.json! Things may fail unexpectedly!', @@ -65,6 +65,6 @@ exports.up = function(knex, Promise) { }); }; -exports.down = function(knex, Promise) { +exports.down = function(_knex, Promise) { return Promise.reject(new Error('Not Implemented')); }; diff --git a/src/migrations/20190619152500-engine-snapshot.js b/src/migrations/20190619152500-engine-snapshot.js index c135303a..faf13dab 100644 --- a/src/migrations/20190619152500-engine-snapshot.js +++ b/src/migrations/20190619152500-engine-snapshot.js @@ -1,10 +1,10 @@ -exports.up = (knex, Promise) => { +exports.up = knex => { return knex.schema.createTable('engineSnapshot', t => { t.string('snapshot'); // Engine snapshot encoded as JSON. t.string('timestamp'); // When the snapshot was created. }); }; -exports.down = (knex, Promise) => { +exports.down = (_knex, Promise) => { return Promise.reject(new Error('Not Implemented')); }; diff --git a/src/migrations/M00000.js b/src/migrations/M00000.js index 41de30b8..e46e629e 100644 --- a/src/migrations/M00000.js +++ b/src/migrations/M00000.js @@ -3,7 +3,7 @@ const _ = require('lodash'); // We take legacy deviceConfig targets and store them without the RESIN_ prefix // (we also strip the BALENA_ prefix for completeness, even though no supervisors // using this prefix made it to production) -exports.up = function(knex, Promise) { +exports.up = function(knex) { return knex('deviceConfig') .select('targetValues') .then(devConfigs => { @@ -18,6 +18,6 @@ exports.up = function(knex, Promise) { }); }; -exports.down = function(knex, Promise) { +exports.down = function(_knex, Promise) { return Promise.reject(new Error('Not Implemented')); }; diff --git a/src/migrations/M00001.js b/src/migrations/M00001.js index 3b917cee..592b7657 100644 --- a/src/migrations/M00001.js +++ b/src/migrations/M00001.js @@ -61,6 +61,6 @@ exports.up = function(knex, Promise) { }); }; -exports.down = function(knex, Promise) { +exports.down = function(_knex, Promise) { return Promise.reject(new Error('Not Implemented')); }; diff --git a/src/migrations/M00002.js b/src/migrations/M00002.js index 3c90c998..5172bcce 100644 --- a/src/migrations/M00002.js +++ b/src/migrations/M00002.js @@ -42,6 +42,6 @@ exports.up = function(knex, Promise) { }); }; -exports.down = function(knex, Promise) { +exports.down = function(_knex, Promise) { return Promise.reject(new Error('Not Implemented')); }; diff --git a/src/migrations/M00003.js b/src/migrations/M00003.js index 21f49517..306ec751 100644 --- a/src/migrations/M00003.js +++ b/src/migrations/M00003.js @@ -16,6 +16,6 @@ exports.up = function(knex) { }); }; -exports.down = function(knex, Promise) { +exports.down = function(_knex, Promise) { return Promise.reject(new Error('Not Implemented')); }; diff --git a/src/migrations/M00004.js b/src/migrations/M00004.js index a9c4ba5e..288c00f5 100644 --- a/src/migrations/M00004.js +++ b/src/migrations/M00004.js @@ -5,6 +5,6 @@ exports.up = function(knex) { }); }; -exports.down = function(knex, Promise) { +exports.down = function(_knex, Promise) { return Promise.reject(new Error('Not Implemented')); }; diff --git a/tsconfig.js.json b/tsconfig.js.json new file mode 100644 index 00000000..caaaf0e9 --- /dev/null +++ b/tsconfig.js.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.release.json", + "compilerOptions": { + "noImplicitAny": false, + "checkJs": true + }, + "include": ["src/**/*.ts", "src/**/*.js", "typings/**/*.d.ts"] +}