Markdownlint Implementation Documentation
Overview
This document details the implementation of the markdownlint workflow using reviewdog/action-markdownlint for automated Markdown linting in the HungryHub server repository.
Action Details
- Action: reviewdog/action-markdownlint@v0.26.2
- Tool: markdownlint-cli v0.41.0
- Purpose: Validates Markdown syntax, formatting, and structure consistency
- Files Covered: 90+ Markdown files (.md, .markdown)
Repository Status
Before Implementation
-
❌ No existing Markdown linting workflow
-
⚠️ Only
typos.ymlworkflow checking spelling in Markdown files -
📊 90 Markdown files requiring validation:
README.md, CHANGELOG.md, features.md, front-end.md, testing.md .github/instructions/*.md, docs/*.md, config/initializers.md bin/README.md, app/*/README.md, spec/*/README.md
After Implementation
- ✅ Comprehensive Markdown linting with reviewdog integration
- ✅ Custom configuration optimized for technical documentation
- ✅ Pull request reviews with inline comments
- ✅ Self-hosted runner compatibility
- ✅ Integration with existing CI/CD pipeline
Workflow Configuration
File: .github/workflows/markdownlint.yml
name: Markdown Linting
"on":
pull_request:
types: [opened, synchronize, reopened]
paths:
- '**/*.md'
- '**/*.markdown'
push:
branches: [main, master, develop]
paths:
- '**/*.md'
- '**/*.markdown'
Key Features
- Triggered on: Markdown file changes in PRs and main branches
- Runner: Self-hosted with type-cpx31, image-x86-app-docker-ce
- Changed Files Detection: Only lints modified Markdown files
- reviewdog Integration: Provides inline PR comments
- Timeout: 10 minutes (reasonable for 90+ files)
Custom Configuration
File: .markdownlint.json
{
"default": true,
"MD003": { "style": "atx" },
"MD007": { "indent": 2 },
"MD010": { "code_blocks": false },
"MD013": { "line_length": 120 },
"MD024": { "allow_different_nesting": true },
"MD033": false,
"MD041": false,
"MD046": { "style": "fenced" }
}
Rule Explanations
- MD003: ATX-style headings (# ## ###) for consistency
- MD007: 2-space indentation for lists (matches project style)
- MD010: Allow tabs in code blocks (common in documentation)
- MD013: 120 character line length (same as YAML config)
- MD024: Allow duplicate headings at different nesting levels
- MD033: Allow HTML tags (needed for technical docs)
- MD041: Don’t require first line to be top-level heading
- MD046: Prefer fenced code blocks (```) over indented
Local Testing Results
Installation
npm install markdownlint-cli
Testing Sample Files
npx markdownlint README.md CHANGELOG.md features.md front-end.md testing.md --config .markdownlint.json
Issues Found (Sample)
- Line Length Violations: Multiple files exceeded 120 characters
- Missing Blank Lines: Around headings and lists
- Bare URLs: URLs not properly formatted as links
- Missing Code Languages: Fenced blocks without language specification
- Trailing Spaces: Inconsistent whitespace handling
- List Formatting: Inconsistent list numbering and spacing
Example Issues
README.md:34 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines
README.md:123:12 MD034/no-bare-urls Bare URL used [Context: "http://localhost:3000/admin/ka..."]
README.md:215 MD040/fenced-code-language Fenced code blocks should have a language specified
CHANGELOG.md:4:121 MD013/line-length Line length [Expected: 120; Actual: 139]
testing.md:2:4 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]
Workflow Validation
YAML Syntax Check
python3 -c "import yaml; yaml.safe_load(open('.github/workflows/markdownlint.yml')); print('✅ markdownlint.yml is valid YAML')"
# Result: ✅ markdownlint.yml is valid YAML
Act Workflow Testing
act pull_request --workflows .github/workflows/markdownlint.yml --list
# Result: Stage 0, Job ID: markdownlint, Job name: Markdown Linting with markdownlint
Integration Benefits
Code Quality Improvements
- Consistent Documentation: Uniform formatting across all Markdown files
- Better Readability: Proper heading structure and spacing
- Link Validation: Ensures URLs are properly formatted
- Professional Appearance: Clean, well-formatted documentation
Developer Experience
- PR Integration: Inline comments in pull requests
- Fast Feedback: Only checks changed files
- Non-Blocking: Warning level allows merging with issues
- Educational: Teaches Markdown best practices
Maintenance Benefits
- Automated Validation: No manual Markdown review needed
- Consistent Standards: Enforced formatting rules
- Documentation Quality: Higher quality technical documentation
- Reduced Bike-shedding: Automated style decisions
Comparison with Existing Tools
vs. typos.yml (Existing)
| Feature | typos.yml | markdownlint.yml |
|---|---|---|
| Scope | Spelling only | Full Markdown structure |
| Files | All text files | Markdown specific |
| Validation | Dictionary check | Syntax and formatting |
| Output | Spell corrections | Structure improvements |
| Overlap | Minimal | Complementary |
Conclusion: Both tools serve different purposes and should coexist.
Repository Impact
File Statistics
- Total Markdown Files: 90 files
- Primary Files: README.md, CHANGELOG.md, features.md, front-end.md, testing.md
- Documentation Dirs: .github/instructions/, docs/, bin/, app/, spec/
- Configuration Files: .markdownlint.json (new)
Workflow Statistics
- Total Workflows: 14 (was 13)
- Linting Workflows: 4 (shfmt, actionlint, yamllint, markdownlint)
- Quality Gates: Comprehensive coverage (shell, YAML, Markdown, Actions)
Security Considerations
Action Security
- Pinned Version: v0.26.2 with SHA hash 3667398db9118d7e78f7a63d10e26ce454ba5f58
- Permissions: Read-only repository access
- Token Usage: Standard GITHUB_TOKEN for PR comments
- Third-party Risk: Minimal, well-maintained action
Self-hosted Runner
- Isolation: Cleanup step removes all files
- Network: Limited to repository files
- Execution: Node.js-based, no system access
- Dependencies: Standard npm packages
Troubleshooting
Common Issues
- Permission Errors: Ensure GITHUB_TOKEN has comment permissions
- File Not Found: Check path patterns match actual file structure
- Rule Conflicts: Adjust .markdownlint.json for specific needs
- Performance: Increase timeout for large repositories
Debug Commands
# Test configuration locally
npx markdownlint . --config .markdownlint.json
# Check specific files
npx markdownlint README.md --config .markdownlint.json
# Validate workflow YAML
python3 -c "import yaml; yaml.safe_load(open('.github/workflows/markdownlint.yml'))"
# Test with act
act pull_request --workflows .github/workflows/markdownlint.yml --list
Future Enhancements
Potential Improvements
- Auto-fix Mode: Enable automatic fixing of simple issues
- Custom Rules: Add HungryHub-specific Markdown rules
- Link Checking: Validate external links are accessible
- Performance: Optimize for large file counts
- Reporting: Generate Markdown quality reports
Configuration Tuning
- Monitor rule violations and adjust .markdownlint.json
- Consider adding project-specific rules
- Evaluate auto-fix safety for different rule types
Conclusion
The markdownlint implementation provides comprehensive Markdown validation for 90+ files in the repository. Combined with existing typos checking, this creates a complete documentation quality pipeline. The workflow integrates seamlessly with the existing CI/CD infrastructure and provides immediate value through improved documentation consistency.
This completes the reviewdog linting suite implementation:
- ✅ Shell Scripts: shfmt (50+ files)
- ✅ GitHub Actions: actionlint (13 workflows)
- ✅ YAML Files: yamllint (660+ files)
- ✅ Markdown Files: markdownlint (90+ files)
The repository now has comprehensive automated linting coverage for all major file types.