Skip to content

Commit 3bbff3c

Browse files
committed
fix(examples): use top-level await for async functions
Replace unawaited function calls with top-level await to fix oxlint no-floating-promises errors. This ensures examples run to completion and any errors are properly surfaced. - examples/index.ts: await quickstart() - examples/openai-integration.ts: await openaiIntegration() - examples/ai-sdk-integration.ts: await aiSdkIntegration() - examples/human-in-the-loop.ts: await humanInTheLoopExample() - examples/meta-tools.ts: await main() in import.meta.main guard
1 parent b196d6d commit 3bbff3c

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed

examples/ai-sdk-integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ const aiSdkIntegration = async (): Promise<void> => {
4141
assert(text.includes('Michael'), 'Expected employee name to be included in the response');
4242
};
4343

44-
aiSdkIntegration();
44+
await aiSdkIntegration();

examples/human-in-the-loop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ const simulateHumanValidation = async (toolCall: ToolCall): Promise<boolean> =>
103103
return true;
104104
};
105105

106-
humanInTheLoopExample();
106+
await humanInTheLoopExample();

examples/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const quickstart = async (): Promise<void> => {
7575
};
7676

7777
// Run the example
78-
quickstart();
78+
await quickstart();
7979

8080
/**
8181
* # Next Steps

examples/meta-tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ const main = async () => {
272272

273273
// Run if this file is executed directly
274274
if (import.meta.main) {
275-
main();
275+
await main();
276276
}
277277

278278
export { metaToolsWithAISDK, metaToolsWithOpenAI, directMetaToolUsage, dynamicToolRouter };

examples/openai-integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ const openaiIntegration = async (): Promise<void> => {
6666
};
6767

6868
// Run the example
69-
openaiIntegration();
69+
await openaiIntegration();

lefthook.yaml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
pre-commit:
2-
parallel: false
3-
commands:
4-
# Lint first - fail fast on warnings
5-
oxlint:
6-
glob: '*.{ts,tsx,js,jsx,mts,cts}'
7-
run: pnpm oxlint --max-warnings=0 --type-aware --fix {staged_files}
8-
stage_fixed: true
2+
parallel: true
3+
groups:
4+
lint-fmt:
5+
parallel: false
6+
commands:
7+
oxlint:
8+
glob: "*.{ts,tsx,js,jsx,mts,cts}"
9+
run: pnpm oxlint --max-warnings=0 --type-aware --fix {staged_files}
10+
stage_fixed: true
11+
oxfmt:
12+
glob: "*"
13+
run: pnpm oxfmt --no-error-on-unmatched-pattern {staged_files}
14+
stage_fixed: true
915

10-
# Format after linting passes
11-
oxfmt:
12-
glob: '*'
13-
run: pnpm oxfmt --no-error-on-unmatched-pattern {staged_files}
14-
stage_fixed: true
15-
16-
# Type check TypeScript files
1716
typecheck:
18-
glob: '*.{ts,tsx,mts,cts}'
19-
run: pnpm run typecheck
17+
commands:
18+
typecheck:
19+
glob: "*.{ts,tsx,mts,cts}"
20+
run: pnpm run typecheck

0 commit comments

Comments
 (0)