-
Notifications
You must be signed in to change notification settings - Fork 518
Expand file tree
/
Copy pathcode_patterns.mdc
More file actions
24 lines (20 loc) · 1.02 KB
/
code_patterns.mdc
File metadata and controls
24 lines (20 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
---
description: Code Patterns and Best Practices
globs: "**/*.{js,ts}"
alwaysApply: true
---
The following conventions MUST be followed in new code.
DON'T report code patterns outside of the examples explicitly listed below:
- Never use `void asyncFunction()` or `asyncFunction().catch(console.error)` - use `runAsynchronously(asyncFunction)` instead
- Instead of Vercel `waitUntil`, use `runAsynchronously(promise, { promiseCallback: waitUntil })`
- Don't concatenate URLs as strings - avoid patterns like `/users/${userId}`
- Replace non-null assertions with `?? throwErr("message", { extraData })` pattern
- Properly handle async operations with try/catch blocks
- Use helper functions for validation and environment variables
# Solution
Fix code pattern violations by:
- Wrapping async calls with runAsynchronously
- Importing parseJson/stringifyJson from stack-shared/utils/json
- Using runAsynchronously with promiseCallback for waitUntil
- Using proper URL construction utilities
- Replacing ! assertions with ?? throwErr pattern