Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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.yml workflow 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

  1. Triggered on: Markdown file changes in PRs and main branches
  2. Runner: Self-hosted with type-cpx31, image-x86-app-docker-ce
  3. Changed Files Detection: Only lints modified Markdown files
  4. reviewdog Integration: Provides inline PR comments
  5. 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)

  1. Line Length Violations: Multiple files exceeded 120 characters
  2. Missing Blank Lines: Around headings and lists
  3. Bare URLs: URLs not properly formatted as links
  4. Missing Code Languages: Fenced blocks without language specification
  5. Trailing Spaces: Inconsistent whitespace handling
  6. 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

  1. Consistent Documentation: Uniform formatting across all Markdown files
  2. Better Readability: Proper heading structure and spacing
  3. Link Validation: Ensures URLs are properly formatted
  4. Professional Appearance: Clean, well-formatted documentation

Developer Experience

  1. PR Integration: Inline comments in pull requests
  2. Fast Feedback: Only checks changed files
  3. Non-Blocking: Warning level allows merging with issues
  4. Educational: Teaches Markdown best practices

Maintenance Benefits

  1. Automated Validation: No manual Markdown review needed
  2. Consistent Standards: Enforced formatting rules
  3. Documentation Quality: Higher quality technical documentation
  4. Reduced Bike-shedding: Automated style decisions

Comparison with Existing Tools

vs. typos.yml (Existing)

Featuretypos.ymlmarkdownlint.yml
ScopeSpelling onlyFull Markdown structure
FilesAll text filesMarkdown specific
ValidationDictionary checkSyntax and formatting
OutputSpell correctionsStructure improvements
OverlapMinimalComplementary

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

  1. Permission Errors: Ensure GITHUB_TOKEN has comment permissions
  2. File Not Found: Check path patterns match actual file structure
  3. Rule Conflicts: Adjust .markdownlint.json for specific needs
  4. 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

  1. Auto-fix Mode: Enable automatic fixing of simple issues
  2. Custom Rules: Add HungryHub-specific Markdown rules
  3. Link Checking: Validate external links are accessible
  4. Performance: Optimize for large file counts
  5. 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:

  1. Shell Scripts: shfmt (50+ files)
  2. GitHub Actions: actionlint (13 workflows)
  3. YAML Files: yamllint (660+ files)
  4. Markdown Files: markdownlint (90+ files)

The repository now has comprehensive automated linting coverage for all major file types.