diff --git a/.eslintrc b/.eslintrc index 7916d955231eb0eec33d144324be80f317a9fe88..256c63e4c59502f937824c1379ec7c32dc9ab63e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -42,5 +42,16 @@ "@typescript-eslint/member-delimiter-style": "off", "@typescript-eslint/no-unused-expressions": "off", "@typescript-eslint/interface-name-prefix": "off" - } + }, + "overrides": [ + { + "files": [ + "test/**/*" + ], + "rules": { + "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/no-explicit-any": "off" + } + } + ] } diff --git a/src/db/postgres.ts b/src/db/postgres.ts index 26ebcaf5cb091665bfebe942d12c97aa4dd47713..da0d800e0de916bd03c8b76cd928531763cd4f8d 100644 --- a/src/db/postgres.ts +++ b/src/db/postgres.ts @@ -25,7 +25,7 @@ const pgp: pgPromise.IMain = pgPromise({ export class Postgres implements IDatabaseConnector { public static ParameterizeSql(sql: string): string { - return sql.replace(/\$((\w|\d|_)+)+/g, (k) => { + return sql.replace(/\$((\w|\d|_)+)+/g, (k: string) => { return `\${${k.substr("$".length)}}`; }); } @@ -35,7 +35,8 @@ export class Postgres implements IDatabaseConnector { constructor(private connectionString: string) { } - public Open() { + + public Open(): void { // Hide username:password const logConnString = this.connectionString.substr( this.connectionString.indexOf("@") || 0, @@ -63,7 +64,7 @@ export class Postgres implements IDatabaseConnector { public async Run(sql: string, parameters?: ISqlCommandParameters): Promise<void> { log.silly("Run:", sql); - return this.db.oneOrNone(Postgres.ParameterizeSql(sql), parameters).then(() => {}); + await this.db.oneOrNone(Postgres.ParameterizeSql(sql), parameters); } public async Close(): Promise<void> { @@ -73,6 +74,5 @@ export class Postgres implements IDatabaseConnector { public async Exec(sql: string): Promise<void> { log.silly("Exec:", sql); await this.db.none(sql); - return; } } diff --git a/src/db/roomstore.ts b/src/db/roomstore.ts index aca61771d9cfd9d0041ae66de4ff15eedca9dbd3..dc442162d1b34008d049ecb027b92b18b28913ce 100644 --- a/src/db/roomstore.ts +++ b/src/db/roomstore.ts @@ -237,7 +237,7 @@ export class DbRoomStore { try { await this.db.Run(`INSERT INTO room_entries VALUES ($id, $matrix, $remote)`, values); - log.verbose(`Created new entry ${ values.id}`); + log.verbose(`Created new entry ${values.id}`); } catch (ex) { log.error("Failed to insert room entry", ex); throw Error("Failed to insert room entry"); diff --git a/test/db/test_roomstore.ts b/test/db/test_roomstore.ts index 29fef595f868cbf328db16a5cc2cc306b6cd1743..921550de72fc52246014d0daace1d3081f578b63 100644 --- a/test/db/test_roomstore.ts +++ b/test/db/test_roomstore.ts @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +/* eslint-disable @typescript-eslint/camelcase */ import * as Chai from "chai"; import { DiscordStore, CURRENT_SCHEMA } from "../../src/store"; diff --git a/test/mocks/appservicemock.ts b/test/mocks/appservicemock.ts index 5aaf9ca2e873416efaaea1aea49e688d36a91dde..4de03ee482d1eb6f56606cb805693af62dc7a4e7 100644 --- a/test/mocks/appservicemock.ts +++ b/test/mocks/appservicemock.ts @@ -240,7 +240,7 @@ class MatrixClientMock extends AppserviceMockBase { public async uploadContent(data: Buffer, contentType: string, filename: string = "noname") { this.funcCalled("uploadContent", data, contentType, filename); - return "mxc://" + filename; + return `mxc://${filename}`; } public mxcToHttp(mxcUrl: string) { diff --git a/tsconfig.json b/tsconfig.json index e57e4513c483a95d650c220c37987a8829a33ef0..19323e419200383ab52c0675579a455fbe48050e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,7 @@ "compileOnSave": true, "include": [ "src/**/*", + "test/**/*", "tools/**/*", ] }