chore(#17): recommendation document for code validation layer#78
chore(#17): recommendation document for code validation layer#78
Conversation
Evaluate ESLint, TypeScript compiler, Prettier, ShellCheck, and custom CHT checks for validating generated code against cht-core's config. Recommends a thin wrapper approach with auto-fix pipeline.
Hareet
left a comment
There was a problem hiding this comment.
Review
Test Plan
1. Review recommendation document for accuracy ✅ (with one exception)
The document is accurate with one significant exception: the tsc implementation sketch would silently produce false negatives. cht-core's tsconfig has rootDir: "./src" and include: ["src/**/*"] — files in a temp directory outside src/ are silently excluded. tsc reports 0 errors without actually type-checking anything.
Two options to consider:
- Wrapper tsconfig — create a temp
tsconfig.validation.jsonextending the target's, withincludeoverridden to add the temp directory. Clean up after validation. - Stage inside the project tree — write generated files into a
.gitignoreddirectory withinrootDir(e.g.,src/.validation-staging/), so the existing tsconfig picks them up naturally.
Either way, the doc should specify the chosen approach since it affects whether imports, type declarations, and per-directory tsconfig overrides resolve correctly.
2. Verify tool evaluation matches current cht-core and cht-agent configs ✅
Verified against the actual files:
.eslintrc— ESLint v8.31.0, legacy config, extends@medic/eslint-config+@typescript-eslint/recommended+prettier✅tsconfig.json—strict: true,noUnusedLocals,noUnusedParameters,noImplicitReturns✅.prettierrc— single quotes, 2-space indent, trailing comma es5, 100 char width ✅
All claims in the document match the codebase.
3. Confirm proposed interfaces align with Code Generation Layer patterns ✅ (minor note)
CodeValidator consumes GeneratedFile[] which is defined in GITHUB_ISSUES_DRAFT.md but not yet in src/types/index.ts. The doc should either inline the type definition or reference where it's specified.
Minor notes
- Issue numbers
#62,#64,#65in the integration diagram only appear in this file — consider using layer names instead of (or alongside) issue numbers for clarity. usesPrettier(targetProject)in the sketch is unspecified — checking for.prettierrcexistence is sufficient, worth a one-liner note.
Address tsc false negative (stage files inside project tree instead of temp dir), inline GeneratedFile type, add layer names alongside issue numbers, and specify usesPrettier detection method.
Summary
Details
ValidationIssue,ValidationResult,CodeValidator)Test plan
Fixes #17