You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Use proper English (spelling, grammar, punctuation, capitalization)
221
-
222
-
### Code structure
223
-
224
-
-**Avoid `else`**: Return early to reduce indentation and keep logic flat
225
-
-**Keep functions small**: Small, focused functions are easier to understand and test
226
-
-**Minimal parameters**: Functions should only accept what they actually use
227
-
- Use comma-separated parameters for up to three parameters
228
-
- Use a single object parameter for more than three parameters
229
-
-**Declare variables close to use**: Variables should be declared near their first use
230
-
-**Extract reusable logic**: Extract complex or reusable logic into named helper functions
231
-
-**Avoid intermediate variables for single-use expressions**: Don't create constants or variables if they're only used once. Inline them directly. For example:
- Do not duplicate imports – always reuse existing imports if present
251
-
- Do not use dynamic imports unless explicitly told to do so
252
-
253
-
### Error handling
254
-
255
-
-**User errors**: Use appropriate error codes (4xx for client errors), log as `softFail`
256
-
-**Internal errors**: Use appropriate error codes (5xx for server errors), log with `log.exception` or `log.error`
257
-
- Always handle and propagate errors clearly
258
-
- Use custom error classes from `src/errors.ts` when appropriate
259
-
-**Don't log then throw**: Do NOT call `log.error()` immediately before throwing. Errors are already logged by the caller or error handler. This creates duplicate logs and violates separation of concerns.
***Nodoublevalidation:**WhenusingZodschemaswithAJV (`ajvValidate`intooldefinitions), doNOTaddredundantmanualvalidation — let the schema handle it. Use the parsed data directly.
158
174
159
175
***ErrorHandling:**
160
176
***UserErrors:**
@@ -163,6 +179,9 @@ Use comments to guide reviewers:
***Don't log then throw:** Do NOT call `log.error()` immediately before throwing — the error will be logged by the caller. This creates duplicate logs and violates separation of concerns.
183
+
* ❌ Don't: `log.error('Somethingfailed'); throw new Error('Somethingfailed');`
0 commit comments