DangerJS Plugin - TODOs

rohit_gohri profile image Rohit Gohri Originally published at rohit.page on ・2 min read

What is It?

A plugin for danger-js that collects all the "TODO" comments introduced in a pull request (PR) and posts them as a comment on the PR.

NPM JS - Danger Plugin Todos

It's a pretty simple plugin that just scans your diff for matching comments, it supports different language style comments including JS, C, C++, Ruby, Java, Elm, HTML, Bash, etc. (open an issue if something is missing). You can also specify custom keywords other than "TODO" or "FIXME".

How to set it up?

  • Set up danger-js and add it to your continuous integration (CI) pipeline
  • Add danger-plugin-todos to the "dangerfile" as mentioned in the README

Next time your CI pipeline runs for any PR this plugin will scan the diff to get all the To-Do comments and post them through danger as a comment on the PR. The comment will update on consecutive runs.

Possible Workflows

Scenario A:

Sometimes when you start work on a feature you see things along the way that need to be fixed and you end up adding a To-Do or Fix-Me comment for them. The feature branch then gets merged and the comments quickly gets forgotten if they were not related to a part of the code base that sees frequent updates.

To track such To-Dos this plugin can be used, as a list of them will be added as a comment to the PR. This list of To-Dos can then be moved to a new issue before the PR is merged and the issue added to the backlog.

Scenario B:

This plugin can also be used to create an actual auto-updating To-Do List.

Just add all your tasks for the PR in the code as To-Dos and open a Work In Progress (WIP) PR, this will create a list of To-Dos in the PR comments.

Now, as you work on them and remove them the comment will be updated and your list will become smaller. Once you are done with them the PR will be ready to merge.

More Features Incoming

There are some new ideas that are being worked on (check the issues here), like:

  • Generate a link to create a new issue with a list of To-Dos automatically : This would be pretty great for our Scenario A above. Link can be customized to support different issue trackers
  • Show completed To-Dos : PRs that complete and remove old To-Dos should be celebrated. This would add a success message on removing old To-Dos.

Anyways, I hope this is useful for you. If you have any ideas on how to make this better feel free to message me on Twitter or open an issue on the repo.


Editor guide