|
| 1 | +# Fix Lint Issues and Test Failures |
| 2 | + |
| 3 | +> **Agent Scope**: This is a focused, single-purpose task following [12-factor-agents](https://github.com/humanlayer/12-factor-agents) principles. Fix one category of issues at a time, commit after each fix, and iterate. |
| 4 | +
|
| 5 | +## Context |
| 6 | + |
| 7 | +This monorepo uses: |
| 8 | +- **Turbo** for orchestrating builds, linting, and tests across packages |
| 9 | +- **ESLint** with TypeScript for linting |
| 10 | +- **Vitest** for unit and component testing |
| 11 | +- **pnpm** as the package manager |
| 12 | + |
| 13 | +### Key Commands |
| 14 | + |
| 15 | +| Command | Scope | Description | |
| 16 | +|---------|-------|-------------| |
| 17 | +| `pnpm lint` | Monorepo | Run ESLint across all packages | |
| 18 | +| `pnpm test` | Monorepo | Run all tests via Turbo | |
| 19 | +| `pnpm build` | Monorepo | Build all packages | |
| 20 | +| `pnpm lint:fix` | Monorepo | Auto-fix lint issues where possible | |
| 21 | + |
| 22 | +### Package-Specific Commands (apps/main) |
| 23 | + |
| 24 | +| Command | Description | |
| 25 | +|---------|-------------| |
| 26 | +| `pnpm --filter @cbnsndwch/struktura-main lint` | Lint main app only | |
| 27 | +| `pnpm --filter @cbnsndwch/struktura-main test` | Test main app only | |
| 28 | +| `pnpm --filter @cbnsndwch/struktura-main test:unit` | Unit tests only | |
| 29 | +| `pnpm --filter @cbnsndwch/struktura-main test:components` | Component tests only | |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +## Step-by-Step Process |
| 34 | + |
| 35 | +### 1. Discover Issues |
| 36 | + |
| 37 | +First, run a full lint check to identify all issues: |
| 38 | + |
| 39 | +```bash |
| 40 | +pnpm lint 2>&1 |
| 41 | +``` |
| 42 | + |
| 43 | +Then run tests to find failures: |
| 44 | + |
| 45 | +```bash |
| 46 | +pnpm test 2>&1 |
| 47 | +``` |
| 48 | + |
| 49 | +Report findings in a structured format: |
| 50 | + |
| 51 | +``` |
| 52 | +<issues_found> |
| 53 | + category: "lint" |
| 54 | + count: 5 |
| 55 | + breakdown: |
| 56 | + - rule: "@typescript-eslint/no-unused-vars" |
| 57 | + count: 3 |
| 58 | + files: ["src/foo.ts", "src/bar.ts"] |
| 59 | + - rule: "import/order" |
| 60 | + count: 2 |
| 61 | + files: ["src/baz.ts"] |
| 62 | +</issues_found> |
| 63 | +``` |
| 64 | + |
| 65 | +### 2. Categorize and Prioritize |
| 66 | + |
| 67 | +Group issues by type for atomic fixes: |
| 68 | + |
| 69 | +**Lint Issue Categories (in order of priority):** |
| 70 | +1. **Build-breaking**: Type errors, missing imports, syntax errors |
| 71 | +2. **Auto-fixable**: Issues that `pnpm lint:fix` can resolve |
| 72 | +3. **Manual fixes**: Unused variables, missing types, logic issues |
| 73 | +4. **Warnings**: Non-critical style or deprecation warnings |
| 74 | + |
| 75 | +**Test Failure Categories:** |
| 76 | +1. **Missing dependencies**: Tests failing due to missing mocks/providers |
| 77 | +2. **API changes**: Tests failing due to changed function signatures |
| 78 | +3. **Assertion failures**: Actual logic/expectation mismatches |
| 79 | +4. **Flaky tests**: Intermittent failures (timing, race conditions) |
| 80 | + |
| 81 | +### 3. Fix One Category at a Time |
| 82 | + |
| 83 | +Follow this cycle for EACH category: |
| 84 | + |
| 85 | +#### A. Attempt Auto-Fix First (for lint) |
| 86 | + |
| 87 | +```bash |
| 88 | +pnpm lint:fix |
| 89 | +``` |
| 90 | + |
| 91 | +#### B. Review Remaining Issues |
| 92 | + |
| 93 | +```bash |
| 94 | +pnpm lint 2>&1 | head -100 |
| 95 | +``` |
| 96 | + |
| 97 | +#### C. Apply Manual Fixes |
| 98 | + |
| 99 | +For each issue: |
| 100 | +1. Read the affected file |
| 101 | +2. Understand the context (3-5 lines before/after) |
| 102 | +3. Apply the minimal fix that resolves the issue |
| 103 | +4. Verify the fix doesn't break anything else |
| 104 | + |
| 105 | +#### D. Validate |
| 106 | + |
| 107 | +```bash |
| 108 | +pnpm build && pnpm lint && pnpm test |
| 109 | +``` |
| 110 | + |
| 111 | +#### E. Commit the Fix |
| 112 | + |
| 113 | +```bash |
| 114 | +git add -A |
| 115 | +git commit -m "fix(scope): resolve [issue type] in [file/area]" |
| 116 | +``` |
| 117 | + |
| 118 | +### 4. Handle Errors and Edge Cases |
| 119 | + |
| 120 | +If a fix introduces new issues: |
| 121 | + |
| 122 | +``` |
| 123 | +<error_context> |
| 124 | + original_issue: "unused variable 'foo'" |
| 125 | + attempted_fix: "removed variable declaration" |
| 126 | + new_error: "ReferenceError: foo is not defined" |
| 127 | + root_cause: "variable was used in a different scope" |
| 128 | + resolution: "keep variable, add eslint-disable comment with explanation" |
| 129 | +</error_context> |
| 130 | +``` |
| 131 | + |
| 132 | +**Escape hatches (use sparingly):** |
| 133 | +- `// eslint-disable-next-line <rule>` - Disable for one line with reason |
| 134 | +- `// @ts-expect-error <reason>` - Suppress type error with explanation |
| 135 | +- Skip the issue and document for manual review |
| 136 | + |
| 137 | +--- |
| 138 | + |
| 139 | +## Compact Error Handling (Factor 9) |
| 140 | + |
| 141 | +When encountering errors: |
| 142 | +1. Capture the essential error (type + message + location) |
| 143 | +2. Discard full stack traces after understanding the issue |
| 144 | +3. Focus on root cause, not symptoms |
| 145 | + |
| 146 | +Example transformation: |
| 147 | +``` |
| 148 | +# Before (verbose) |
| 149 | +Error: Cannot find module '@/lib/utils' |
| 150 | + at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1048:15) |
| 151 | + at Function.Module._load (node:internal/modules/cjs/loader:901:27) |
| 152 | + ... 20 more lines |
| 153 | +
|
| 154 | +# After (compact) |
| 155 | +Issue: Missing module alias '@/lib/utils' in src/components/Button.tsx:3 |
| 156 | +Fix: Update import path or add path alias to tsconfig.json |
| 157 | +``` |
| 158 | + |
| 159 | +--- |
| 160 | + |
| 161 | +## Small, Focused Fixes (Factor 10) |
| 162 | + |
| 163 | +Each commit should address ONE logical issue: |
| 164 | + |
| 165 | +✅ **Good commits:** |
| 166 | +- `fix(main): remove unused imports in auth module` |
| 167 | +- `fix(tests): add SidebarProvider wrapper to navigation tests` |
| 168 | +- `fix(lint): resolve no-unused-vars in workspace components` |
| 169 | + |
| 170 | +❌ **Bad commits:** |
| 171 | +- `fix: resolve all lint issues` (too broad) |
| 172 | +- `fix: lint and tests and add new feature` (mixed concerns) |
| 173 | + |
| 174 | +--- |
| 175 | + |
| 176 | +## Progress Tracking |
| 177 | + |
| 178 | +After each fix cycle, update progress: |
| 179 | + |
| 180 | +``` |
| 181 | +<fix_progress> |
| 182 | + phase: "lint" |
| 183 | + completed: |
| 184 | + - "@typescript-eslint/no-unused-vars" (3 issues) |
| 185 | + in_progress: |
| 186 | + - "import/order" (2 remaining) |
| 187 | + remaining: |
| 188 | + - Test failures (7 total) |
| 189 | + commits_made: 2 |
| 190 | +</fix_progress> |
| 191 | +``` |
| 192 | + |
| 193 | +--- |
| 194 | + |
| 195 | +## Completion Criteria |
| 196 | + |
| 197 | +The task is complete when: |
| 198 | + |
| 199 | +1. `pnpm lint` exits with code 0 (no errors) |
| 200 | +2. `pnpm test` exits with code 0 (all tests pass) |
| 201 | +3. `pnpm build` completes successfully |
| 202 | +4. Each fix has been committed with a descriptive message |
| 203 | + |
| 204 | +--- |
| 205 | + |
| 206 | +## Resumption Context |
| 207 | + |
| 208 | +If pausing this task, capture: |
| 209 | + |
| 210 | +```markdown |
| 211 | +## Fix Session State |
| 212 | + |
| 213 | +**Last successful command**: `pnpm lint` (0 errors) |
| 214 | +**Current phase**: Fixing test failures |
| 215 | +**Next file to fix**: `apps/main/app/components/__tests__/Sidebar.test.tsx` |
| 216 | +**Remaining issues**: 4 test failures in component tests |
| 217 | +**Commits made**: 3 |
| 218 | +``` |
0 commit comments