@webpieces/dev-config 0.2.93 → 0.2.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/architecture/executors/validate-no-any-unknown/executor.js +2 -2
  2. package/architecture/executors/validate-no-any-unknown/executor.js.map +1 -1
  3. package/architecture/executors/validate-no-any-unknown/executor.ts +2 -2
  4. package/architecture/executors/validate-no-skiplevel-deps/executor.js.map +1 -1
  5. package/architecture/executors/validate-no-skiplevel-deps/executor.ts +2 -2
  6. package/eslint-plugin/__tests__/catch-error-pattern.test.ts +41 -26
  7. package/eslint-plugin/__tests__/no-unmanaged-exceptions.test.ts +20 -20
  8. package/eslint-plugin/rules/catch-error-pattern.d.ts +3 -3
  9. package/eslint-plugin/rules/catch-error-pattern.js +84 -137
  10. package/eslint-plugin/rules/catch-error-pattern.js.map +1 -1
  11. package/eslint-plugin/rules/catch-error-pattern.ts +123 -158
  12. package/eslint-plugin/rules/enforce-architecture.js +3 -3
  13. package/eslint-plugin/rules/enforce-architecture.js.map +1 -1
  14. package/eslint-plugin/rules/enforce-architecture.ts +8 -8
  15. package/eslint-plugin/rules/max-file-lines.js +3 -3
  16. package/eslint-plugin/rules/max-file-lines.js.map +1 -1
  17. package/eslint-plugin/rules/max-file-lines.ts +5 -5
  18. package/eslint-plugin/rules/max-method-lines.js +3 -3
  19. package/eslint-plugin/rules/max-method-lines.js.map +1 -1
  20. package/eslint-plugin/rules/max-method-lines.ts +5 -5
  21. package/executors/validate-eslint-sync/executor.d.ts +3 -2
  22. package/executors/validate-eslint-sync/executor.js.map +1 -1
  23. package/executors/validate-eslint-sync/executor.ts +6 -2
  24. package/executors/validate-versions-locked/executor.js +3 -2
  25. package/executors/validate-versions-locked/executor.js.map +1 -1
  26. package/executors/validate-versions-locked/executor.ts +5 -4
  27. package/package.json +1 -1
  28. package/src/generators/init/generator.js.map +1 -1
  29. package/templates/webpieces.exceptions.md +15 -15
@@ -52,7 +52,7 @@ Without traceId in errors:
52
52
  // BAD: Catching just to rethrow without adding value
