I’m a stickler for good documentation, but there’s one thing I’m not great at That thing is… spell checking! 😱️

The thing is, I write a lot of code and text without my glasses or contact lenses, and thus rely on a lot of muscle memory to write just about anything. My eyes are fairly useless without correction so I’ll miss an extra or missing letter. This leads to a lot of embarrassment in the way of spelling errors, and I’ve had contributors open pull requests on my repos to say “No, Vanessa, repository is not spelled… like that…”

I have no good response other than to say “Well, my fingers seemed to think that was an appropriate spelling for the word! 😄️

Typos

I saw a new project that would be my savior - a Rust project called “typos” that offered to check spelling, and even correct it in place! The only problem was that I needed to automate running it with CI, so for one of this weekend’s projects I decided to add a GitHub action to do just that.. And it works great! Here is the basics for how to use it in your repository:

name: vsoch-check-spelling

on:
  push:
    branches: [master]
  pull_request: []

jobs:
  formatting:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Check for typos
        uses: crate-ci/typos@1.0.4
        with: 
          files: ./_posts

You could also do multiple folders or files, like

          files: ./_posts ./docs ./README.md

And you can add a “_typos.toml” to the repository with settings for words to ignore. Take a look at all the typos that were caught here! and for Singularity Registry Server! If you want to learn more about the typos project, see crate-ci/typos or read about the action on the GitHub marketplace.

And when you are running it locally and want to preview and then write changes? It’s as simple as:

# preview changes
./typos _posts

# write changes in place
typos _posts/ --write-changes

That’s all folks! The news on the street is that spell checking is cool and automating it even cooler! I’m very excited about this project and am looking forward to adding this step to check spelling in many of my documentation-rich projects.




Suggested Citation:
Sochat, Vanessa. "Spell Check with Typos." @vsoch (blog), 31 May 2021, https://vsoch.github.io/2021/typos/ (accessed 18 Nov 24).