Skip to content

Commit 453738d

Browse files
committed
style: format
1 parent f21c9ea commit 453738d

28 files changed

+154
-149
lines changed

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
docs
2+
dist
3+
pnpm-lock.yaml
4+
playground/**/*.json

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"docs:preview": "serve docs",
5151
"lint": "eslint --cache .",
5252
"lint:fix": "pnpm run lint --fix",
53+
"format": "prettier --cache --write .",
5354
"test": "vitest",
5455
"test:deno": "cd tests/deno && deno run --allow-net --import-map=import_map.json --allow-env index.ts",
5556
"release": "bumpp && pnpm publish",

src/api/comments.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const add = <T = Comments.AddResponse>(
1212
targetType: PostTypeRaw,
1313
targetId: string,
1414
content: string,
15-
option: AddCommentOption = {}
15+
option: AddCommentOption = {},
1616
) =>
1717
toResponse<T>(
1818
request.post('1.0/comments/add', {
@@ -27,37 +27,37 @@ export const add = <T = Comments.AddResponse>(
2727
targetType,
2828
replyToCommentId: option.replyToCommentId,
2929
},
30-
})
30+
}),
3131
)
3232

3333
export const like = <T = {}>(targetType: PostTypeRaw, id: string) =>
3434
toResponse<T>(
3535
request.post('1.0/comments/like', {
3636
json: { targetType, id },
37-
})
37+
}),
3838
)
3939

4040
export const unlike = <T = {}>(targetType: PostTypeRaw, id: string) =>
4141
toResponse<T>(
4242
request.post('1.0/comments/unlike', {
4343
json: { targetType, id },
44-
})
44+
}),
4545
)
4646

4747
export const remove = <T = Comments.RemoveResponse>(
4848
targetType: PostTypeRaw,
49-
id: string
49+
id: string,
5050
) =>
5151
toResponse<T>(
5252
request.post('1.0/comments/remove', {
5353
json: { targetType, id },
54-
})
54+
}),
5555
)
5656

5757
export const listPrimary = <T = Comments.ListPrimaryResponse>(
5858
targetType: PostTypeRaw,
5959
targetId: string,
60-
option: ListPrimaryCommentOption = {}
60+
option: ListPrimaryCommentOption = {},
6161
) =>
6262
toResponse<T>(
6363
request.post('1.0/comments/listPrimary', {
@@ -68,13 +68,13 @@ export const listPrimary = <T = Comments.ListPrimaryResponse>(
6868
limit: option.limit ?? 10,
6969
loadMoreKey: option.loadMoreKey,
7070
},
71-
})
71+
}),
7272
)
7373

7474
export const list = <T = Comments.ListResponse>(
7575
targetType: PostTypeRaw,
7676
threadId: string,
77-
option: PaginationOption<ListCommentMoreKey> = {}
77+
option: PaginationOption<ListCommentMoreKey> = {},
7878
) =>
7979
toResponse<T>(
8080
request.post('1.0/comments/list', {
@@ -84,5 +84,5 @@ export const list = <T = Comments.ListResponse>(
8484
limit: option.limit ?? 20,
8585
loadMoreKey: option.loadMoreKey,
8686
},
87-
})
87+
}),
8888
)

src/api/media-meta.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { InteractiveResponse } from '../types/api-responses'
1111
export const interactive = <T = InteractiveResponse>(
1212
id: string,
1313
type: LiteralUnion<'STORY'>,
14-
trigger: LiteralUnion<'user'> = 'user'
14+
trigger: LiteralUnion<'user'> = 'user',
1515
) =>
1616
toResponse<T>(
1717
request.post('1.0/mediaMeta/interactive', {
@@ -20,5 +20,5 @@ export const interactive = <T = InteractiveResponse>(
2020
type,
2121
trigger,
2222
},
23-
})
23+
}),
2424
)

src/api/notifications.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ export const list = <T = Notifications.ListResponse>(
1010
option: Pick<
1111
PaginationOption<{ lastNotificationId: string }>,
1212
'loadMoreKey'
13-
> = {}
13+
> = {},
1414
) =>
1515
toResponse<T>(
1616
request.post('1.0/notifications/list', {
1717
json: {
1818
loadMoreKey: option.loadMoreKey,
1919
},
20-
})
20+
}),
2121
)

