fix command attempts to automatically apply corrections to Vale alerts that provide fix suggestions.
Usage
Either a JSON alert string or a path to a file containing an alert in JSON format.
How It Works
Thefix command:
- Parses the alert JSON (either from a string or file)
- Extracts the suggested correction from the alert’s
Actionfield - Applies the correction to the text
- Returns the result as JSON
Only alerts that include an
Action field with fix suggestions can be automatically corrected. Not all Vale rules provide automatic fixes.Alert Format
Vale alerts in JSON format include fix information when available:Examples
Fix from File
If you have an alert saved in a file:Fix from String
Pass the alert JSON directly:Output
The command returns JSON with the fix result:Which Rules Support Auto-Fix?
Rules that provide automatic fixes include:- Substitution rules - Suggest replacing terms with alternatives
- Capitalization rules - Fix incorrect capitalization
- Consistency rules - Standardize spelling variations
Action field in JSON output:
Integration Examples
Editor Integration
Editors can use this command to implement auto-fix functionality:Batch Fixing
Process multiple alerts:CI/CD Automation
Automatically fix simple issues in CI:GitHub Actions
Limitations
- Read-only - The command outputs the fix but doesn’t modify files directly
- Single alert - Processes one alert at a time
- No context - May not handle complex document structures correctly
- Rule-dependent - Only works with rules that provide fix suggestions
- Experimental - The interface may change without notice
Creating Fixable Rules
If you’re writing custom Vale rules, you can make them fixable by including suggestions:StyleName/FixableRule.yml
API Usage
Thefix command is part of Vale’s private API and is primarily intended for tool integration:
- Editor plugins (VS Code, Vim, etc.)
- Language servers
- Custom linting tools
- Automated fixing utilities
If you’re building tools that integrate with Vale, consider using the JSON output format with the
fix command to implement auto-fix functionality.