Skip to content

Commit 409eeb9

Browse files
committed
chore: 更新 Prettier 設定中的 printWidth 至 140
1 parent fcd2173 commit 409eeb9

7 files changed

Lines changed: 8 additions & 31 deletions

File tree

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"printWidth": 100,
2+
"printWidth": 140,
33
"singleQuote": false,
44
"semi": true,
55
"tabWidth": 2,

src/eventRouter.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ export async function eventRouter(event: any, channelAccessToken: string, ctx: E
1515
case "text":
1616
switch (event.message.text) {
1717
case "debug":
18-
const {
19-
id: versionId,
20-
tag: versionTag,
21-
timestamp: versionTimestamp,
22-
} = env.CF_VERSION_METADATA;
18+
const { id: versionId, tag: versionTag, timestamp: versionTimestamp } = env.CF_VERSION_METADATA;
2319
await sendMessage(channelAccessToken, event.replyToken, [
2420
{
2521
type: "text",

src/router.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ export async function router(request: Request, env: Env, ctx: ExecutionContext)
88
return new Response("Method Not Allowed", { status: 405 });
99
}
1010
// 取得環境變數
11-
const [channelSecret, channelAccessToken] = await Promise.all([
12-
env.LINE_CHANNEL_SECRET.get(),
13-
env.LINE_CHANNEL_ACCESS_TOKEN.get(),
14-
]);
11+
const [channelSecret, channelAccessToken] = await Promise.all([env.LINE_CHANNEL_SECRET.get(), env.LINE_CHANNEL_ACCESS_TOKEN.get()]);
1512
if (!channelSecret || !channelAccessToken) {
1613
return new Response("Server misconfigured", { status: 500 });
1714
}

src/utils/eventRoutes/loadStart.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
export async function loadStart(
2-
ChannelAccessToken: string,
3-
chatId: string,
4-
loadingSeconds: number,
5-
) {
1+
export async function loadStart(ChannelAccessToken: string, chatId: string, loadingSeconds: number) {
62
const res = await fetch("https://api.line.me/v2/bot/chat/loading/start", {
73
headers: {
84
"Content-Type": "application/json",

src/utils/hmacSHA256Base64.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
export async function hmacSHA256Base64(secret: string, message: string): Promise<string> {
22
const enc = new TextEncoder();
33

4-
const key = await crypto.subtle.importKey(
5-
"raw",
6-
enc.encode(secret),
7-
{ name: "HMAC", hash: "SHA-256" },
8-
false,
9-
["sign"],
10-
);
4+
const key = await crypto.subtle.importKey("raw", enc.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
115

126
const signature = await crypto.subtle.sign("HMAC", key, enc.encode(message));
137

test/eventRouter.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ describe("eventRouter", () => {
3333
expect(ctx.waitUntil).toHaveBeenCalledTimes(1);
3434
expect(mocks.markAsRead).toHaveBeenCalledWith("accessToken", "mark-token");
3535
expect(mocks.loadStart).toHaveBeenCalledWith("accessToken", "U123", 5);
36-
expect(mocks.sendMessage).toHaveBeenCalledWith("accessToken", "reply-token", [
37-
{ type: "text", text: "Hi" },
38-
]);
36+
expect(mocks.sendMessage).toHaveBeenCalledWith("accessToken", "reply-token", [{ type: "text", text: "Hi" }]);
3937
});
4038

4139
it("handles 'hi' message", async () => {
@@ -49,9 +47,7 @@ describe("eventRouter", () => {
4947

5048
await eventRouter(event, "accessToken", ctx);
5149

52-
expect(mocks.sendMessage).toHaveBeenCalledWith("accessToken", "reply-token", [
53-
{ type: "text", text: "Hi" },
54-
]);
50+
expect(mocks.sendMessage).toHaveBeenCalledWith("accessToken", "reply-token", [{ type: "text", text: "Hi" }]);
5551
});
5652

5753
it("handles default text message", async () => {

vitest.config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import { fileURLToPath } from "node:url";
44
export default defineConfig({
55
resolve: {
66
alias: {
7-
"cloudflare:workers": fileURLToPath(
8-
new URL("./test/mocks/cloudflare-workers.ts", import.meta.url),
9-
),
7+
"cloudflare:workers": fileURLToPath(new URL("./test/mocks/cloudflare-workers.ts", import.meta.url)),
108
},
119
},
1210
test: {

0 commit comments

Comments
 (0)