---
name: ESLint Type-Aware Rule Violations
status: closed
created: 2025-10-13T11:02:21Z
updated: 2025-10-14T07:39:59Z
completed: 2025-10-13T16:30:34Z
github: https://github.com/BuzzTrail/video-extension/issues/132
depends_on: [003, 004]
parallel: false
conflicts_with: []
---

# Task: ESLint Type-Aware Rule Violations

## Description

Run ESLint with type-aware rules enabled to discover and fix violations related to async/await patterns, promise handling, and type-based correctness. Focus on high-value rules like `no-floating-promises` and `no-misused-promises` that catch common async bugs.

## Acceptance Criteria

- [ ] All ESLint type-aware violations identified via `pnpm nx run-many -t lint --all`
- [ ] `no-floating-promises` violations fixed (add `await` or `.catch()`)
- [ ] `no-misused-promises` violations fixed (correct async usage)
- [ ] `strict-boolean-expressions` violations fixed or suppressed with justification
- [ ] All lint errors resolved or explicitly justified with `eslint-disable` comments
- [ ] Zero ESLint violations: `pnpm nx run-many -t lint --all` succeeds
- [ ] No runtime regressions introduced by fixes

## Technical Details

**Type-Aware Rules to Fix**:

1. **no-floating-promises**: Promises that aren't awaited or handled
   ```typescript
   // ❌ Before
   async function doWork() {
     someAsyncOperation(); // Floating promise!
   }

   // ✅ After
   async function doWork() {
     await someAsyncOperation();
     // or
     someAsyncOperation().catch(handleError);
   }
   ```

2. **no-misused-promises**: Promises used in wrong contexts
   ```typescript
   // ❌ Before
   if (asyncCheck()) { ... } // Returns promise, not boolean

   // ✅ After
   const result = await asyncCheck();
   if (result) { ... }
   ```

3. **strict-boolean-expressions**: Non-boolean values in conditions
   ```typescript
   // ❌ Before
   if (value) { ... } // value might be string, number, etc.

   // ✅ After
   if (value !== null && value !== undefined) { ... }
   // or
   if (Boolean(value)) { ... }
   ```

**Commands**:
```bash
# Run lint with auto-fix where possible
pnpm nx affected:lint --fix

# For remaining violations, fix manually
pnpm nx run-many -t lint --all
```

**When to Use eslint-disable**:

Only use `eslint-disable-next-line` when:
- The rule doesn't apply to the specific case
- Fixing would make code significantly worse
- Always include a justification comment

```typescript
// Intentionally not awaited - fire and forget with error handling
// eslint-disable-next-line @typescript-eslint/no-floating-promises
backgroundTask().catch(logger.error);
```

**Files Likely to Need Updates**:
- Any file with async/await functions
- Event handlers and callbacks
- API client code
- Background job processors

## Dependencies

- [ ] Task 003 completed (ESLint type-aware rules enabled)
- [ ] Task 004 completed (type definitions in place)

## Effort Estimate

- **Size**: S
- **Hours**: 2 hours
- **Parallel**: false (needs type-aware config and types)

## Definition of Done

- [ ] All async/await violations fixed
- [ ] All promise handling violations fixed
- [ ] Boolean expression violations resolved
- [ ] ESLint passes with 0 violations
- [ ] All tests pass
- [ ] Justification comments added for any suppressed rules
- [ ] Code review completed
- [ ] No runtime behavior changes (only type safety improvements)
