Skip to content

Commit 455e752

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 455e752

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
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: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
pre-commit:
22
parallel: false
33
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
9-
10-
# Format after linting passes
4+
# Format - part of parallel group
115
oxfmt:
6+
priority: 1
127
glob: '*'
138
run: pnpm oxfmt --no-error-on-unmatched-pattern {staged_files}
149
stage_fixed: true
1510

16-
# Type check TypeScript files
11+
# Lint - part of parallel group (same priority = parallel)
12+
oxlint:
13+
priority: 1
14+
glob: '*.{ts,tsx,js,jsx,mts,cts}'
15+
run: pnpm oxlint --max-warnings=0 --type-aware --fix {staged_files}
16+
stage_fixed: true
17+
18+
# Type check TypeScript files - run after format/lint (higher priority = later)
1719
typecheck:
20+
priority: 2
1821
glob: '*.{ts,tsx,mts,cts}'
1922
run: pnpm run typecheck

0 commit comments

Comments
 (0)