fix eslint-errors

This commit is contained in:
Michael C
2021-07-04 01:34:31 -04:00
parent a1bcd08658
commit d89b26b77d
71 changed files with 392 additions and 393 deletions

View File

@@ -1,19 +1,20 @@
import {Logger} from '../utils/logger';
import {IDatabase, QueryType} from './IDatabase';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import MysqlInterface from 'sync-mysql';
export class Mysql implements IDatabase {
private connection: any;
constructor(private config: any) {
constructor(private config: unknown) {
}
async init(): Promise<void> {
this.connection = new MysqlInterface(this.config);
}
prepare(type: QueryType, query: string, params?: any[]) {
prepare(type: QueryType, query: string, params?: any[]): Promise<any[]> {
Logger.debug(`prepare (mysql): type: ${type}, query: ${query}, params: ${params}`);
const queryResult = this.connection.query(query, params);

View File

@@ -17,7 +17,7 @@ types.setTypeParser(20, function(val) {
export class Postgres implements IDatabase {
private pool: Pool;
constructor(private config: any) {}
constructor(private config: Record<string, any>) {}
async init(): Promise<void> {
this.pool = new Pool(this.config.postgres);
@@ -43,7 +43,7 @@ export class Postgres implements IDatabase {
}
}
async prepare(type: QueryType, query: string, params?: any[]) {
async prepare(type: QueryType, query: string, params?: any[]): Promise<any[]> {
// Convert query to use numbered parameters
let count = 1;
for (let char = 0; char < query.length; char++) {
@@ -64,7 +64,7 @@ export class Postgres implements IDatabase {
return value;
}
case 'all': {
let values = queryResult.rows;
const values = queryResult.rows;
Logger.debug(`result (postgres): ${values}`);
return values;
}

View File

@@ -12,7 +12,7 @@ export class Sqlite implements IDatabase {
{
}
async prepare(type: QueryType, query: string, params: any[] = []) {
async prepare(type: QueryType, query: string, params: any[] = []): Promise<any[]> {
// Logger.debug(`prepare (sqlite): type: ${type}, query: ${query}, params: ${params}`);
const preparedQuery = this.db.prepare(query);
@@ -30,7 +30,7 @@ export class Sqlite implements IDatabase {
}
}
async init() {
async init(): Promise<void> {
// Make dirs if required
if (!fs.existsSync(path.join(this.config.dbPath, "../"))) {
fs.mkdirSync(path.join(this.config.dbPath, "../"));
@@ -61,7 +61,7 @@ export class Sqlite implements IDatabase {
this.db.exec("pragma mmap_size= 500000000;");
}
attachDatabase(database: string, attachAs: string) {
attachDatabase(database: string, attachAs: string): void {
this.db.prepare(`ATTACH ? as ${attachAs}`).run(database);
}
@@ -83,7 +83,7 @@ export class Sqlite implements IDatabase {
}
private static processUpgradeQuery(query: string): string {
let result = query.replace(/^.*--!sqlite-ignore/gm, "");
const result = query.replace(/^.*--!sqlite-ignore/gm, "");
return result;
}

View File

@@ -60,7 +60,7 @@ if (config.mysql) {
enableWalCheckpointNumber: false
});
}
async function initDb() {
async function initDb(): Promise<void> {
await db.init();
await privateDB.init();
@@ -74,4 +74,4 @@ export {
db,
privateDB,
initDb,
}
};