DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 970,177 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
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 (0)

🌚 Life is too short to browse without dark mode