Configuration
Must be set to
"dependent"
Configuration for dependent file relationships
Pattern matching files that trigger the dependency check
Pattern(s) for files that must be included when matching files are changed
Custom message to display when validation fails
Default message to display when validation fails
Basic Usage
Examples
Test Coverage Enforcement
Require test files for source code changes:Multiple Required Files
Require multiple related files to be updated together:Multiple Dependencies
Define different dependencies for different file types:Using Placeholders
Use$
placeholder to reference the base filename:
How It Works
1
Get Changed Files
The validator retrieves all files changed in the PR
2
Process Dependencies
For each dependency rule:
- Find files matching the “when” pattern
- For each match, determine the required corresponding files
- Check if these required files are included in the PR
3
Handle Placeholders
Replaces placeholders (2, etc.) with captured groups from the pattern match
4
Return Result
Returns a validation result with status (pass, fail, or error) and a message
Pattern Matching
The Dependent Files Validator uses JavaScript regular expressions with capture groups:src/(.+)\.js$
captures the path and filename (without extension) in$1
test/$1.test.js
uses the captured value to construct the expected test file path
Practical Use Cases
API and Documentation Sync
Ensure API changes are documented:Schema and Migration Files
Ensure database schema changes include migrations:Component and Test Updates
Enforce complete component updates:Best Practices
Use clear patterns with capture groups to establish relationships
Provide helpful error messages explaining the relationship
Consider the structure of your codebase when defining dependencies
Group related dependencies in one validator for clarity
Be careful with complex patterns that might be difficult for contributors to understand
Limitations
- Regular expressions can become complex for deeply nested directory structures
- Dependencies must be expressed as deterministic patterns
- Capturing multiple directory levels can be tricky