fix backend lint errors

This commit is contained in:
Hazelnoot 2025-04-02 10:35:11 -04:00
parent 9dffb13be7
commit f9c1535147
13 changed files with 27 additions and 23 deletions

View file

@ -487,7 +487,7 @@ function applyEnvOverrides(config: Source) {
} }
} }
function _step2name(step: string|number): string { function _step2name(step: string | number): string {
return step.toString().replaceAll(/[^a-z0-9]+/gi, '').toUpperCase(); return step.toString().replaceAll(/[^a-z0-9]+/gi, '').toUpperCase();
} }

View file

@ -34,7 +34,7 @@ export class DownloadService {
} }
@bindThis @bindThis
public async downloadUrl(url: string, path: string, options: { timeout?: number, operationTimeout?: number, maxSize?: number} = {} ): Promise<{ public async downloadUrl(url: string, path: string, options: { timeout?: number, operationTimeout?: number, maxSize?: number } = {} ): Promise<{
filename: string; filename: string;
}> { }> {
this.logger.info(`Downloading ${chalk.cyan(url)} to ${chalk.cyanBright(path)} ...`); this.logger.info(`Downloading ${chalk.cyan(url)} to ${chalk.cyanBright(path)} ...`);

View file

@ -112,7 +112,7 @@ export interface IActivity extends IObject {
actor: IObject | string; actor: IObject | string;
// ActivityPub spec allows for arrays: https://www.w3.org/TR/activitystreams-vocabulary/#properties // ActivityPub spec allows for arrays: https://www.w3.org/TR/activitystreams-vocabulary/#properties
// Misskey can only handle one value, so we use a tuple for that case. // Misskey can only handle one value, so we use a tuple for that case.
object: IObject | string | [IObject | string] ; object: IObject | string | [IObject | string];
target?: IObject | string; target?: IObject | string;
/** LD-Signature */ /** LD-Signature */
signature?: { signature?: {

View file

@ -77,7 +77,7 @@ type PackedPureRenote = PackedRenote & {
replyId: NonNullable<Packed<'Note'>['replyId']>; replyId: NonNullable<Packed<'Note'>['replyId']>;
poll: NonNullable<Packed<'Note'>['poll']>; poll: NonNullable<Packed<'Note'>['poll']>;
fileIds: NonNullable<Packed<'Note'>['fileIds']>; fileIds: NonNullable<Packed<'Note'>['fileIds']>;
} };
export function isRenotePacked(note: Packed<'Note'>): note is PackedRenote { export function isRenotePacked(note: Packed<'Note'>): note is PackedRenote {
return note.renoteId != null; return note.renoteId != null;

View file

@ -83,7 +83,7 @@ export class ImportNotesProcessorService {
} }
@bindThis @bindThis
private downloadUrl(url: string, path:string): Promise<{filename: string}> { private downloadUrl(url: string, path:string): Promise<{ filename: string }> {
return this.downloadService.downloadUrl(url, path, { operationTimeout: this.config.import?.downloadTimeout, maxSize: this.config.import?.maxFileSize }); return this.downloadService.downloadUrl(url, path, { operationTimeout: this.config.import?.downloadTimeout, maxSize: this.config.import?.maxFileSize });
} }

View file

@ -161,4 +161,4 @@ export type ThinUser = {
export type ScheduleNotePostJobData = { export type ScheduleNotePostJobData = {
scheduleNoteId: MiNote['id']; scheduleNoteId: MiNote['id'];
} };

View file

@ -100,7 +100,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
id: string; id: string;
note: { note: {
text?: string; text?: string;
cw?: string|null; cw?: string | null;
fileIds: string[]; fileIds: string[];
visibility: typeof noteVisibilities[number]; visibility: typeof noteVisibilities[number];
visibleUsers: Packed<'UserLite'>[]; visibleUsers: Packed<'UserLite'>[];

View file

@ -192,7 +192,7 @@ export class MastodonApiServerService {
reply.send(response); reply.send(response);
}); });
fastify.post<{ Body: { description?: string; focus?: string }}>('/v2/media', { preHandler: upload.single('file') }, async (_request, reply) => { fastify.post<{ Body: { description?: string; focus?: string } }>('/v2/media', { preHandler: upload.single('file') }, async (_request, reply) => {
const multipartData = await _request.file(); const multipartData = await _request.file();
if (!multipartData) { if (!multipartData) {
reply.code(401).send({ error: 'No image' }); reply.code(401).send({ error: 'No image' });
@ -284,7 +284,7 @@ export class MastodonApiServerService {
reply.send(response); reply.send(response);
}); });
fastify.get<{ Querystring: { limit?: string }}>('/v1/follow_requests', async (_request, reply) => { fastify.get<{ Querystring: { limit?: string } }>('/v1/follow_requests', async (_request, reply) => {
const client = this.clientService.getClient(_request); const client = this.clientService.getClient(_request);
const limit = _request.query.limit ? parseInt(_request.query.limit) : 20; const limit = _request.query.limit ? parseInt(_request.query.limit) : 20;

View file

@ -142,7 +142,7 @@ export class ApiAccountMastodon {
reply.send(response); reply.send(response);
}); });
fastify.get<{ Querystring: { acct?: string }}>('/v1/accounts/lookup', async (_request, reply) => { fastify.get<{ Querystring: { acct?: string } }>('/v1/accounts/lookup', async (_request, reply) => {
if (!_request.query.acct) return reply.code(400).send({ error: 'BAD_REQUEST', error_description: 'Missing required property "acct"' }); if (!_request.query.acct) return reply.code(400).send({ error: 'BAD_REQUEST', error_description: 'Missing required property "acct"' });
const client = this.clientService.getClient(_request); const client = this.clientService.getClient(_request);
@ -154,7 +154,7 @@ export class ApiAccountMastodon {
reply.send(response); reply.send(response);
}); });
fastify.get<ApiAccountMastodonRoute & { Querystring: { id?: string | string[] }}>('/v1/accounts/relationships', async (_request, reply) => { fastify.get<ApiAccountMastodonRoute & { Querystring: { id?: string | string[] } }>('/v1/accounts/relationships', async (_request, reply) => {
if (!_request.query.id) return reply.code(400).send({ error: 'BAD_REQUEST', error_description: 'Missing required property "id"' }); if (!_request.query.id) return reply.code(400).send({ error: 'BAD_REQUEST', error_description: 'Missing required property "id"' });
const client = this.clientService.getClient(_request); const client = this.clientService.getClient(_request);

View file

@ -312,7 +312,9 @@ describe('ユーザー', () => {
assert.strictEqual(response.name, null); assert.strictEqual(response.name, null);
assert.strictEqual(response.username, 'zoe'); assert.strictEqual(response.username, 'zoe');
assert.strictEqual(response.host, null); assert.strictEqual(response.host, null);
response.avatarUrl && assert.match(response.avatarUrl, /^[-a-zA-Z0-9@:%._\+~#&?=\/]+$/); if (response.avatarUrl) {
assert.match(response.avatarUrl, /^[-a-zA-Z0-9@:%._\+~#&?=\/]+$/);
}
assert.strictEqual(response.avatarBlurhash, null); assert.strictEqual(response.avatarBlurhash, null);
assert.deepStrictEqual(response.avatarDecorations, []); assert.deepStrictEqual(response.avatarDecorations, []);
assert.strictEqual(response.isBot, false); assert.strictEqual(response.isBot, false);

View file

@ -54,7 +54,7 @@ class DummyFastifyReply {
} }
class DummyFastifyRequest { class DummyFastifyRequest {
public ip: string; public ip: string;
public body: {credential: any, context: string}; public body: { credential: any, context: string };
public headers: IncomingHttpHeaders = { 'accept': 'application/json' }; public headers: IncomingHttpHeaders = { 'accept': 'application/json' };
constructor(body?: any) { constructor(body?: any) {
this.ip = '0.0.0.0'; this.ip = '0.0.0.0';

View file

@ -661,7 +661,9 @@ export async function captureWebhook<T = SystemWebhookPayload>(postAction: () =>
let timeoutHandle: NodeJS.Timeout | null = null; let timeoutHandle: NodeJS.Timeout | null = null;
const result = await new Promise<string>(async (resolve, reject) => { const result = await new Promise<string>(async (resolve, reject) => {
fastify.all('/', async (req, res) => { fastify.all('/', async (req, res) => {
timeoutHandle && clearTimeout(timeoutHandle); if (timeoutHandle) {
clearTimeout(timeoutHandle);
}
const body = JSON.stringify(req.body); const body = JSON.stringify(req.body);
res.status(200).send('ok'); res.status(200).send('ok');