DEV Community

Christophe Colombier
Christophe Colombier

Posted on

How to fix typos in your code for goods !

I'm often struggling with typos when writing code.

Some typos are really nasty to find, such as:

  • maintanance => maintenance
  • begining => beginning
  • proccess => process

of course, they are obvious when you read them here, but in a large repository...

There are three tools I use.

all of them are opensource projects.

All these tools are reporting errors, the first two ones can help you to fix them.

typos

simply type typos to see the error the tool report.

You can then use typos -w to fix the ones, the tool suggests.

codespell

cspell

  • slow compared to the others
  • whitelist dictionaries based
  • reports anything it doesn't know, it can be very verbose
  • you can easily add your own dictionaries
  • ability to dump unknown words with --words-only, so you can build your own dictionaries easily
  • VS Code extension available
  • pre-commit.com hook available

Battle fight

  • typos and codespell are definitely easy to use on daily basis
  • cspell is the one I use in VS Code and commit hook, it requires some fine-tuning by building dictionaries, but it's worth it on long term.

Top comments (1)

Collapse
 
ccoveille profile image
Christophe Colombier

This post needs to be updated to include

github.com/errata-ai/vale

I'm using it daily with language tool in my IDE