Skip to content

Commit 5eb7fba

Browse files
committed
Banned use of explicit any
We had this set to warning to allow our legacy code to pass lint, but this has result in more uses of explicit any being added to the codebase. The approach here is to add comments to allow the existing cases but ban all new cases.
1 parent 16c8209 commit 5eb7fba

21 files changed

+109
-11
lines changed

biome.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
"noNonNullAssertion": "off"
2929
},
3030
"suspicious": {
31-
"noConsoleLog": "off",
32-
"noExplicitAny": "warn",
33-
"noImplicitAnyLet": "warn"
31+
"noConsoleLog": "off"
3432
}
3533
}
3634
},

cedar/query-runner/src/app.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ const warmupPool = async () => {
4343
console.timeEnd('Warmup');
4444
};
4545

46+
// TODO: Clean up the any type
47+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
4648
const timeQuery = async (query: string, args: any[]) => {
4749
//: { [key: string]: string }) => {
4850
const start = performance.now();
@@ -51,6 +53,8 @@ const timeQuery = async (query: string, args: any[]) => {
5153
return end - start;
5254
};
5355

56+
// TODO: Clean up the any type
57+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
5458
const runQuery = async (query: string, args: any[]) => {
5559
// { [key: string]: string }) => {
5660
const runTimes: number[] = Array(SERIES_RUNS).fill(

src/activity-handlers/create.handler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export class CreateHandler {
4444
const replyTarget = await object?.getReplyTarget();
4545

4646
if (replyTarget?.id?.href) {
47+
// TODO: Clean up the any type
48+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
4749
const data = await ctx.data.globaldb.get<any>([
4850
replyTarget.id.href,
4951
]);

src/app.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ function ensureCorrectContext<B, R>(
297297
return async (ctx: Context<ContextData>, b: B) => {
298298
const host = ctx.host;
299299
if (!ctx.data) {
300+
// TODO: Clean up the any type
301+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
300302
(ctx as any).data = {};
301303
}
302304
if (!ctx.data.globaldb) {

src/core/events.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import EventEmitter from 'node:events';
22

33
export class AsyncEvents extends EventEmitter {
4+
// TODO: Clean up the any type
5+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
46
async emitAsync(eventName: string, ...args: any[]): Promise<boolean> {
57
const handlers = this.listeners(eventName);
68
if (handlers.length === 0) {

src/db.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export const client = Knex({
2525
});
2626

2727
interface ActivityJsonLd {
28+
// TODO: Clean up the any type
29+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
2830
[key: string]: any;
2931
}
3032

src/dispatchers.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ export async function handleAnnoucedCreate(
377377
const replyTarget = await object?.getReplyTarget();
378378

379379
if (replyTarget?.id?.href) {
380+
// TODO: Clean up the any type
381+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
380382
const data = await ctx.data.globaldb.get<any>([replyTarget.id.href]);
381383
const replyTargetAuthor = data?.attributedTo?.id;
382384
const inboxActor = await getUserData(ctx, 'index');
@@ -954,8 +956,12 @@ export async function likedDispatcher(
954956
object:
955957
| string
956958
| {
959+
// TODO: Clean up the any type
960+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
957961
[key: string]: any;
958962
};
963+
// TODO: Clean up the any type
964+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
959965
[key: string]: any;
960966
}>([result]);
961967

src/dispatchers.unit.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ vi.mock('./app', () => ({
2828
describe('dispatchers', () => {
2929
describe('actorDispatcher', () => {
3030
it(`returns null if the handle is not "${ACTOR_DEFAULT_HANDLE}"`, async () => {
31+
// TODO: Clean up the any type
32+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
3133
const ctx = {} as RequestContext<any>;
3234
const handle = 'anything';
3335

@@ -42,6 +44,8 @@ describe('dispatchers', () => {
4244
});
4345

4446
describe('likedDispatcher', () => {
47+
// TODO: Clean up the any type
48+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
4549
const likeActivities: Record<string, any> = {
4650
'https://example.com/like/123': {
4751
'@context': [
@@ -81,6 +85,8 @@ describe('dispatchers', () => {
8185
info: vi.fn(),
8286
},
8387
},
88+
// TODO: Clean up the any type
89+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
8490
} as RequestContext<any>;
8591

8692
beforeEach(() => {
@@ -147,6 +153,8 @@ describe('dispatchers', () => {
147153
it('hydrates the object of a like', async () => {
148154
const actorId = 'https://example.com/actor/123';
149155

156+
// TODO: Clean up the any type
157+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
150158
const likeActivities: Record<string, any> = {
151159
'https://example.com/like/123': {
152160
'@context': [
@@ -262,6 +270,8 @@ describe('dispatchers', () => {
262270
error: vi.fn(),
263271
},
264272
},
273+
// TODO: Clean up the any type
274+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
265275
} as RequestContext<any>;
266276

267277
beforeEach(() => {
@@ -328,6 +338,8 @@ describe('dispatchers', () => {
328338

329339
describe('nodeInfoDispatcher', () => {
330340
it('returns the node info', async () => {
341+
// TODO: Clean up the any type
342+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
331343
const result = await nodeInfoDispatcher({} as RequestContext<any>);
332344

333345
expect(result).toEqual({

src/helpers/activitypub/activity.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ export interface ActivityObject {
1717
id: string;
1818
content: string;
1919
attachment?: ActivityObjectAttachment | ActivityObjectAttachment[];
20+
// TODO: Clean up the any type
21+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
2022
[key: string]: any;
2123
}
2224

2325
export interface Activity {
2426
id: string;
2527
object: string | ActivityObject;
28+
// TODO: Clean up the any type
29+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
2630
[key: string]: any;
2731
}
2832

src/helpers/user.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ export async function getUserKeypair(
144144
ctx: Context<ContextData>,
145145
handle: string,
146146
) {
147+
// TODO: Clean up the any types
148+
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
147149
const existing = await ctx.data.db.get<{ publicKey: any; privateKey: any }>(
148150
['keypair', handle],
149151
);

0 commit comments

Comments
 (0)