-
Empty or Guide-Only Lines
Problem: root/ │ <-- These lines are now skipped ├─ src/ │ └─ dist/ <-- Valid lineSolution: Guide-only lines are automatically skipped. No action needed.
-
Invalid Indentation
Problem: root/ src/ dist/ <-- Too much indentationSolution: Ensure each level increases by one indentation unit (default 2 spaces).
-
Mixed Indentation
Problem: root/ ⎵⎵src/ <-- Spaces ⇥dist/ <-- TabSolution: Use consistent indentation (spaces or tabs) and set
tabIndentationSize.
-
Duplicate Paths
Problem: root/ ├─ src/ │ └─ index.ts └─ src/ <-- Duplicate └─ main.tsSolution:
- Use unique directory names
- Configure
pathConflict.onDuplicatePath - Use merge strategies for intentional duplicates
-
Invalid Characters
Problem: root/ ├─ src<1>/ <-- Invalid chars └─ test:2/ <-- Invalid charsSolution:
- Use allowed characters (configure
allowedChars) - Use
pathConflict.onInvalidCharsstrategy - Consider transliteration for special characters
- Use allowed characters (configure
-
Long Paths
Problem: very/deep/nested/structure/with/many/levels/and/long/names/file.tsSolution:
- Reduce path depth
- Use shorter names
- Configure
maxPathLengthandonLongPathstrategy
-
Conflicting Rules
Problem: { pathValidation: { enforceCase: "lower", allowedChars: "^[A-Z]+$" // Conflicts with lowercase requirement } }
Solution: Ensure validation rules don't contradict each other.
-
Invalid Merge Strategies
Problem: { pathConflict: { onDuplicatePath: "merge", mergeStrategy: undefined // Missing merge strategy } }
Solution: Always provide merge strategies when using merge resolution.
-
Incorrect Extensions
Problem: { pathValidation: { allowedExtensions: ["ts"], // Missing dot requireExtensions: true } }
Solution: Use complete extensions with dots (e.g., [".ts", ".js"]).
-
Deep Directory Structures
Problem: Extremely deep nesting causing slow validationSolution:
- Set reasonable
maxDepth - Use
pathValidation.resolveRelative = false - Consider flatter structure
- Set reasonable
-
Large Number of Files
Problem: Thousands of files causing slow path validationSolution:
- Use
uniquePaths: falseif not needed - Disable unnecessary validations
- Consider batch processing
- Use
-
Complex Regex Patterns
Problem: { pathValidation: { allowedChars: "^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d)[A-Za-z\\d]{8,}$" } }
Solution: Use simpler patterns or split into multiple rules.
-
Understanding Validation Errors
Error: Invalid tree structure: Line 5: Path "src" is duplicated Line 10: Invalid characters in name- Line number indicates where the error occurred
- Error message describes the specific issue
- Context shows the problematic line
-
Warning vs. Error
{ pathConflict: { onDuplicatePath: "warn" // Warning instead of error } }
- Warnings allow operation to continue
- Errors stop processing
- Configure severity per rule
-
Debug Mode
{ logging: { level: "debug", includeMetadata: true } }
- Shows detailed validation steps
- Includes rule evaluations
- Helps identify specific issues
-
Start Simple
// Begin with basic validation const config: ForgeConfig = { pathValidation: { maxDepth: 5, allowedChars: "^[a-z0-9-]+$" } };
-
Add Rules Gradually
// Add more rules as needed config.pathValidation = { ...config.pathValidation, enforceCase: "lower", uniquePaths: true };
-
Test Configuration
// Test with sample structures const testTree = ` root/ ├─ src/ └─ test/ `;
-
Monitor Performance
// Enable performance logging config.logging = { level: "debug", includeDuration: true };
-
Duplicate Paths
// Auto-rename duplicates pathConflict: { onDuplicatePath: "numbered", counterStart: 1 }
-
Invalid Characters
// Replace invalid chars pathConflict: { onInvalidChars: "replace", replacementChar: "-" }
-
Long Paths
// Auto-shorten paths pathConflict: { onLongPath: "shorten", preserveExtension: true }
- Check error messages for line numbers and context
- Enable debug logging for detailed information
- Test configuration with smaller trees first
- Use validation warnings instead of errors during setup
- Consider using custom resolution functions for special cases