CSV-Style Error Output
When Linkspector finds broken links in default mode, it outputs results in a CSV-style format to the console. This format is designed for quick human readability and easy parsing.Format Structure
Example Output
Fields Explained
- filename - Relative path to the file containing the broken link
- line_number - Line number where the link appears (1-based)
- column - Column position where the link starts (1-based)
- status emoji - Visual indicator (π« for errors, β¨ for success)
- link - The actual URL that was checked
- status_code - HTTP status code (or
nullif not applicable) - error_message - Descriptive error message explaining the failure
Success Output
When all links are valid:JSON/RDJSON Output
Linkspector supports JSON output in the RDJSON (Reviewdog Diagnostic Format) format, making it ideal for CI/CD integration and automated tooling.Enabling JSON Output
Use the--json or -j flag:
RDJSON Structure
Empty RDJSON Output
When no broken links are found:Diagnostic Fields
Each diagnostic entry contains:- message - Error description including the URL, status code, and error details
- location.path - File path relative to the current directory
- location.range.start - Starting position (line and column)
- location.range.end - Ending position (line and column)
- severity - Always
"ERROR"for broken links
Line and column numbers in RDJSON are 1-based, matching most editor conventions.
RDJSON Validation Process
Linkspector automatically validates and fixes RDJSON output using the@umbrelladocs/rdformat-validator package to ensure compliance with the RDJSON specification.
Validation Levels
The validation process uses two fix levels:-
Basic Validation - Applied first, fixes common formatting issues
- Ensures all required fields are present
- Validates line and column numbers are positive integers
- Corrects field types and structure
-
Aggressive Validation - Applied if basic validation fails
- Attempts more extensive corrections
- Fills in missing data with default values
- Restructures malformed diagnostics
Automatic Fixes
Common automatic fixes include:- Ensuring line and column numbers are at least 1
- Adding missing required fields with sensible defaults
- Correcting invalid severity levels
- Fixing malformed range objects
Validation Messages
When fixes are applied, validation messages are written to stderr:Validation Failure Fallback
If validation completely fails, Linkspector outputs an empty but valid RDJSON structure:Statistics Output
Display comprehensive link checking statistics with the--showstat or -s flag.
Enabling Statistics
The
--showstat and --json options cannot be used together.Statistics Table
Statistics Fields
- Total files checked - Number of files processed
- Total links checked - Total unique links found across all files
- Hyperlinks - Links starting with
http://orhttps:// - File and header links - Relative file paths, anchors, and hash links
- Email links - Links starting with
mailto:(automatically skipped) - Working links - Links with status
aliveorassumed alive - Failed links - Links with status
error
Email links are automatically skipped and not counted in working or failed totals.
Combining Output Formats
Different output formats serve different purposes:CSV Output
Best for: Quick debugging and local developmentUse when you need immediate visual feedback on broken links.
RDJSON Output
Best for: CI/CD pipelines and automationUse with tools like Reviewdog or custom scripts for automated checking.
Statistics
Best for: Reporting and documentation health metricsUse for periodic audits and tracking link health over time.
Exit Codes
Linkspector uses standard exit codes to indicate success or failure:- Exit 0 - All links are valid
- Exit 1 - One or more broken links found, or configuration error