DEV Community

Jake Gore
Jake Gore

Posted on

Don't leave TODOs in your code!

What was the problem?

A few days ago, while working on a project, I wanted to find all of the TODOs that I had written to make sure that nothing was left unfinished. I tried looking through all of my project files, but it was time consuming and I wasn't certain that I had checked everything. This gave me an idea, I wanted to make an NPM package that would check my files for me.

What did I do?

Since then, I have created a package that searches your files and prints the TODOs to the terminal so you never leave any unused TODOs in your code. This will not only clean up your code, but help you avoid errors by not leaving unimplemented features in your code.


Feel free to check out the package and project files.

How do I install it?

Install the package with NPM, either locally with npm i -D todo-viewer, or globally with npm i -g todo-viewer. For the usage instructions, check out the documentation on Github.

Don't hesitate to make any changes to the code and submit a pull request! Any feedback on the package is highly appreciated. Thanks!

Top comments (3)

patricklafferty profile image
Patrick Lafferty • Edited

What led you to create this project over just using grep, or your editor's "find in files" equivalent function which pretty much every editor has? As far as I can tell this doesn't give you the line number for each todo, or the context surrounding the line, so you don't know where in the file it is. It also only works for todos that exactly match "// TODO:' with no indentation, and wont catch "//TODO:", "//TODO", "/* TODO", "/* \nTODO", "//To do:" etc.

A grep example:

grep -r TODO src -n -C2

-r recursively search in src
-n: show line numbers
-CX: show X lines before/after the matching line

This won't have any of the mentioned restrictions.

jakegore profile image
Jake Gore

To be honest, this is the first npm project that I have worked on. I had an idea and didn't really do much research before creating the module. Looking back, I would have done more research as it seems that there are already better options out there such as grep as suggested. Thanks for the suggestions. I posted this on Reddit too and it was suggested to use grep in your pre-commit git hook. You can find the comment here if you are interested.

berkmann18 profile image
Maximilian Berkmann

Does this account for any types of TODO comments and do pre-commit checks?