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

Typos Workflow Improvement

Analysis: Current vs. reviewdog/action-typos

Previous Implementation

  • ✅ Changed files detection (efficient)
  • ✅ Comprehensive file type coverage
  • ❌ Complex Docker setup with imunew/typos-cli
  • ❌ Manual reviewdog integration
  • ❌ Less maintainable
  • ❌ No automatic typo fix suggestions
  • ❌ Potential Docker image security concerns

New Implementation with reviewdog/action-typos

  • Official reviewdog action - better maintained
  • Built-in reviewdog integration - cleaner implementation
  • Automatic typo fix suggestions - better developer experience
  • Latest typos version - always up-to-date
  • Simplified configuration - easier to maintain
  • Retained changed files detection - still efficient
  • Added typos configuration - domain-specific customization

Key Improvements

1. Better Integration

# Before: Manual Docker + reviewdog
docker run --rm \
  -v "${{ github.workspace }}:/work" \
  -w /work \
  imunew/typos-cli \
  ${{ steps.changed-files.outputs.all_changed_files }} \
| reviewdog -f=typos -reporter=github-pr-review -fail-on-error=false \
|| true

# After: Official action
uses: reviewdog/action-typos@627388e238f182b925d9acd151432f9b68f1d666 # v1.17.2
with:
  github_token: ${{ secrets.GITHUB_TOKEN }}
  level: warning
  reporter: github-pr-review
  filter_mode: added
  fail_level: none
  typos_flags: '${{ steps.changed-files.outputs.all_changed_files }}'

2. Enhanced Features

  • Typo fix suggestions: The action can suggest corrections in PR reviews
  • Better error handling: Built-in error handling and reporting
  • Configurable behavior: More granular control over reporting levels
  • Security: Uses official GitHub Actions instead of third-party Docker images

3. Domain-Specific Configuration (.typos.toml)

[default]
extend-ignore-re = [
    "(?i)klick",  # Case-insensitive for company names
    "postgres", "mysql", "redis",  # Database names
    "ActiveRecord", "params",  # Rails terms
    "api", "url", "json",  # Common abbreviations
]

[default.extend-words]
"occured" = "occurred"
"mispelled" = "misspelled"
"recieve" = "receive"

Configuration Details

Workflow Settings

  • Level: warning - Shows issues as warnings, not errors
  • Reporter: github-pr-review - Adds review comments to PRs
  • Filter Mode: added - Only checks newly added lines
  • Fail Level: none - Never fails the CI build
  • Efficiency: Still uses changed files detection for performance

File Coverage

The workflow checks these file types:

  • Ruby: *.rb, *.rake, *.erb
  • Web: *.html, *.htm, *.js, *.jsx, *.vue, *.css, *.scss
  • Documentation: *.md, *.txt
  • Configuration: *.json, *.yml, *.yaml, *.toml

Benefits

  1. Better Developer Experience: Suggestions instead of just error reporting
  2. Reduced Maintenance: Official action handles updates automatically
  3. Enhanced Security: No third-party Docker images
  4. Flexible Configuration: Domain-specific word handling
  5. Improved Performance: Same efficiency with better features

Testing Results

YAML Syntax: All workflows validated successfully
Tool Functionality: typos-cli 1.35.4 working correctly
Configuration: .typos.toml properly handles company names and technical terms
Integration: reviewdog action correctly configured

Maintenance

Updating Excluded Words

Edit .typos.toml to add:

  • Company/brand names: Add to extend-ignore-re
  • Technical terms: Add to extend-ignore-re
  • Common corrections: Add to extend-words

Action Updates

The action is pinned to a specific commit SHA for security. Update periodically:

uses: reviewdog/action-typos@[new-commit-sha] # vX.X.X

This improvement provides a more robust, maintainable, and feature-rich spelling check workflow while maintaining the performance benefits of your original implementation.