src/api/personal-update.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { PersonalUpdate } from '../types/api-responses'
1010
*/
1111
export const single = <T = PersonalUpdate.SingleResponse>(
1212
username: string,
13-
option: PaginationOption<{ lastId: string }> = {}
13+
option: PaginationOption<{ lastId: string }> = {},
1414
) =>
1515
toResponse<T>(
1616
request.post('1.0/personalUpdate/single', {
@@ -19,7 +19,7 @@ export const single = <T = PersonalUpdate.SingleResponse>(
1919
limit: option.limit ?? 10,
2020
loadMoreKey: option.loadMoreKey,
2121
},
22-
})
22+
}),
2323
)
2424

2525
/**
@@ -31,45 +31,45 @@ export const followingUpdates = <T = PersonalUpdate.FollowingUpdatesResponse>(
3131
session: 'PopulatedUpdate'
3232
lastReadTime: number
3333
lastPageEarliestTime: number
34-
}> = {}
34+
}> = {},
3535
) =>
3636
toResponse<T>(
3737
request.post('1.0/personalUpdate/followingUpdates', {
3838
json: {
3939
limit: option.limit ?? 10,
4040
loadMoreKey: option.loadMoreKey,
4141
},
42-
})
42+
}),
4343
)
4444

4545
/**
4646
* 置顶动态
4747
*/
4848
export const pin = <T = PersonalUpdate.PinResponse>(
4949
type: PostTypeRaw,
50-
id: string
50+
id: string,
5151
) =>
5252
toResponse<T>(
5353
request.post('1.0/personalUpdate/pin', {
5454
json: {
5555
id,
5656
type,
5757
},
58-
})
58+
}),
5959
)
6060

6161
/**
6262
* 取消置顶动态
6363
*/
6464
export const unpin = <T = PersonalUpdate.UnpinResponse>(
6565
type: PostTypeRaw,
66-
id: string
66+
id: string,
6767
) =>
6868
toResponse<T>(
6969
request.post('1.0/personalUpdate/unpin', {
7070
json: {
7171
id,
7272
type,
7373
},
74-
})
74+
}),
7575
)

src/api/posts.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { Posts } from '../types/api-responses'
1414
export const create = <T = Posts.CreateResponse>(
1515
type: PostType,
1616
content: string,
17-
options: CreatePostOption = {}
17+
options: CreatePostOption = {},
1818
) =>
1919
toResponse<T>(
2020
request.post(`1.0/${type}/create`, {
@@ -25,7 +25,7 @@ export const create = <T = Posts.CreateResponse>(
2525
submitToTopic: options.topicId,
2626
linkInfo: options.linkInfo,
2727
},
28-
})
28+
}),
2929
)
3030

3131
/**
@@ -36,7 +36,7 @@ export const get = <T = Posts.GetResponse>(type: PostType, id: string) =>
3636
toResponse<T>(
3737
request(`1.0/${type}/get`, {
3838
searchParams: { id },
39-
})
39+
}),
4040
)
4141

4242
/**
@@ -52,7 +52,7 @@ export const share = <T = {}>(type: PostType, id: string, method: string) =>
5252
id,
5353
method,
5454
},
55-
})
55+
}),
5656
)
5757

5858
/**
@@ -63,7 +63,7 @@ export const like = <T = {}>(type: PostType, id: string) =>
6363
toResponse<T>(
6464
request.post(`1.0/${type}/like`, {
6565
json: { id },
66-
})
66+
}),
6767
)
6868

6969
/**
@@ -74,7 +74,7 @@ export const unlike = <T = {}>(type: PostType, id: string) =>
7474
toResponse<T>(
7575
request.post(`1.0/${type}/unlike`, {
7676
json: { id },
77-
})
77+
}),
7878
)
7979

8080
/**
@@ -85,7 +85,7 @@ export const remove = <T = Posts.RemoveResponse>(type: PostType, id: string) =>
8585
toResponse<T>(
8686
request.post(`1.0/${type}/remove`, {
8787
json: { id },
88-
})
88+
}),
8989
)
9090

9191
/**
@@ -95,7 +95,7 @@ export const remove = <T = Posts.RemoveResponse>(type: PostType, id: string) =>
9595
export const listLikedUsers = <T = Posts.ListLikedUsersResponse>(
9696
type: PostType,
9797
id: string,
98-
option: PaginationOption<string> = {}
98+
option: PaginationOption<string> = {},
9999
) =>
100100
toResponse<T>(
101101
request.post(`1.0/${type}/listLikedUsers`, {
@@ -104,7 +104,7 @@ export const listLikedUsers = <T = Posts.ListLikedUsersResponse>(
104104
limit: option.limit ?? 100,
105105
loadMoreKey: option.loadMoreKey,
106106
},
107-
})
107+
}),
108108
)
109109

110110
/**
@@ -115,7 +115,7 @@ export const hide = <T = Posts.HideResponse>(type: PostType, id: string) =>
115115
toResponse<T>(
116116
request.post(`1.0/${type}/sponsor/hide`, {
117117
json: { id },
118-
})
118+
}),
119119
)
120120

121121
/**
@@ -126,5 +126,5 @@ export const recover = <T = Posts.HideResponse>(type: PostType, id: string) =>
126126
toResponse<T>(
127127
request.post(`1.0/${type}/sponsor/recover`, {
128128
json: { id },
129-
})
129+
}),
130130
)

src/api/recommend-feed.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { RecommendFeed } from '../types/api-responses'
77
* @param option 选项
88
*/
99
export const list = <T = RecommendFeed.ListResponse>(
10-
option: ListRecommendFeedOption = {}
10+
option: ListRecommendFeedOption = {},
1111
) =>
1212
toResponse<T>(
1313
request.post('1.0/recommendFeed/list', {
@@ -16,5 +16,5 @@ export const list = <T = RecommendFeed.ListResponse>(
1616
trigger: option.trigger ?? 'auto',
1717
loadMoreKey: option.loadMoreKey,
1818
},
19-
})
19+
}),
2020
)

