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();
}

View file

@ -34,7 +34,7 @@ export class DownloadService {
}
@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;
}> {
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;
// 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.
object: IObject | string | [IObject | string] ;
object: IObject | string | [IObject | string];
target?: IObject | string;
/** LD-Signature */
signature?: {

View file

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

View file

@ -83,7 +83,7 @@ export class ImportNotesProcessorService {
}
@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 });
}

View file

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

View file

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

View file

@ -192,7 +192,7 @@ export class MastodonApiServerService {
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();
if (!multipartData) {
reply.code(401).send({ error: 'No image' });
@ -284,7 +284,7 @@ export class MastodonApiServerService {
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 limit = _request.query.limit ? parseInt(_request.query.limit) : 20;

View file

@ -142,7 +142,7 @@ export class ApiAccountMastodon {
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"' });
const client = this.clientService.getClient(_request);
@ -154,7 +154,7 @@ export class ApiAccountMastodon {
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"' });
const client = this.clientService.getClient(_request);

View file

@ -148,7 +148,7 @@ describe('Streaming', () => {
test('フォローしているユーザーの投稿が流れる', async () => {
const fired = await waitFire(
ayano, 'homeTimeline', // ayano:home
ayano, 'homeTimeline', // ayano:home
() => api('notes/create', { text: 'foo' }, kyoko), // kyoko posts
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
);
@ -158,7 +158,7 @@ describe('Streaming', () => {
test('フォローしているユーザーの visibility: followers な投稿が流れる', async () => {
const fired = await waitFire(
ayano, 'homeTimeline', // ayano:home
ayano, 'homeTimeline', // ayano:home
() => api('notes/create', { text: 'foo', visibility: 'followers' }, kyoko), // kyoko posts
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
);
@ -170,7 +170,7 @@ describe('Streaming', () => {
const note = await post(kyoko, { text: 'foo', visibility: 'followers' });
const fired = await waitFire(
ayano, 'homeTimeline', // ayano:home
ayano, 'homeTimeline', // ayano:home
() => api('notes/create', { text: 'bar', visibility: 'followers', replyId: note.id }, kyoko), // kyoko posts
msg => msg.type === 'note' && msg.body.userId === kyoko.id && msg.body.reply.text === 'foo',
);
@ -182,7 +182,7 @@ describe('Streaming', () => {
const chitoseNote = await post(chitose, { text: 'followers-only post', visibility: 'followers' });
const fired = await waitFire(
ayano, 'homeTimeline', // ayano:home
ayano, 'homeTimeline', // ayano:home
() => api('notes/create', { text: 'reply to chitose\'s followers-only post', replyId: chitoseNote.id }, kyoko), // kyoko's reply to chitose's followers-only post
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
);
@ -195,7 +195,7 @@ describe('Streaming', () => {
const kyokoReply = await post(kyoko, { text: 'reply to followers-only post', replyId: chitoseNote.id });
const fired = await waitFire(
ayano, 'homeTimeline', // ayano:home
ayano, 'homeTimeline', // ayano:home
() => api('notes/create', { renoteId: kyokoReply.id }, kyoko), // kyoko's renote of kyoko's reply to chitose's followers-only post
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
);
@ -205,7 +205,7 @@ describe('Streaming', () => {
test('フォローしていないユーザーの投稿は流れない', async () => {
const fired = await waitFire(
kyoko, 'homeTimeline', // kyoko:home
kyoko, 'homeTimeline', // kyoko:home
() => api('notes/create', { text: 'foo' }, ayano), // ayano posts
msg => msg.type === 'note' && msg.body.userId === ayano.id, // wait ayano
);
@ -215,7 +215,7 @@ describe('Streaming', () => {
test('フォローしているユーザーのダイレクト投稿が流れる', async () => {
const fired = await waitFire(
ayano, 'homeTimeline', // ayano:home
ayano, 'homeTimeline', // ayano:home
() => api('notes/create', { text: 'foo', visibility: 'specified', visibleUserIds: [ayano.id] }, kyoko), // kyoko dm => ayano
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
);
@ -225,7 +225,7 @@ describe('Streaming', () => {
test('フォローしているユーザーでも自分が指定されていないダイレクト投稿は流れない', async () => {
const fired = await waitFire(
ayano, 'homeTimeline', // ayano:home
ayano, 'homeTimeline', // ayano:home
() => api('notes/create', { text: 'foo', visibility: 'specified', visibleUserIds: [chitose.id] }, kyoko), // kyoko dm => chitose
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
);
@ -574,7 +574,7 @@ describe('Streaming', () => {
test('withReplies = falseでフォローしてる人によるリプライが流れてくる', async () => {
const fired = await waitFire(
ayano, 'globalTimeline', // ayano:Global
ayano, 'globalTimeline', // ayano:Global
() => api('notes/create', { text: 'foo', replyId: kanakoNote.id }, kyoko), // kyoko posts
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
);

View file

@ -312,7 +312,9 @@ describe('ユーザー', () => {
assert.strictEqual(response.name, null);
assert.strictEqual(response.username, 'zoe');
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.deepStrictEqual(response.avatarDecorations, []);
assert.strictEqual(response.isBot, false);

View file

@ -54,7 +54,7 @@ class DummyFastifyReply {
}
class DummyFastifyRequest {
public ip: string;
public body: {credential: any, context: string};
public body: { credential: any, context: string };
public headers: IncomingHttpHeaders = { 'accept': 'application/json' };
constructor(body?: any) {
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;
const result = await new Promise<string>(async (resolve, reject) => {
fastify.all('/', async (req, res) => {
timeoutHandle && clearTimeout(timeoutHandle);
if (timeoutHandle) {
clearTimeout(timeoutHandle);
}
const body = JSON.stringify(req.body);
res.status(200).send('ok');