chore(lint): enable object-shorthand (#81808) · openclaw/openclaw@425a4ab
tanshanshan
·
2026-05-31
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1097,7 +1097,6 @@ export function resolvePoolAcquire(params: AttemptParamsLike): {
|
1097 | 1097 | }, |
1098 | 1098 | options: { |
1099 | 1099 | copilotHome: resolved.copilotHome, |
1100 | | -cwd: readString(params.cwd) ?? readString(params.workspaceDir), |
1101 | 1100 | gitHubToken: resolved.authMode === "gitHubToken" ? resolved.gitHubToken : undefined, |
1102 | 1101 | useLoggedInUser: resolved.authMode === "useLoggedInUser", |
1103 | 1102 | }, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -66,7 +66,6 @@ function makeOptions(overrides: Partial<ClientCreateOptions> = {}): ClientCreate
|
66 | 66 | copilotHome: overrides.copilotHome ?? "copilot-home", |
67 | 67 | useLoggedInUser: overrides.useLoggedInUser ?? true, |
68 | 68 | gitHubToken: overrides.gitHubToken, |
69 | | -cwd: overrides.cwd, |
70 | 69 | }; |
71 | 70 | } |
72 | 71 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -20,10 +20,9 @@ export interface PoolKey {
|
20 | 20 | |
21 | 21 | export interface ClientCreateOptions extends Omit< |
22 | 22 | CopilotClientOptions, |
23 | | -"baseDirectory" | "gitHubToken" | "useLoggedInUser" | "workingDirectory" |
| 23 | +"baseDirectory" | "workingDirectory" | "useLoggedInUser" | "gitHubToken" |
24 | 24 | > { |
25 | 25 | readonly copilotHome: string; |
26 | | -readonly cwd?: string; |
27 | 26 | readonly useLoggedInUser?: boolean; |
28 | 27 | readonly gitHubToken?: string; |
29 | 28 | } |
@@ -362,11 +361,10 @@ function normalizeClientCreateOptions(
|
362 | 361 | options: ClientCreateOptions, |
363 | 362 | normalizedCopilotHome: string, |
364 | 363 | ): CopilotClientOptions { |
365 | | -const { copilotHome: _copilotHome, cwd, ...clientOptions } = options; |
| 364 | +const { copilotHome: _copilotHome, ...clientOptions } = options; |
366 | 365 | return { |
367 | 366 | ...clientOptions, |
368 | 367 | baseDirectory: normalizedCopilotHome, |
369 | | -workingDirectory: cwd, |
370 | 368 | }; |
371 | 369 | } |
372 | 370 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -169,6 +169,19 @@ describe("SMS account config", () => {
|
169 | 169 | }); |
170 | 170 | }); |
171 | 171 | |
| 172 | +it("coerces numeric allowFrom entries accepted by the config schema", () => { |
| 173 | +const parsed = SmsConfigSchema.parse({ |
| 174 | +accountSid: "AC123", |
| 175 | +authToken: "token", |
| 176 | +fromNumber: "+15550001111", |
| 177 | +allowFrom: [15551234567], |
| 178 | +}); |
| 179 | + |
| 180 | +expect(resolveSmsAccount({ channels: { sms: parsed } })).toMatchObject({ |
| 181 | +allowFrom: ["+15551234567"], |
| 182 | +}); |
| 183 | +}); |
| 184 | + |
172 | 185 | it("discovers env-only SMS credentials as the implicit default account", () => { |
173 | 186 | process.env.TWILIO_ACCOUNT_SID = "AC-env"; |
174 | 187 | process.env.TWILIO_AUTH_TOKEN = "env-token"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -24,13 +24,16 @@ function getChannelConfig(cfg: OpenClawConfig): SmsChannelConfig | undefined {
|
24 | 24 | return cfg?.channels?.[CHANNEL_ID] as SmsChannelConfig | undefined; |
25 | 25 | } |
26 | 26 | |
27 | | -function parseList(raw: string | string[] | undefined): string[] { |
| 27 | +function parseList(raw: unknown): string[] { |
28 | 28 | if (!raw) { |
29 | 29 | return []; |
30 | 30 | } |
31 | | -return (Array.isArray(raw) ? raw : normalizeStringEntries(raw.split(","))) |
32 | | -.map((entry) => normalizeSmsAllowFrom(entry)) |
33 | | -.filter(Boolean); |
| 31 | +const entries = Array.isArray(raw) |
| 32 | + ? raw |
| 33 | + : typeof raw === "string" |
| 34 | + ? normalizeStringEntries(raw.split(",")) |
| 35 | + : [raw]; |
| 36 | +return entries.map((entry) => normalizeSmsAllowFrom(String(entry))).filter(Boolean); |
34 | 37 | } |
35 | 38 | |
36 | 39 | function parseTextChunkLimit(raw: unknown): number { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -109,10 +109,12 @@ describe("dispatchSmsInboundEvent", () => {
|
109 | 109 | meta: undefined, |
110 | 110 | }); |
111 | 111 | expect(sendSmsViaTwilio).toHaveBeenCalledOnce(); |
112 | | -expect(sendSmsViaTwilio.mock.calls[0]?.[0]).toMatchObject({ |
113 | | -to: "+15551234567", |
114 | | -}); |
115 | | -expect(sendSmsViaTwilio.mock.calls[0]?.[0].text).toContain("PAIR123"); |
| 112 | +expect(sendSmsViaTwilio).toHaveBeenCalledWith( |
| 113 | +expect.objectContaining({ |
| 114 | +to: "+15551234567", |
| 115 | +text: expect.stringContaining("PAIR123"), |
| 116 | +}), |
| 117 | +); |
116 | 118 | }); |
117 | 119 | |
118 | 120 | it("uses the canonical routed session key for authorized SMS turns", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -30,16 +30,15 @@ type ProviderAuthWarmWorkerResult =
|
30 | 30 | }; |
31 | 31 | |
32 | 32 | function isWorkerInput(value: unknown): value is ProviderAuthWarmWorkerInput { |
| 33 | +if (!value || typeof value !== "object") { |
| 34 | +return false; |
| 35 | +} |
| 36 | +const record = value as Record<string, unknown>; |
33 | 37 | return ( |
34 | | -value !== null && |
35 | | -typeof value === "object" && |
36 | | -"cfg" in value && |
37 | | -(!("runtimeAuthStores" in value) || |
38 | | -Array.isArray((value as { runtimeAuthStores?: unknown }).runtimeAuthStores)) && |
39 | | -(!("runtimeAuthLookups" in value) || |
40 | | -Array.isArray((value as { runtimeAuthLookups?: unknown }).runtimeAuthLookups)) && |
41 | | -(!("omitFalseProviderAuth" in value) || |
42 | | -typeof (value as { omitFalseProviderAuth?: unknown }).omitFalseProviderAuth === "boolean") |
| 38 | +"cfg" in record && |
| 39 | +(!("runtimeAuthStores" in record) || Array.isArray(record.runtimeAuthStores)) && |
| 40 | +(!("runtimeAuthLookups" in record) || Array.isArray(record.runtimeAuthLookups)) && |
| 41 | +(!("omitFalseProviderAuth" in record) || typeof record.omitFalseProviderAuth === "boolean") |
43 | 42 | ); |
44 | 43 | } |
45 | 44 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -245,9 +245,10 @@ interface ZodDummy {
|
245 | 245 | unwrap: () => z.ZodType; |
246 | 246 | } |
247 | 247 | function isUnwrappable(object: unknown): object is ZodDummy { |
| 248 | +if (!object || typeof object !== "object") { |
| 249 | +return false; |
| 250 | +} |
248 | 251 | return ( |
249 | | -object !== null && |
250 | | -typeof object === "object" && |
251 | 252 | "unwrap" in object && |
252 | 253 | typeof (object as Record<string, unknown>).unwrap === "function" && |
253 | 254 | !(object instanceof z.ZodArray) |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -315,7 +315,7 @@ describe("Session Store Cache", () => {
|
315 | 315 | throw new Error("Expected cached entry"); |
316 | 316 | } |
317 | 317 | expect(entry?.polluted).toBeUndefined(); |
318 | | -expect(Object.hasOwn(entry as SessionEntry, "__proto__")).toBe(true); |
| 318 | +expect(Object.hasOwn(entry as object, "__proto__")).toBe(true); |
319 | 319 | expect(Object.prototype).not.toHaveProperty("polluted"); |
320 | 320 | }); |
321 | 321 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。