Skip to content

Commit f8f37e5

Browse files
committed
docs: create TASK_066 files
1 parent 317b6ca commit f8f37e5

File tree

2 files changed

+204
-0
lines changed

2 files changed

+204
-0
lines changed

.claude/plans/066.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Plan: 066
2+
3+
Captured: 2025-09-17T00:22:54.261Z
4+
5+
## Plan: Make cc-track Lint-Agnostic with Built-in Support for Biome and ESLint
6+
7+
### Investigation Results: Biome-Specific Hardcoded Assumptions
8+
9+
After investigating the codebase, I found that while the configuration system appears to support any lint command, there are indeed several hardcoded assumptions specific to Biome that need to be fixed:
10+
11+
### Issues Found:
12+
13+
1. **`src/lib/validation.ts` - runBiomeCheck function (lines 91-130)**:
14+
- Function name itself is "runBiomeCheck" (should be generic like "runLintCheck")
15+
- Line 98: Hardcoded `bunx biome check --write` for auto-formatting
16+
- Line 109: Adds `--error-on-warnings` flag specifically for Biome
17+
- Line 120: Parses Biome-specific output format "diagnostic"
18+
- Variable names reference "biome" throughout
19+
20+
2. **`src/hooks/edit-validation.ts` - runBiomeCheck function (lines 178-219)**:
21+
- Function name is "runBiomeCheck" (should be generic)
22+
- Line 192: Adds `--reporter=compact` flag specifically for Biome
23+
- Line 208-213: Parses Biome-specific compact output format
24+
25+
3. **`src/commands/prepare-completion.ts` (lines 281-293)**:
26+
- Line 283: Messages reference "Biome issues" specifically
27+
- Line 292: Hardcoded advice to use `bunx biome check --write`
28+
29+
4. **Variable/property naming throughout**:
30+
- `ValidationResult` interface has property called "biome"
31+
- Config properties use "biome" in variable names
32+
33+
### Detailed Fix Plan:
34+
35+
1. **Update configuration structure** to support tool detection:
36+
```typescript
37+
// In track.config.json
38+
"lint": {
39+
"enabled": true,
40+
"tool": "biome", // "biome" | "eslint" | "custom"
41+
"command": "bunx biome check",
42+
"autoFixCommand": "bunx biome check --write", // optional
43+
"customParser": "path/to/parser.js" // only needed for tool: "custom"
44+
}
45+
```
46+
47+
2. **Create lint parser abstraction** (`src/lib/lint-parsers.ts`):
48+
```typescript
49+
interface LintParser {
50+
parseOutput(output: string, filePath?: string): ParsedLintResult;
51+
getAutoFixCommand(baseCommand: string): string | undefined;
52+
}
53+
54+
class BiomeParser implements LintParser {
55+
// Parse "X diagnostics" format
56+
// Parse compact reporter format for file-specific errors
57+
// Return structured errors with line numbers
58+
}
59+
60+
class ESLintParser implements LintParser {
61+
// Parse ESLint stylish or compact format
62+
// Extract error/warning counts
63+
// Handle various ESLint output formats
64+
}
65+
66+
class GenericParser implements LintParser {
67+
// Simple line-based error matching
68+
// Fallback for unknown tools
69+
}
70+
```
71+
72+
3. **Refactor `src/lib/validation.ts`**:
73+
- **Line 93**: Rename function `runBiomeCheck``runLintCheck`
74+
- **Line 95-101**: Replace hardcoded auto-formatter with:
75+
```typescript
76+
if (lintConfig?.autoFixCommand) {
77+
try {
78+
execSync(lintConfig.autoFixCommand, { cwd: projectRoot });
79+
} catch {
80+
// Auto-fix might fail, continue to check
81+
}
82+
}
83+
```
84+
- **Line 107-109**: Remove automatic `--error-on-warnings` addition
85+
- **Line 119-127**: Replace Biome-specific parsing with parser abstraction:
86+
```typescript
87+
const parser = getLintParser(lintConfig?.tool || 'biome');
88+
const result = parser.parseOutput(output);
89+
```
90+
- Update all variable names: `biomeConfig``lintConfig`, `biomeCheck``lintCheck`
91+
92+
4. **Refactor `src/hooks/edit-validation.ts`**:
93+
- **Line 178**: Rename function `runBiomeCheck` → `runLintCheck`
94+
- **Line 192**: Remove hardcoded `--reporter=compact`, use command as-is
95+
- **Line 208-213**: Replace Biome-specific parsing with:
96+
```typescript
97+
const parser = getLintParser(config.lint?.tool || 'biome');
98+
const errors = parser.parseOutput(output, filePath);
99+
```
100+
- Update function signature and all references
101+
102+
5. **Update ValidationResult interface** (multiple files):
103+
- Change `biome?: { ... }` to `lint?: { ... }`
104+
- Keep the same structure (passed, errors, issueCount)
105+
- Update all references in:
106+
- `src/lib/validation.ts`
107+
- `src/commands/prepare-completion.ts`
108+
- `src/commands/complete-task.ts`
109+
- Test files
110+
111+
6. **Update user-facing messages in `src/commands/prepare-completion.ts`**:
112+
- **Line 283**: Change "Biome issues" to "Linting issues"
113+
- **Line 292**: Generate tool-specific fix advice:
114+
```typescript
115+
const lintTool = config.lint?.tool || 'biome';
116+
const fixAdvice = {
117+
biome: 'Fix with `bunx biome check --write`',
118+
eslint: 'Fix with `npx eslint --fix`',
119+
custom: config.lint?.autoFixCommand
120+
? `Fix with \`${config.lint.autoFixCommand}\``
121+
: 'Fix linting issues manually'
122+
};
123+
messages.push(`**Action:** ${fixAdvice[lintTool]}.\n`);
124+
```
125+
126+
7. **Backward compatibility handling**:
127+
- In config loading, detect old format (just `command` string)
128+
- If old format detected, convert to new format assuming Biome:
129+
```typescript
130+
if (typeof config.lint === 'object' && !config.lint.tool) {
131+
config.lint.tool = 'biome'; // Assume Biome for existing configs
132+
}
133+
```
134+
135+
8. **Update default configurations**:
136+
- `src/lib/config.ts`: Update default lint config structure
137+
- Template files: Update to show new config format
138+
- Documentation: Add examples for ESLint configuration
139+
140+
9. **Add comprehensive tests**:
141+
- Test Biome output parsing with various error formats
142+
- Test ESLint output parsing (stylish, compact formats)
143+
- Test generic parser fallback
144+
- Test backward compatibility with old configs
145+
- Test both validation.ts and edit-validation.ts with different tools
146+
147+
10. **Update documentation**:
148+
- README: Show examples for both Biome and ESLint configuration
149+
- Comments in code: Update to be tool-agnostic
150+
- Config template: Include commented examples for different tools
151+
152+
### Implementation Order:
153+
1. Create lint-parsers.ts with all three parser implementations
154+
2. Update config types and interfaces
155+
3. Refactor validation.ts to use parsers
156+
4. Refactor edit-validation.ts to use parsers
157+
5. Update prepare-completion.ts messages
158+
6. Add backward compatibility logic
159+
7. Update all tests
160+
8. Update documentation and templates
161+
162+
This approach maintains full detail while supporting Biome and ESLint as first-class citizens, with the flexibility to support other tools through the custom parser option.

.claude/tasks/TASK_066.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# TASK_066: Make cc-track Lint-Agnostic with Built-in Support for Biome and ESLint
2+
3+
## Purpose
4+
Refactor cc-track from hardcoded Biome assumptions to a flexible lint system that supports Biome, ESLint, and custom tools as first-class citizens.
5+
6+
## Status
7+
**in_progress** - Started: 2025-09-17 20:22
8+
9+
## Requirements
10+
- [ ] Create lint parser abstraction with BiomeParser, ESLintParser, and GenericParser
11+
- [ ] Update configuration structure to support tool detection and auto-fix commands
12+
- [ ] Refactor `src/lib/validation.ts` - rename `runBiomeCheck` to `runLintCheck` and remove hardcoded assumptions
13+
- [ ] Refactor `src/hooks/edit-validation.ts` - rename function and replace Biome-specific parsing
14+
- [ ] Update ValidationResult interface from `biome?` to `lint?` across all files
15+
- [ ] Update user-facing messages in `src/commands/prepare-completion.ts` to be tool-agnostic
16+
- [ ] Implement backward compatibility for existing configurations
17+
- [ ] Update default configurations and templates
18+
- [ ] Add comprehensive tests for all parsers and tool configurations
19+
- [ ] Update documentation with examples for Biome, ESLint, and custom tools
20+
21+
## Success Criteria
22+
- ✅ Support for Biome, ESLint, and custom lint tools through configuration
23+
- ✅ No hardcoded tool-specific assumptions in validation logic
24+
- ✅ Backward compatibility maintained for existing Biome configurations
25+
- ✅ Clear error messages and fix suggestions for each supported tool
26+
- ✅ Comprehensive test coverage for all parsers and scenarios
27+
28+
## Technical Approach
29+
1. **Parser Abstraction**: Create `LintParser` interface with tool-specific implementations
30+
2. **Configuration Enhancement**: Extend lint config to include `tool`, `command`, `autoFixCommand`, and `customParser`
31+
3. **Function Refactoring**: Replace all `runBiomeCheck` functions with generic `runLintCheck`
32+
4. **Output Parsing**: Replace hardcoded Biome output parsing with parser abstraction
33+
5. **Message Updates**: Generate tool-specific error messages and fix advice
34+
6. **Backward Compatibility**: Auto-detect and convert old configuration format
35+
36+
## Current Focus
37+
Setting up the foundational parser abstraction and configuration structure to support multiple lint tools.
38+
39+
## Next Steps
40+
1. Create `src/lib/lint-parsers.ts` with parser implementations
41+
2. Update configuration types and interfaces
42+
3. Begin refactoring validation functions to use the new parser system

0 commit comments

Comments
 (0)