chore: 🚨 lint megalodon
This commit is contained in:
parent
34e2f7ada6
commit
a75a19cd17
@ -16,7 +16,7 @@
|
||||
"build": "pnpm swc src -d built -D",
|
||||
"build:debug": "pnpm swc src -d built -s -D",
|
||||
"watch": "pnpm swc src -d built -D -w",
|
||||
"lint": "pnpm rome check --apply **/*.ts",
|
||||
"lint": "pnpm rome check --apply **/*.ts ; pnpm run format",
|
||||
"mocha": "cross-env NODE_ENV=test TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true TS_NODE_PROJECT=\"./test/tsconfig.json\" mocha",
|
||||
"test": "pnpm run mocha",
|
||||
"format": "pnpm rome format * --write"
|
||||
|
@ -1514,7 +1514,7 @@ export default class Misskey implements MegalodonInterface {
|
||||
if (status.quote != null)
|
||||
status.quote = await this.addMentionsToStatus(status.quote, cache);
|
||||
|
||||
const idx = status.account.acct.indexOf('@');
|
||||
const idx = status.account.acct.indexOf("@");
|
||||
const origin = idx < 0 ? null : status.account.acct.substring(idx + 1);
|
||||
|
||||
status.mentions = (
|
||||
@ -1523,22 +1523,25 @@ export default class Misskey implements MegalodonInterface {
|
||||
for (const m of status.mentions.filter(
|
||||
(value, index, array) => array.indexOf(value) === index,
|
||||
)) {
|
||||
const regexFull = new RegExp(`(?<=^|\\s|>)@${m.acct}(?=[^a-zA-Z0-9]|$)`, 'gi');
|
||||
const regexLocalUser = new RegExp(`(?<=^|\\s|>)@${m.acct}@${this.baseUrlToHost(this.baseUrl)}(?=[^a-zA-Z0-9]|$)`, 'gi');
|
||||
const regexRemoteUser = new RegExp(`(?<=^|\\s|>)@${m.username}(?=[^a-zA-Z0-9@]|$)`, 'gi');
|
||||
const regexFull = new RegExp(
|
||||
`(?<=^|\\s|>)@${m.acct}(?=[^a-zA-Z0-9]|$)`,
|
||||
"gi",
|
||||
);
|
||||
const regexLocalUser = new RegExp(
|
||||
`(?<=^|\\s|>)@${m.acct}@${this.baseUrlToHost(
|
||||
this.baseUrl,
|
||||
)}(?=[^a-zA-Z0-9]|$)`,
|
||||
"gi",
|
||||
);
|
||||
const regexRemoteUser = new RegExp(
|
||||
`(?<=^|\\s|>)@${m.username}(?=[^a-zA-Z0-9@]|$)`,
|
||||
"gi",
|
||||
);
|
||||
|
||||
if (m.acct == m.username) {
|
||||
status.content = status.content.replace(
|
||||
regexLocalUser,
|
||||
`@${m.acct}`,
|
||||
);
|
||||
}
|
||||
|
||||
else if (!status.content.match(regexFull)) {
|
||||
status.content = status.content.replace(
|
||||
regexRemoteUser,
|
||||
`@${m.acct}`,
|
||||
);
|
||||
status.content = status.content.replace(regexLocalUser, `@${m.acct}`);
|
||||
} else if (!status.content.match(regexFull)) {
|
||||
status.content = status.content.replace(regexRemoteUser, `@${m.acct}`);
|
||||
}
|
||||
|
||||
status.content = status.content.replace(
|
||||
@ -2015,7 +2018,10 @@ export default class Misskey implements MegalodonInterface {
|
||||
*/
|
||||
private reactionName(name: string): string {
|
||||
// See: https://github.com/tc39/proposal-regexp-unicode-property-escapes#matching-emoji
|
||||
const isUnicodeEmoji = /\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F/gu.test(name);
|
||||
const isUnicodeEmoji =
|
||||
/\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F/gu.test(
|
||||
name,
|
||||
);
|
||||
if (isUnicodeEmoji) {
|
||||
return name;
|
||||
}
|
||||
@ -2025,7 +2031,10 @@ export default class Misskey implements MegalodonInterface {
|
||||
/**
|
||||
* POST /api/notes/reactions/create
|
||||
*/
|
||||
public async reactStatus(id: string, name: string): Promise<Response<Entity.Status>> {
|
||||
public async reactStatus(
|
||||
id: string,
|
||||
name: string,
|
||||
): Promise<Response<Entity.Status>> {
|
||||
await this.client.post<{}>("/api/notes/reactions/create", {
|
||||
noteId: id,
|
||||
reaction: this.reactionName(name),
|
||||
@ -2047,7 +2056,10 @@ export default class Misskey implements MegalodonInterface {
|
||||
/**
|
||||
* POST /api/notes/reactions/delete
|
||||
*/
|
||||
public async unreactStatus(id: string, name: string): Promise<Response<Entity.Status>> {
|
||||
public async unreactStatus(
|
||||
id: string,
|
||||
name: string,
|
||||
): Promise<Response<Entity.Status>> {
|
||||
await this.client.post<{}>("/api/notes/reactions/delete", {
|
||||
noteId: id,
|
||||
reaction: this.reactionName(name),
|
||||
@ -3037,7 +3049,9 @@ export default class Misskey implements MegalodonInterface {
|
||||
}
|
||||
|
||||
try {
|
||||
const match = q.match(/^@(?<user>[a-zA-Z0-9_]+)(?:@(?<host>[a-zA-Z0-9-.]+\.[a-zA-Z0-9-]+)|)$/);
|
||||
const match = q.match(
|
||||
/^@(?<user>[a-zA-Z0-9_]+)(?:@(?<host>[a-zA-Z0-9-.]+\.[a-zA-Z0-9-]+)|)$/,
|
||||
);
|
||||
if (match) {
|
||||
const lookupQuery = {
|
||||
username: match.groups?.user,
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace MisskeyEntity {
|
||||
export type GetAll = {
|
||||
tutorial: number
|
||||
defaultNoteVisibility: 'public' | 'home' | 'followers' | 'specified'
|
||||
}
|
||||
tutorial: number;
|
||||
defaultNoteVisibility: "public" | "home" | "followers" | "specified";
|
||||
};
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
namespace MisskeyEntity {
|
||||
export type Announcement = {
|
||||
id: string
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
text: string
|
||||
title: string
|
||||
isRead?: boolean
|
||||
}
|
||||
id: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
text: string;
|
||||
title: string;
|
||||
isRead?: boolean;
|
||||
};
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
namespace MisskeyEntity {
|
||||
export type App = {
|
||||
id: string
|
||||
name: string
|
||||
callbackUrl: string
|
||||
permission: Array<string>
|
||||
secret: string
|
||||
}
|
||||
id: string;
|
||||
name: string;
|
||||
callbackUrl: string;
|
||||
permission: Array<string>;
|
||||
secret: string;
|
||||
};
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type Blocking = {
|
||||
id: string
|
||||
createdAt: string
|
||||
blockeeId: string
|
||||
blockee: UserDetail
|
||||
}
|
||||
id: string;
|
||||
createdAt: string;
|
||||
blockeeId: string;
|
||||
blockee: UserDetail;
|
||||
};
|
||||
}
|
||||
|
@ -2,6 +2,6 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type CreatedNote = {
|
||||
createdNote: Note
|
||||
}
|
||||
createdNote: Note;
|
||||
};
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
namespace MisskeyEntity {
|
||||
export type Emoji = {
|
||||
name: string
|
||||
host: string | null
|
||||
url: string
|
||||
aliases: Array<string>
|
||||
category: string
|
||||
}
|
||||
name: string;
|
||||
host: string | null;
|
||||
url: string;
|
||||
aliases: Array<string>;
|
||||
category: string;
|
||||
};
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type Favorite = {
|
||||
id: string
|
||||
createdAt: string
|
||||
noteId: string
|
||||
note: Note
|
||||
}
|
||||
id: string;
|
||||
createdAt: string;
|
||||
noteId: string;
|
||||
note: Note;
|
||||
};
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
namespace MisskeyEntity {
|
||||
export type Field = {
|
||||
name: string
|
||||
value: string
|
||||
verified?: string
|
||||
}
|
||||
name: string;
|
||||
value: string;
|
||||
verified?: string;
|
||||
};
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
namespace MisskeyEntity {
|
||||
export type File = {
|
||||
id: string
|
||||
createdAt: string
|
||||
name: string
|
||||
type: string
|
||||
md5: string
|
||||
size: number
|
||||
isSensitive: boolean
|
||||
id: string;
|
||||
createdAt: string;
|
||||
name: string;
|
||||
type: string;
|
||||
md5: string;
|
||||
size: number;
|
||||
isSensitive: boolean;
|
||||
properties: {
|
||||
width: number
|
||||
height: number
|
||||
avgColor: string
|
||||
}
|
||||
url: string
|
||||
thumbnailUrl: string
|
||||
comment: string
|
||||
blurhash: string
|
||||
}
|
||||
width: number;
|
||||
height: number;
|
||||
avgColor: string;
|
||||
};
|
||||
url: string;
|
||||
thumbnailUrl: string;
|
||||
comment: string;
|
||||
blurhash: string;
|
||||
};
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type FollowRequest = {
|
||||
id: string
|
||||
follower: User
|
||||
followee: User
|
||||
}
|
||||
id: string;
|
||||
follower: User;
|
||||
followee: User;
|
||||
};
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type Follower = {
|
||||
id: string
|
||||
createdAt: string
|
||||
followeeId: string
|
||||
followerId: string
|
||||
follower: UserDetail
|
||||
}
|
||||
id: string;
|
||||
createdAt: string;
|
||||
followeeId: string;
|
||||
followerId: string;
|
||||
follower: UserDetail;
|
||||
};
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type Following = {
|
||||
id: string
|
||||
createdAt: string
|
||||
followeeId: string
|
||||
followerId: string
|
||||
followee: UserDetail
|
||||
}
|
||||
id: string;
|
||||
createdAt: string;
|
||||
followeeId: string;
|
||||
followerId: string;
|
||||
followee: UserDetail;
|
||||
};
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
namespace MisskeyEntity {
|
||||
export type Hashtag = {
|
||||
tag: string
|
||||
chart: Array<number>
|
||||
usersCount: number
|
||||
}
|
||||
tag: string;
|
||||
chart: Array<number>;
|
||||
usersCount: number;
|
||||
};
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
namespace MisskeyEntity {
|
||||
export type List = {
|
||||
id: string
|
||||
createdAt: string
|
||||
name: string
|
||||
userIds: Array<string>
|
||||
}
|
||||
id: string;
|
||||
createdAt: string;
|
||||
name: string;
|
||||
userIds: Array<string>;
|
||||
};
|
||||
}
|
||||
|
@ -2,17 +2,17 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type Meta = {
|
||||
maintainerName: string
|
||||
maintainerEmail: string
|
||||
name: string
|
||||
version: string
|
||||
uri: string
|
||||
description: string
|
||||
langs: Array<string>
|
||||
disableRegistration: boolean
|
||||
disableLocalTimeline: boolean
|
||||
bannerUrl: string
|
||||
maxNoteTextLength: 3000
|
||||
emojis: Array<Emoji>
|
||||
}
|
||||
maintainerName: string;
|
||||
maintainerEmail: string;
|
||||
name: string;
|
||||
version: string;
|
||||
uri: string;
|
||||
description: string;
|
||||
langs: Array<string>;
|
||||
disableRegistration: boolean;
|
||||
disableLocalTimeline: boolean;
|
||||
bannerUrl: string;
|
||||
maxNoteTextLength: 3000;
|
||||
emojis: Array<Emoji>;
|
||||
};
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type Mute = {
|
||||
id: string
|
||||
createdAt: string
|
||||
muteeId: string
|
||||
mutee: UserDetail
|
||||
}
|
||||
id: string;
|
||||
createdAt: string;
|
||||
muteeId: string;
|
||||
mutee: UserDetail;
|
||||
};
|
||||
}
|
||||
|
@ -5,28 +5,28 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type Note = {
|
||||
id: string
|
||||
createdAt: string
|
||||
userId: string
|
||||
user: User
|
||||
text: string | null
|
||||
cw: string | null
|
||||
visibility: 'public' | 'home' | 'followers' | 'specified'
|
||||
renoteCount: number
|
||||
repliesCount: number
|
||||
reactions: { [key: string]: number }
|
||||
emojis: Array<Emoji>
|
||||
fileIds: Array<string>
|
||||
files: Array<File>
|
||||
replyId: string | null
|
||||
renoteId: string | null
|
||||
uri?: string
|
||||
reply?: Note
|
||||
renote?: Note
|
||||
viaMobile?: boolean
|
||||
tags?: Array<string>
|
||||
poll?: Poll
|
||||
mentions?: Array<string>
|
||||
myReaction?: string
|
||||
}
|
||||
id: string;
|
||||
createdAt: string;
|
||||
userId: string;
|
||||
user: User;
|
||||
text: string | null;
|
||||
cw: string | null;
|
||||
visibility: "public" | "home" | "followers" | "specified";
|
||||
renoteCount: number;
|
||||
repliesCount: number;
|
||||
reactions: { [key: string]: number };
|
||||
emojis: Array<Emoji>;
|
||||
fileIds: Array<string>;
|
||||
files: Array<File>;
|
||||
replyId: string | null;
|
||||
renoteId: string | null;
|
||||
uri?: string;
|
||||
reply?: Note;
|
||||
renote?: Note;
|
||||
viaMobile?: boolean;
|
||||
tags?: Array<string>;
|
||||
poll?: Poll;
|
||||
mentions?: Array<string>;
|
||||
myReaction?: string;
|
||||
};
|
||||
}
|
||||
|
@ -3,15 +3,15 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type Notification = {
|
||||
id: string
|
||||
createdAt: string
|
||||
id: string;
|
||||
createdAt: string;
|
||||
// https://github.com/syuilo/misskey/blob/056942391aee135eb6c77aaa63f6ed5741d701a6/src/models/entities/notification.ts#L50-L62
|
||||
type: NotificationType
|
||||
userId: string
|
||||
user: User
|
||||
note?: Note
|
||||
reaction?: string
|
||||
}
|
||||
type: NotificationType;
|
||||
userId: string;
|
||||
user: User;
|
||||
note?: Note;
|
||||
reaction?: string;
|
||||
};
|
||||
|
||||
export type NotificationType = string
|
||||
export type NotificationType = string;
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
namespace MisskeyEntity {
|
||||
export type Choice = {
|
||||
text: string
|
||||
votes: number
|
||||
isVoted: boolean
|
||||
}
|
||||
text: string;
|
||||
votes: number;
|
||||
isVoted: boolean;
|
||||
};
|
||||
|
||||
export type Poll = {
|
||||
multiple: boolean
|
||||
expiresAt: string
|
||||
choices: Array<Choice>
|
||||
}
|
||||
multiple: boolean;
|
||||
expiresAt: string;
|
||||
choices: Array<Choice>;
|
||||
};
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type Reaction = {
|
||||
id: string
|
||||
createdAt: string
|
||||
user: User
|
||||
url?: string
|
||||
type: string
|
||||
}
|
||||
id: string;
|
||||
createdAt: string;
|
||||
user: User;
|
||||
url?: string;
|
||||
type: string;
|
||||
};
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
namespace MisskeyEntity {
|
||||
export type Relation = {
|
||||
id: string
|
||||
isFollowing: boolean
|
||||
hasPendingFollowRequestFromYou: boolean
|
||||
hasPendingFollowRequestToYou: boolean
|
||||
isFollowed: boolean
|
||||
isBlocking: boolean
|
||||
isBlocked: boolean
|
||||
isMuted: boolean
|
||||
}
|
||||
id: string;
|
||||
isFollowing: boolean;
|
||||
hasPendingFollowRequestFromYou: boolean;
|
||||
hasPendingFollowRequestToYou: boolean;
|
||||
isFollowed: boolean;
|
||||
isBlocking: boolean;
|
||||
isBlocked: boolean;
|
||||
isMuted: boolean;
|
||||
};
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace MisskeyEntity {
|
||||
export type Session = {
|
||||
token: string
|
||||
url: string
|
||||
}
|
||||
token: string;
|
||||
url: string;
|
||||
};
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
namespace MisskeyEntity {
|
||||
export type State = {
|
||||
isFavorited: boolean
|
||||
isMutedThread: boolean
|
||||
isWatching: boolean
|
||||
}
|
||||
isFavorited: boolean;
|
||||
isMutedThread: boolean;
|
||||
isWatching: boolean;
|
||||
};
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
namespace MisskeyEntity {
|
||||
export type Stats = {
|
||||
notesCount: number
|
||||
originalNotesCount: number
|
||||
usersCount: number
|
||||
originalUsersCount: number
|
||||
instances: number
|
||||
}
|
||||
notesCount: number;
|
||||
originalNotesCount: number;
|
||||
usersCount: number;
|
||||
originalUsersCount: number;
|
||||
instances: number;
|
||||
};
|
||||
}
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type User = {
|
||||
id: string
|
||||
name: string
|
||||
username: string
|
||||
host: string | null
|
||||
avatarUrl: string
|
||||
avatarColor: string
|
||||
emojis: Array<Emoji>
|
||||
}
|
||||
id: string;
|
||||
name: string;
|
||||
username: string;
|
||||
host: string | null;
|
||||
avatarUrl: string;
|
||||
avatarColor: string;
|
||||
emojis: Array<Emoji>;
|
||||
};
|
||||
}
|
||||
|
@ -4,31 +4,31 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type UserDetail = {
|
||||
id: string
|
||||
name: string
|
||||
username: string
|
||||
host: string | null
|
||||
avatarUrl: string
|
||||
avatarColor: string
|
||||
isAdmin: boolean
|
||||
isModerator: boolean
|
||||
isBot: boolean
|
||||
isCat: boolean
|
||||
emojis: Array<Emoji>
|
||||
createdAt: string
|
||||
bannerUrl: string
|
||||
bannerColor: string
|
||||
isLocked: boolean
|
||||
isSilenced: boolean
|
||||
isSuspended: boolean
|
||||
description: string
|
||||
followersCount: number
|
||||
followingCount: number
|
||||
notesCount: number
|
||||
avatarId: string
|
||||
bannerId: string
|
||||
pinnedNoteIds?: Array<string>
|
||||
pinnedNotes?: Array<Note>
|
||||
fields: Array<Field>
|
||||
}
|
||||
id: string;
|
||||
name: string;
|
||||
username: string;
|
||||
host: string | null;
|
||||
avatarUrl: string;
|
||||
avatarColor: string;
|
||||
isAdmin: boolean;
|
||||
isModerator: boolean;
|
||||
isBot: boolean;
|
||||
isCat: boolean;
|
||||
emojis: Array<Emoji>;
|
||||
createdAt: string;
|
||||
bannerUrl: string;
|
||||
bannerColor: string;
|
||||
isLocked: boolean;
|
||||
isSilenced: boolean;
|
||||
isSuspended: boolean;
|
||||
description: string;
|
||||
followersCount: number;
|
||||
followingCount: number;
|
||||
notesCount: number;
|
||||
avatarId: string;
|
||||
bannerId: string;
|
||||
pinnedNoteIds?: Array<string>;
|
||||
pinnedNotes?: Array<Note>;
|
||||
fields: Array<Field>;
|
||||
};
|
||||
}
|
||||
|
@ -4,33 +4,33 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type UserDetailMe = {
|
||||
id: string
|
||||
name: string
|
||||
username: string
|
||||
host: string | null
|
||||
avatarUrl: string
|
||||
avatarColor: string
|
||||
isAdmin: boolean
|
||||
isModerator: boolean
|
||||
isBot: boolean
|
||||
isCat: boolean
|
||||
emojis: Array<Emoji>
|
||||
createdAt: string
|
||||
bannerUrl: string
|
||||
bannerColor: string
|
||||
isLocked: boolean
|
||||
isSilenced: boolean
|
||||
isSuspended: boolean
|
||||
description: string
|
||||
followersCount: number
|
||||
followingCount: number
|
||||
notesCount: number
|
||||
avatarId: string
|
||||
bannerId: string
|
||||
pinnedNoteIds?: Array<string>
|
||||
pinnedNotes?: Array<Note>
|
||||
fields: Array<Field>
|
||||
alwaysMarkNsfw: boolean
|
||||
lang: string | null
|
||||
}
|
||||
id: string;
|
||||
name: string;
|
||||
username: string;
|
||||
host: string | null;
|
||||
avatarUrl: string;
|
||||
avatarColor: string;
|
||||
isAdmin: boolean;
|
||||
isModerator: boolean;
|
||||
isBot: boolean;
|
||||
isCat: boolean;
|
||||
emojis: Array<Emoji>;
|
||||
createdAt: string;
|
||||
bannerUrl: string;
|
||||
bannerColor: string;
|
||||
isLocked: boolean;
|
||||
isSilenced: boolean;
|
||||
isSuspended: boolean;
|
||||
description: string;
|
||||
followersCount: number;
|
||||
followingCount: number;
|
||||
notesCount: number;
|
||||
avatarId: string;
|
||||
bannerId: string;
|
||||
pinnedNoteIds?: Array<string>;
|
||||
pinnedNotes?: Array<Note>;
|
||||
fields: Array<Field>;
|
||||
alwaysMarkNsfw: boolean;
|
||||
lang: string | null;
|
||||
};
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace MisskeyEntity {
|
||||
export type UserKey = {
|
||||
accessToken: string
|
||||
user: User
|
||||
}
|
||||
accessToken: string;
|
||||
user: User;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user