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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"migrateandstart": "pnpm migrate && pnpm start",
"watch": "pnpm dev",
"dev": "node scripts/dev.mjs",
"lint": "pnpm -r lint",
"lint": "pnpm --no-bail -r lint",
"cy:open": "pnpm cypress open --config-file=cypress.config.ts",
"cy:run": "pnpm cypress run",
"e2e": "pnpm start-server-and-test start:test http://localhost:61812 cy:run",
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/assets/misc/bios.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ window.onload = async () => {
const account = JSON.parse(localStorage.getItem('account'));
const i = account.token;

const api = (endpoint, data = {}) => {
const _api = (endpoint, data = {}) => {
const promise = new Promise((resolve, reject) => {
// Append a credential
if (i) data.i = i;
Expand Down
1 change: 0 additions & 1 deletion packages/backend/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export default [
},
},
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'import/order': ['warn', {
groups: [
'builtin',
Expand Down
22 changes: 10 additions & 12 deletions packages/backend/scripts/check_connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,22 @@ async function connectToPostgres() {
}

async function connectToRedis(redisOptions) {
return await new Promise(async (resolve, reject) => {
const redis = new Redis({
let redis;
try {
redis = new Redis({
...redisOptions,
lazyConnect: true,
reconnectOnError: false,
showFriendlyErrorStack: true,
});
redis.on('error', e => reject(e));

try {
await redis.connect();
resolve();
} catch (e) {
reject(e);
} finally {
redis.disconnect(false);
}
});
await Promise.race([
new Promise((_, reject) => redis.on('error', e => reject(e))),
redis.connect(),
]);
} finally {
redis.disconnect(false);
}
}

// If not all of these are defined, the default one gets reused.
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/boot/master.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function masterMain() {
//await connectDb();
if (config.pidFile) fs.writeFileSync(config.pidFile, process.pid.toString());
} catch (e) {
bootLogger.error('Fatal error occurred during initialization', null, true);
bootLogger.error('Fatal error occurred during initialization: ' + e, null, true);
process.exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ export function loadConfig(): Config {
function tryCreateUrl(url: string) {
try {
return new URL(url);
} catch (e) {
} catch (_) {
throw new Error(`url="${url}" is not a valid URL.`);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/AccountMoveService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class AccountMoveService {
*/
@bindThis
public async moveFromLocal(src: MiLocalUser, dst: MiLocalUser | MiRemoteUser): Promise<unknown> {
const srcUri = this.userEntityService.getUserUri(src);
const _srcUri = this.userEntityService.getUserUri(src);
const dstUri = this.userEntityService.getUserUri(dst);

// add movedToUri to indicate that the user has moved
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/AnnouncementService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export class AnnouncementService {
announcementId: announcementId,
userId: user.id,
});
} catch (e) {
} catch (_) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/AvatarDecorationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class AvatarDecorationService implements OnApplicationShutdown {
const obj = JSON.parse(data);

if (obj.channel === 'internal') {
const { type, body } = obj.message as GlobalEvents['internal']['payload'];
const { type, body: _ } = obj.message as GlobalEvents['internal']['payload'];
switch (type) {
case 'avatarDecorationCreated':
case 'avatarDecorationUpdated':
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/EmailService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export class EmailService {
valid: true,
reason: null,
};
} catch (error) {
} catch (_) {
return {
valid: false,
reason: 'network',
Expand Down
28 changes: 8 additions & 20 deletions packages/backend/src/core/FileInfoService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,25 +484,13 @@ export class FileInfoService {
* Calculate blurhash string of image
*/
@bindThis
private getBlurhash(path: string, type: string): Promise<string> {
return new Promise(async (resolve, reject) => {
(await sharpBmp(path, type))
.raw()
.ensureAlpha()
.resize(64, 64, { fit: 'inside' })
.toBuffer((err, buffer, info) => {
if (err) return reject(err);

let hash;

try {
hash = blurhash.encode(new Uint8ClampedArray(buffer), info.width, info.height, 5, 5);
} catch (e) {
return reject(e);
}

resolve(hash);
});
});
private async getBlurhash(path: string, type: string): Promise<string> {
const sharp = await sharpBmp(path, type);
const { data: buffer, info } = await sharp
.raw()
.ensureAlpha()
.resize(64, 64, { fit: 'inside' })
.toBuffer({ resolveWithObject: true });
return blurhash.encode(new Uint8ClampedArray(buffer), info.width, info.height, 5, 5);
}
}
8 changes: 4 additions & 4 deletions packages/backend/src/core/MfmService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export class MfmService {
try {
const date = new Date(parseInt(text, 10) * 1000);
return `<time datetime="${escapeHtml(date.toISOString())}">${escapeHtml(date.toISOString())}</time>`;
} catch (err) {
} catch (_) {
return fnDefault(node);
}
}
Expand Down Expand Up @@ -376,7 +376,7 @@ export class MfmService {
try {
const url = new URL(node.props.url);
return `<a href="${escapeHtml(url.href)}">${toHtml(node.children)}</a>`;
} catch (err) {
} catch (_) {
return `[${toHtml(node.children)}](${escapeHtml(node.props.url)})`;
}
},
Expand All @@ -390,7 +390,7 @@ export class MfmService {
try {
const url = new URL(href);
return `<a href="${escapeHtml(url.href)}" class="u-url mention">${escapeHtml(acct)}</a>`;
} catch (err) {
} catch (_) {
return escapeHtml(acct);
}
},
Expand Down Expand Up @@ -419,7 +419,7 @@ export class MfmService {
try {
const url = new URL(node.props.url);
return `<a href="${escapeHtml(url.href)}">${escapeHtml(node.props.url)}</a>`;
} catch (err) {
} catch (_) {
return escapeHtml(node.props.url);
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/core/NoteDraftService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ export class NoteDraftService {
}

//#region visibleUsers
let visibleUsers: MiUser[] = [];
let _visibleUsers: MiUser[] = [];
if (data.visibleUserIds != null && data.visibleUserIds.length > 0) {
visibleUsers = await this.usersRepository.findBy({
_visibleUsers = await this.usersRepository.findBy({
id: In(data.visibleUserIds),
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/RoleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
default:
return false;
}
} catch (err) {
} catch (_) {
// TODO: log error
return false;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/backend/src/core/SearchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ export class SearchService {
return this.searchNoteByMeiliSearch(q, me, opts, pagination);
}
default: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const typeCheck: never = this.provider;
const _: never = this.provider;
return [];
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/backend/src/core/UserSuspendService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export class UserSuspendService {
});

(async () => {
await this.postSuspend(user).catch(e => {});
await this.unFollowAll(user).catch(e => {});
await this.postSuspend(user).catch(_ => {});
await this.unFollowAll(user).catch(_ => {});
})();
}

Expand All @@ -67,7 +67,7 @@ export class UserSuspendService {
});

(async () => {
await this.postUnsuspend(user).catch(e => {});
await this.postUnsuspend(user).catch(_ => {});
})();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/UtilityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class UtilityService {
try {
// TODO: RE2インスタンスをキャッシュ
return new RE2(regexp[1], regexp[2]).test(text);
} catch (err) {
} catch (_) {
// This should never happen due to input sanitisation.
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/activitypub/ApRendererService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ export class ApRendererService {
const restPart = maybeUrl.slice(match[0].length);

return `<a href="${urlPartParsed.href}" rel="me nofollow noopener" target="_blank">${urlPart}</a>${restPart}`;
} catch (e) {
} catch (_) {
return maybeUrl;
}
};
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/activitypub/ApRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export class ApRequestService {
return await this.signedGet(href, user, allowSoftfail, false);
}
}
} catch (e) {
} catch (_) {
// something went wrong parsing the HTML, ignore the whole thing
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/entities/ChatEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class ChatEntityService {
const reactions: { reaction: string; }[] = [];

for (const record of message.reactions) {
const [userId, reaction] = record.split('/');
const [, reaction] = record.split('/');
reactions.push({
reaction,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/core/entities/MetaEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ export class MetaEntityService {
if (instance.defaultLightTheme) {
try {
defaultLightTheme = JSON.stringify(JSON5.parse(instance.defaultLightTheme));
} catch (e) {
} catch (_) {
}
}
if (instance.defaultDarkTheme) {
try {
defaultDarkTheme = JSON.stringify(JSON5.parse(instance.defaultDarkTheme));
} catch (e) {
} catch (_) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class NoteReactionEntityService implements OnModuleInit {
packedUser?: Packed<'UserLite'>
},
): Promise<Packed<'NoteReaction'>> {
const opts = Object.assign({
const _opts = Object.assign({
}, options);

const reaction = typeof src === 'object' ? src : await this.noteReactionsRepository.findOneByOrFail({ id: src });
Expand Down Expand Up @@ -90,7 +90,7 @@ export class NoteReactionEntityService implements OnModuleInit {
packedUser?: Packed<'UserLite'>
},
): Promise<Packed<'NoteReactionWithNote'>> {
const opts = Object.assign({
const _opts = Object.assign({
}, options);

const reaction = typeof src === 'object' ? src : await this.noteReactionsRepository.findOneByOrFail({ id: src });
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/misc/check-word-mute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function checkWordMute(note: NoteLike, me: UserLike | null | undefi

try {
return new RE2(regexp[1], regexp[2]).test(text);
} catch (err) {
} catch (_) {
// This should never happen due to input sanitisation.
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/misc/get-ip-hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function getIpHash(ip: string): string {
// (this means for IPv4 the entire address is used)
const prefix = IPCIDR.createAddress(ip).mask(64);
return 'ip-' + BigInt('0b' + prefix).toString(36);
} catch (e) {
} catch (_) {
const prefix = IPCIDR.createAddress(ip.replace(/:[0-9]+$/, '')).mask(64);
return 'ip-' + BigInt('0b' + prefix).toString(36);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/misc/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class I18n<T extends Record<string, any>> {
}
}
return str;
} catch (e) {
} catch (_) {
console.warn(`missing localization '${key}'`);
return key;
}
Expand Down
2 changes: 0 additions & 2 deletions packages/backend/src/misc/json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@ type ObjectSchemaTypeDef<p extends Schema> =
never :
any;

type ObjectSchemaType<p extends Schema> = NullOrUndefined<p, ObjectSchemaTypeDef<p>>;

export type SchemaTypeDef<p extends Schema> =
p['type'] extends 'null' ? null :
p['type'] extends 'integer' ? number :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class MiAbuseReportNotificationRecipient {
/**
* 通知先のユーザ.
*/
@ManyToOne(type => MiUser, {
@ManyToOne(() => MiUser, {
onDelete: 'CASCADE',
})
@JoinColumn({ name: 'userId', referencedColumnName: 'id', foreignKeyConstraintName: 'FK_abuse_report_notification_recipient_userId1' })
Expand All @@ -76,7 +76,7 @@ export class MiAbuseReportNotificationRecipient {
/**
* 通知先のユーザプロフィール.
*/
@ManyToOne(type => MiUserProfile, {
@ManyToOne(() => MiUserProfile, {
onDelete: 'CASCADE',
})
@JoinColumn({ name: 'userId', referencedColumnName: 'userId', foreignKeyConstraintName: 'FK_abuse_report_notification_recipient_userId2' })
Expand All @@ -96,7 +96,7 @@ export class MiAbuseReportNotificationRecipient {
/**
* 通知先のシステムWebhook.
*/
@ManyToOne(type => MiSystemWebhook, {
@ManyToOne(() => MiSystemWebhook, {
onDelete: 'CASCADE',
})
@JoinColumn({ name: 'systemWebhookId', referencedColumnName: 'id', foreignKeyConstraintName: 'FK_abuse_report_notification_recipient_systemWebhookId' })
Expand Down
6 changes: 3 additions & 3 deletions packages/backend/src/models/AbuseUserReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class MiAbuseUserReport {
@Column(id())
public targetUserId: MiUser['id'];

@ManyToOne(type => MiUser, {
@ManyToOne(() => MiUser, {
onDelete: 'CASCADE',
})
@JoinColumn()
Expand All @@ -28,7 +28,7 @@ export class MiAbuseUserReport {
@Column(id())
public reporterId: MiUser['id'];

@ManyToOne(type => MiUser, {
@ManyToOne(() => MiUser, {
onDelete: 'CASCADE',
})
@JoinColumn()
Expand All @@ -40,7 +40,7 @@ export class MiAbuseUserReport {
})
public assigneeId: MiUser['id'] | null;

@ManyToOne(type => MiUser, {
@ManyToOne(() => MiUser, {
onDelete: 'SET NULL',
})
@JoinColumn()
Expand Down
Loading
Loading