Skip to content

Commit ae38d86

Browse files
authored
[linting] Enable eslint/no-unsafe-argument (#18965)
1 parent 38f02bd commit ae38d86

File tree

65 files changed

+281
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+281
-212
lines changed

components/gitpod-db/.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
},
1111
"rules": {
1212
"no-var": "error",
13+
"no-void": "error",
1314
"prefer-const": "error",
1415
"@typescript-eslint/ban-ts-comment": "off",
1516
"@typescript-eslint/ban-types": "off",
1617
"@typescript-eslint/explicit-module-boundary-types": "off",
1718
"@typescript-eslint/no-empty-function": "off",
1819
"@typescript-eslint/no-empty-interface": "off",
1920
"@typescript-eslint/no-explicit-any": "off",
21+
"@typescript-eslint/no-floating-promises": "error",
2022
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
2123
"@typescript-eslint/no-inferrable-types": "off",
2224
"@typescript-eslint/no-misused-promises": [
@@ -28,6 +30,7 @@
2830
"@typescript-eslint/no-namespace": "off",
2931
"@typescript-eslint/no-non-null-assertion": "off",
3032
"@typescript-eslint/no-this-alias": "off",
33+
"@typescript-eslint/no-unsafe-argument": "error",
3134
"@typescript-eslint/no-unused-vars": [
3235
"error",
3336
{

components/gitpod-db/src/migrate-migrations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { TypeORM } from "./typeorm/typeorm";
88
import { Config } from "./config";
99
import { MigrateMigrations0_2_0 } from "./typeorm/migrate-migrations-0_2_0";
10+
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
1011

1112
async function migrateMigrationsTable() {
1213
const config = new Config();
@@ -17,7 +18,7 @@ async function migrateMigrationsTable() {
1718
const migration_0_2_0 = new MigrateMigrations0_2_0();
1819
await migration_0_2_0.up(runner);
1920

20-
conn.close();
21+
conn.close().catch((err) => log.error("cannot close connection", err));
2122
console.log("successfully migrated 'migrations' table.");
2223
}
2324

components/gitpod-db/src/periodic-deleter.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,13 @@ export class PeriodicDbDeleter {
3939
const pendingDeletions: Promise<void>[] = [];
4040
for (const { deletions } of toBeDeleted.reverse()) {
4141
for (const deletion of deletions) {
42-
pendingDeletions.push(
43-
this.query(deletion).catch((err) =>
44-
log.error(
45-
`[PeriodicDbDeleter] sync error`,
46-
{
47-
periodicDeleterTickId: tickID,
48-
query: deletion,
49-
},
50-
err,
51-
),
52-
),
42+
const promise: Promise<void> = this.query(deletion).catch((err) =>
43+
log.error(`[PeriodicDbDeleter] sync error`, err, {
44+
periodicDeleterTickId: tickID,
45+
query: deletion,
46+
}),
5347
);
48+
pendingDeletions.push(promise);
5449
}
5550
}
5651
await Promise.all(pendingDeletions);

components/gitpod-db/src/redis/publisher.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class TestRedisPublisher {
3131

3232
@test public publishInstanceUpdate() {
3333
const publisher = this.container.get(RedisPublisher);
34-
expect(() => {
35-
publisher.publishInstanceUpdate({
34+
expect(async () => {
35+
await publisher.publishInstanceUpdate({
3636
ownerID: "123-owner",
3737
instanceID: "123",
3838
workspaceID: "foo-bar-123",

components/gitpod-db/src/tables.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ class TablesSpec {
1919
@test(timeout(10000))
2020
public async createAndFindATeam() {
2121
const thing = new GitpodTableDescriptionProvider();
22-
try {
23-
thing.getSortedTables();
24-
} catch (error) {
25-
expect.fail(error);
26-
}
22+
expect(() => thing.getSortedTables()).to.not.throw();
2723
}
2824
}
2925

components/gitpod-db/src/test/reset-db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function resetDB(typeorm: TypeORM) {
1212
const conn = await typeorm.getConnection();
1313
const users = await conn.getRepository(DBUser).find();
1414
// delete all users except the builtin users
15-
conn.getRepository(DBUser).remove(users.filter((u) => !isBuiltinUser(u.id)));
15+
await conn.getRepository(DBUser).remove(users.filter((u) => !isBuiltinUser(u.id)));
1616

1717
const deletions = conn.entityMetadatas
1818
.filter((meta) => meta.tableName !== "d_b_user")

components/gitpod-db/src/traced-db.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export class DBWithTracing<T> {
1717
public trace(ctx: TraceContext): T {
1818
return new Proxy(this.db, {
1919
get: (_target: any, name: string) => {
20+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
2021
const f = Reflect.get(_target, name);
2122
if (!f) {
2223
return undefined;

components/gitpod-db/src/typeorm/team-db-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export class TeamDBImpl extends TransactionalDBImpl<TeamDB> implements TeamDB {
254254
const orgSettings = await orgSettingsRepo.findOne({ where: { orgId } });
255255
if (orgSettings) {
256256
orgSettings.deleted = true;
257-
orgSettingsRepo.save(orgSettings);
257+
await orgSettingsRepo.save(orgSettings);
258258
}
259259
}
260260

components/gitpod-db/src/typeorm/transformer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export namespace Transformer {
6464
},
6565
from(value: any): any {
6666
// From TIMESTAMP to ISO string
67+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
6768
return new Date(Date.parse(value)).toISOString();
6869
},
6970
};
@@ -74,6 +75,7 @@ export namespace Transformer {
7475
return JSON.stringify(value || defaultValue);
7576
},
7677
from(value: any): any {
78+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
7779
return JSON.parse(value);
7880
},
7981
};
@@ -85,6 +87,7 @@ export namespace Transformer {
8587
return encryptionServiceProvider().encrypt(value);
8688
},
8789
from(value: any): any {
90+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
8891
return encryptionServiceProvider().decrypt(value);
8992
},
9093
};

components/gitpod-db/src/typeorm/user-db-impl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ export class TypeORMUserDBImpl extends TransactionalDBImpl<UserDB> implements Us
379379
}
380380
const res = await userRepo.query(query);
381381
const count = res[0].cnt;
382+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
382383
return Number.parseInt(count);
383384
}
384385

@@ -598,7 +599,7 @@ export class TypeORMUserDBImpl extends TransactionalDBImpl<UserDB> implements Us
598599
}
599600
async revoke(accessTokenToken: OAuthToken): Promise<void> {
600601
const tokenHash = crypto.createHash("sha256").update(accessTokenToken.accessToken, "utf8").digest("hex");
601-
this.deleteGitpodToken(tokenHash);
602+
await this.deleteGitpodToken(tokenHash);
602603
}
603604
async isRefreshTokenRevoked(refreshToken: OAuthToken): Promise<boolean> {
604605
return Date.now() > (refreshToken.refreshTokenExpiresAt?.getTime() ?? 0);

0 commit comments

Comments
 (0)