Add type checking for javascript files

Change-type: patch
This commit is contained in:
Pagan Gazzard 2020-03-24 14:21:17 +00:00
parent 4fbd015083
commit 9c3295c912
18 changed files with 34 additions and 23 deletions

View File

@ -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": [

View File

@ -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": {

View File

@ -347,7 +347,7 @@ export class Images extends (EventEmitter as new () => ImageEventEmitter) {
}
private async getImagesForCleanup(): Promise<string[]> {
const images = [];
const images: string[] = [];
const [
supervisorImageInfo,

View File

@ -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;
}

View File

@ -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;
});

View File

@ -169,7 +169,7 @@ export function get(): Bluebird<HostConfig> {
}
export function patch(conf: HostConfig, configModel: Config): Bluebird<void> {
const promises = [];
const promises: Array<Promise<void>> = [];
if (conf != null && conf.network != null) {
if (conf.network.proxy != null) {
promises.push(setProxy(conf.network.proxy));

View File

@ -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'));
};

View File

@ -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'));
};

View File

@ -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'));
};

View File

@ -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'));
};

View File

@ -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'));
};

View File

@ -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'));
};

View File

@ -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'));
};

View File

@ -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'));
};

View File

@ -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'));
};

View File

@ -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'));
};

View File

@ -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'));
};

8
tsconfig.js.json Normal file
View File

@ -0,0 +1,8 @@
{
"extends": "./tsconfig.release.json",
"compilerOptions": {
"noImplicitAny": false,
"checkJs": true
},
"include": ["src/**/*.ts", "src/**/*.js", "typings/**/*.d.ts"]
}