53
53
  try {
54
54
  await operation();
55
- } catch (err: any) {
55
+ } catch (err: unknown) {
56
56
  const error = toError(err);
57
57
  console.error('Failed:', error);
58
58
  throw error; // No new info added - why catch?
@@ -70,7 +70,7 @@ The key question: Are you adding meaningful information or context? If yes, it m
70
70
  // BAD: "I don't want to deal with this error"
71
71
  try {
72
72
  await riskyOperation();
73
- } catch (err: any) {
73
+ } catch (err: unknown) {
74
74
  // Silence...
75
75
  }
76
76
  ```
@@ -116,7 +116,7 @@ TraceId (also called correlation ID, request ID) ties these together.
116
116
  - Is it adding context to the error before rethrowing? → May be valid (see Problem 3)
117
117
 
118
118
  3. **IF REMOVING** the try-catch block:
119
- - Delete the `try {` and `} catch (err: any) { ... }` wrapper
119
+ - Delete the `try {` and `} catch (err: unknown) { ... }` wrapper
120
120
  - Let the code execute normally
121
121
  - Errors will bubble to global handler automatically
122
122
 
@@ -159,7 +159,7 @@ export class WebpiecesMiddleware {
159
159
  // Await catches BOTH sync throws AND rejected promises
160
160
  await next();
161
161
  console.log('[GlobalErrorHandler] Request END (success)');
162
- } catch (err: any) {
162
+ } catch (err: unknown) {
163
163
  const error = toError(err);
164
164
  const traceId = RequestContext.get<string>('TRACE_ID');
165
165
 
@@ -279,7 +279,7 @@ async function processOrder(order: Order): Promise<void> {
279
279
  try {
280
280
  await validateOrder(order);
281
281
  await saveToDatabase(order);
282
- } catch (err: any) {
282
+ } catch (err: unknown) {
283
283
  // Error disappears into void - debugging nightmare!
284
284
  console.log('Order processing failed');
285
285
  }
@@ -300,7 +300,7 @@ async function fetchUserData(userId: string): Promise<User> {
300
300
  try {
301
301
  const response = await fetch(`/api/users/${userId}`);
302
302
  return await response.json();
303
- } catch (err: any) {
303
+ } catch (err: unknown) {
304
304
  const error = toError(err);
305
305
  // Custom message without traceId
306
306
  throw new Error(`Failed to fetch user ${userId}: ${error.message}`);
@@ -336,7 +336,7 @@ async function processOrder(order: Order): Promise<void> {
336
336
  ```typescript
337
337
  // GOOD: Global handler has full context
338
338
  // In WebpiecesMiddleware.globalErrorHandler (see Pattern 1 above)
339
- catch (err: any) {
339
+ catch (err: unknown) {
340
340
  const error = toError(err);
341
341
  const traceId = RequestContext.get<string>('TRACE_ID');
342
342
 
@@ -367,7 +367,7 @@ async function callVendorApiWithRetry(request: VendorRequest): Promise<VendorRes
367
367
  for (let i = 0; i < maxRetries; i++) {
368
368
  try {
369
369
  return await vendorApi.call(request);
370
- } catch (err: any) {
370
+ } catch (err: unknown) {
371
371
  const error = toError(err);
372
372
  lastError = error;
373
373
  console.warn(`Retry ${i + 1}/${maxRetries} failed:`, error.message);
@@ -404,7 +404,7 @@ async function processBatch(items: Item[]): Promise<BatchResult> {
404
404
  try {
405
405
  const result = await processItem(item);
406
406
  results.push(result);
407
- } catch (err: any) {
407
+ } catch (err: unknown) {
408
408
  const error = toError(err);
409
409
  // Log individual error with traceId
410
410
  console.error(`[Batch] Item ${item.id} failed (traceId: ${traceId}):`, error);
@@ -436,7 +436,7 @@ async function processBatch(items: Item[]): Promise<BatchResult> {
436
436
  async function saveUser(user: User): Promise<void> {
437
437
  try {
438
438
  await userRepository.save(user); // Internal call, not edge
439
- } catch (err: any) {
439
+ } catch (err: unknown) {
440
440
  const error = toError(err);
441
441
  console.error('Save failed:', error);
442
442
  throw error; // No value added - why catch?
@@ -460,7 +460,7 @@ async function saveUserToDb(user: User): Promise<void> {
460
460
  logRequest('[DB] Saving user', { traceId, userId: user.id });
461
461
  await externalDbClient.save('users', user); // EDGE: external service
462
462
  logSuccess('[DB] User saved', { traceId, userId: user.id });
463
- } catch (err: any) {
463
+ } catch (err: unknown) {
464
464
  const error = toError(err);
465
465
  logFailure('[DB] Save failed', { traceId, userId: user.id, error: error.message });
466
466
  throw error; // Rethrow - logging value at the edge
@@ -505,7 +505,7 @@ app.use(async (req, res, next) => {
505
505
 
506
506
  try {
507
507
  await next();
508
- } catch (err: any) {
508
+ } catch (err: unknown) {
509
509
  const error = toError(err);
510
510
  // Report to Sentry/observability
511
511
  Sentry.captureException(error, { extra: { traceId } });
@@ -557,7 +557,7 @@ export class GlobalErrorHandler implements ErrorHandler {
557
557
  vendorSdk.on('event', async (data) => {
558
558
  try {
559
559
  await processVendorEvent(data);
560
- } catch (err: any) {
560
+ } catch (err: unknown) {
561
561
  const error = toError(err);
562
562
  const traceId = RequestContext.get<string>('TRACE_ID');
563
563
  Sentry.captureException(error, { extra: { traceId, vendorData: data } });
@@ -585,7 +585,7 @@ async function sendMail(request: MailRequest): Promise<MailResponse> {
585
585
  const response = await emailService.send(request);
586
586
  logSuccess('[Email] Sent', { traceId, messageId: response.messageId });
587
587
  return response;
588
- } catch (err: any) {
588
+ } catch (err: unknown) {
589
589
  const error = toError(err);
590
590
  logFailure('[Email] Failed', { traceId, error: error.message, to: request.to });
591
591
  throw error; // Rethrow - adds logging value at the edge
@@ -626,7 +626,7 @@ async submitForm(): Promise<void> {
626
626
  try {
627
627
  await this.apiClient.saveData(this.formData);
628
628
  this.router.navigate(['/success']);
629
- } catch (err: any) {
629
+ } catch (err: unknown) {
630
630
  const error = toError(err);
631
631
 
632
632
  if (error instanceof HttpUserError) {