src/api/stories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export const followingFeed = <T = Stories.FollowingFeedResponse>() =>
1212
* @param username 用户名
1313
*/
1414
export const listUserStories = <T = Stories.ListUserStoriesResponse>(
15-
username: string
15+
username: string,
1616
) =>
1717
toResponse<T>(
1818
request.get('1.0/stories/listUserStories', {
1919
searchParams: {
2020
username,
2121
},
22-
})
22+
}),
2323
)

src/api/topics.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { PaginationOption } from '../types/options'
1111
export const getTabsSquareFeed = <T = Topics.GetTabsSquareFeedResponse>(
1212
topicId: string,
1313
// NOTE: suppressed 应该传 false,但不知道这个参数是什么意思
14-
option: PaginationOption<{ lastId: string; suppressed: boolean }> = {}
14+
option: PaginationOption<{ lastId: string; suppressed: boolean }> = {},
1515
) =>
1616
toResponse<T>(
1717
request.post('1.0/topics/tabs/square/feed', {
@@ -20,7 +20,7 @@ export const getTabsSquareFeed = <T = Topics.GetTabsSquareFeedResponse>(
2020
limit: option.limit ?? 10,
2121
loadMoreKey: option.loadMoreKey,
2222
},
23-
})
23+
}),
2424
)
2525

2626
/**
@@ -30,7 +30,7 @@ export const getTabsSquareFeed = <T = Topics.GetTabsSquareFeedResponse>(
3030
*/
3131
export const getTabsSelectedFeed = <T = Topics.GetTabsSelectedFeedResponse>(
3232
topicId: string,
33-
option: PaginationOption<{ offset: number }> = {}
33+
option: PaginationOption<{ offset: number }> = {},
3434
) =>
3535
toResponse<T>(
3636
request.post('1.0/topics/tabs/selected/feed', {
@@ -39,7 +39,7 @@ export const getTabsSelectedFeed = <T = Topics.GetTabsSelectedFeedResponse>(
3939
limit: option.limit ?? 10,
4040
loadMoreKey: option.loadMoreKey,
4141
},
42-
})
42+
}),
4343
)
4444

4545
/**
@@ -54,7 +54,7 @@ export const search = <T = Topics.SearchResponse>(
5454
type?: LiteralUnion<'ALL'>
5555
/** 仅用户发帖时为 true */
5656
onlyUserPostEnabled?: boolean
57-
} = {}
57+
} = {},
5858
) =>
5959
toResponse<T>(
6060
request.post('1.0/users/topics/search', {
@@ -65,5 +65,5 @@ export const search = <T = Topics.SearchResponse>(
6565
limit: option.limit ?? 20,
6666
loadMoreKey: option.loadMoreKey,
6767
},
68-
})
68+
}),
6969
)

src/api/upload.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ export const token = <T = Upload.TokenResponse>(md5: string) =>
77
toResponse<T>(
88
request.get('1.0/upload/token', {
99
searchParams: { md5 },
10-
})
10+
}),
1111
)
1212

1313
export const upload = async (
1414
image: NodeBlob | Blob | Buffer,
15-
token: string
15+
token: string,
1616
) => {
1717
let file: Blob
1818
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(image)) {

0 commit comments

Comments
 (0)