Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
"noNonNullAssertion": "off"
},
"suspicious": {
"noConsoleLog": "off",
"noExplicitAny": "warn",
"noImplicitAnyLet": "warn"
"noConsoleLog": "off"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions cedar/query-runner/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const warmupPool = async () => {
console.timeEnd('Warmup');
};

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

// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
const runQuery = async (query: string, args: any[]) => {
// { [key: string]: string }) => {
const runTimes: number[] = Array(SERIES_RUNS).fill(
Expand Down
2 changes: 2 additions & 0 deletions src/activity-handlers/create.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class CreateHandler {
const replyTarget = await object?.getReplyTarget();

if (replyTarget?.id?.href) {
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
const data = await ctx.data.globaldb.get<any>([
replyTarget.id.href,
]);
Expand Down
2 changes: 2 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ function ensureCorrectContext<B, R>(
return async (ctx: Context<ContextData>, b: B) => {
const host = ctx.host;
if (!ctx.data) {
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
(ctx as any).data = {};
}
if (!ctx.data.globaldb) {
Expand Down
2 changes: 2 additions & 0 deletions src/core/events.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import EventEmitter from 'node:events';

export class AsyncEvents extends EventEmitter {
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
async emitAsync(eventName: string, ...args: any[]): Promise<boolean> {
const handlers = this.listeners(eventName);
if (handlers.length === 0) {
Expand Down
2 changes: 2 additions & 0 deletions src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const client = Knex({
});

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

Expand Down
6 changes: 6 additions & 0 deletions src/dispatchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ export async function handleAnnoucedCreate(
const replyTarget = await object?.getReplyTarget();

if (replyTarget?.id?.href) {
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
const data = await ctx.data.globaldb.get<any>([replyTarget.id.href]);
const replyTargetAuthor = data?.attributedTo?.id;
const inboxActor = await getUserData(ctx, 'index');
Expand Down Expand Up @@ -954,8 +956,12 @@ export async function likedDispatcher(
object:
| string
| {
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
[key: string]: any;
};
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
[key: string]: any;
}>([result]);

Expand Down
12 changes: 12 additions & 0 deletions src/dispatchers.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ vi.mock('./app', () => ({
describe('dispatchers', () => {
describe('actorDispatcher', () => {
it(`returns null if the handle is not "${ACTOR_DEFAULT_HANDLE}"`, async () => {
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
const ctx = {} as RequestContext<any>;
const handle = 'anything';

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

describe('likedDispatcher', () => {
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
const likeActivities: Record<string, any> = {
'https://example.com/like/123': {
'@context': [
Expand Down Expand Up @@ -81,6 +85,8 @@ describe('dispatchers', () => {
info: vi.fn(),
},
},
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
} as RequestContext<any>;

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

// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
const likeActivities: Record<string, any> = {
'https://example.com/like/123': {
'@context': [
Expand Down Expand Up @@ -262,6 +270,8 @@ describe('dispatchers', () => {
error: vi.fn(),
},
},
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
} as RequestContext<any>;

beforeEach(() => {
Expand Down Expand Up @@ -328,6 +338,8 @@ describe('dispatchers', () => {

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

expect(result).toEqual({
Expand Down
4 changes: 4 additions & 0 deletions src/helpers/activitypub/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ export interface ActivityObject {
id: string;
content: string;
attachment?: ActivityObjectAttachment | ActivityObjectAttachment[];
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
[key: string]: any;
}

export interface Activity {
id: string;
object: string | ActivityObject;
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
[key: string]: any;
}

Expand Down
2 changes: 2 additions & 0 deletions src/helpers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ export async function getUserKeypair(
ctx: Context<ContextData>,
handle: string,
) {
// TODO: Clean up the any types
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
const existing = await ctx.data.db.get<{ publicKey: any; privateKey: any }>(
['keypair', handle],
);
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/user.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ function getCtx() {
return handle === HANDLE ? new URL(FOLLOWERS_URI) : undefined;
});

// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
return ctx as any;
}

Expand Down
2 changes: 2 additions & 0 deletions src/http/api/helpers/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export async function getAccountDTOByHandle(
throw new Error('Actor not found');
}

// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
const actor: any = await actorObj.toJsonLd();

const [followerCount, followingCount, isFollowingResult, attachments] =
Expand Down
10 changes: 10 additions & 0 deletions src/http/api/helpers/account.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ describe('Account Helpers', () => {
getAttachments as unknown as ReturnType<typeof vi.fn>
).mockResolvedValue([]);

// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
const apCtx = {} as Context<any>;
const site = {} as Site;
const accountService = {
Expand Down Expand Up @@ -267,8 +269,12 @@ describe('Account Helpers', () => {
});

it('should throw error for empty handle', async () => {
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
const apCtx = {} as Context<any>;
const site = {} as Site;
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
const accountService = {} as any;

await expect(
Expand All @@ -281,8 +287,12 @@ describe('Account Helpers', () => {
lookupObject as unknown as ReturnType<typeof vi.fn>
).mockResolvedValue(null);

// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
const apCtx = {} as Context<any>;
const site = {} as Site;
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
const accountService = {} as any;

await expect(
Expand Down
2 changes: 2 additions & 0 deletions src/http/api/views/account.follows.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ export class AccountFollowsView {
for await (const item of page.getItems()) {
const actor = (await item.toJsonLd({
format: 'compact',
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
})) as any;

const followeeAccount = await this.db('accounts')
Expand Down
2 changes: 2 additions & 0 deletions src/kv-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export function scopeKvStore(db: KvStore, scope: KvKey): KvStore {
get(key: KvKey) {
return db.get(scopeKvKey(scope, key));
},
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
set(key: KvKey, value: any) {
return db.set(scopeKvKey(scope, key), value);
},
Expand Down
10 changes: 10 additions & 0 deletions src/lookup-helpers.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ describe('lookupAPIdByHandle', () => {
).mockResolvedValue(mockWebFingerResponse);

const result = await lookupAPIdByHandle(
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
mockCtx as any,
'@user@example.com',
);
Expand All @@ -54,6 +56,8 @@ describe('lookupAPIdByHandle', () => {
).mockResolvedValue(mockWebFingerResponse);

const result = await lookupAPIdByHandle(
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
mockCtx as any,
'user@example.com',
);
Expand All @@ -77,6 +81,8 @@ describe('lookupAPIdByHandle', () => {
).mockResolvedValue(mockWebFingerResponse);

const result = await lookupAPIdByHandle(
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
mockCtx as any,
'user@example.com',
);
Expand All @@ -90,6 +96,8 @@ describe('lookupAPIdByHandle', () => {
).mockRejectedValue(new Error('WebFinger lookup failed'));

const result = await lookupAPIdByHandle(
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
mockCtx as any,
'user@example.com',
);
Expand Down Expand Up @@ -118,6 +126,8 @@ describe('lookupAPIdByHandle', () => {
).mockResolvedValue(mockWebFingerResponse);

const result = await lookupAPIdByHandle(
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
mockCtx as any,
'user@example.com',
);
Expand Down
2 changes: 2 additions & 0 deletions src/post/post.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ export class Post extends BaseEntity {
}

private handleDeleted() {
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
const self = this as any;
self.type = PostType.Tombstone;
self.title = null;
Expand Down
12 changes: 12 additions & 0 deletions src/post/post.entity.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ describe('Post', () => {
it('creates a note with html content', () => {
const account = internalAccount();
const inReplyTo = Post.createNote(account, 'Parent');
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
(inReplyTo as any).id = 'fake-id';
const content = 'My first note';

Expand All @@ -203,6 +205,8 @@ describe('Post', () => {
it('creates a note with line breaks', () => {
const account = internalAccount();
const inReplyTo = Post.createNote(account, 'Parent');
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
(inReplyTo as any).id = 'fake-id';
const content = `My
first
Expand All @@ -218,6 +222,8 @@ describe('Post', () => {
it('creates a note with escaped html', () => {
const account = internalAccount();
const inReplyTo = Post.createNote(account, 'Parent');
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
(inReplyTo as any).id = 'fake-id';
const content = '<script>alert("hax")</script> Hello, world!';

Expand All @@ -233,6 +239,8 @@ describe('Post', () => {
it('creates a note with links', () => {
const account = internalAccount();
const inReplyTo = Post.createNote(account, 'Parent');
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
(inReplyTo as any).id = 'fake-id';
const content = 'Check out https://ghost.org it is super cool';

Expand All @@ -248,6 +256,8 @@ describe('Post', () => {
it('does not convert handles to mailto', () => {
const account = internalAccount();
const inReplyTo = Post.createNote(account, 'Parent');
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
(inReplyTo as any).id = 'fake-id';
const content =
'I wish I could mention someone like @index@activitypub.ghost.org';
Expand All @@ -264,6 +274,8 @@ describe('Post', () => {
it('does not convert emails to mailto', () => {
const account = internalAccount();
const inReplyTo = Post.createNote(account, 'Parent');
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
(inReplyTo as any).id = 'fake-id';
const content = 'Email me at support@ghost.org';

Expand Down
30 changes: 22 additions & 8 deletions src/post/post.repository.knex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,16 @@ export class KnexPostRepository {

// Parse attachments and convert URL strings back to URL objects
const attachments = row.attachments
? row.attachments.map((attachment: any) => ({
...attachment,
url: new URL(attachment.url),
}))
? row.attachments.map(
(
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
attachment: any,
) => ({
...attachment,
url: new URL(attachment.url),
}),
)
: [];

const post = new Post(
Expand Down Expand Up @@ -353,10 +359,16 @@ export class KnexPostRepository {
);

const attachments = row.attachments
? row.attachments.map((attachment: any) => ({
...attachment,
url: new URL(attachment.url),
}))
? row.attachments.map(
(
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
attachment: any,
) => ({
...attachment,
url: new URL(attachment.url),
}),
)
: [];

const post = new Post(
Expand Down Expand Up @@ -430,6 +442,8 @@ export class KnexPostRepository {
);

// Hacks? Mutate the Post so `isNew` returns false.
// TODO: Clean up the any type
// biome-ignore lint/suspicious/noExplicitAny: Legacy code needs proper typing
(post as any).id = id;

if (isDuplicate) {
Expand Down
Loading