You’ll never have to deal with outdated TODO comments again

Have you ever noticed outdated // TODO: comments in your codebase that should have been addressed ages ago? 🤔

Well, how about this then:

// This will raise an error:
// TODO: 2020-01-01: This is an expired TODO comment.

Looks awesome, huh?


This content originally appeared on DEV Community and was authored by Max Prilutskiy

Have you ever noticed outdated // TODO: comments in your codebase that should have been addressed ages ago? 🤔

Well, how about this then:

// This will raise an error:
// TODO: 2020-01-01: This is an expired TODO comment.

Looks awesome, huh?

Let's discuss how we can do something like that.

Introducing the eslint-plugin-no-expired-todo-comments, a handy tool that prevents TODO comments with expired dates from cluttering your code.

In this blog post, we'll walk through the installation, usage, and benefits of using that tiny plugin to maintain a cleaner codebase.

Btw, the work was inspired by @parker_codes's parker-codes/todo-by, check it out too!

What is it?

The eslint-plugin-no-expired-todo-comments is an ESLint plugin that provides a new rule for detecting TODO comments with expired dates. This plugin ensures that you don't have any outdated TODO comments in your codebase, helping you keep your code clean and organized.

Installation

You can easily install the plugin using npm, yarn, or pnpm, whatever you use basically, as shown below:

npm install eslint-plugin-no-expired-todo-comments --save-dev
# or
yarn add eslint-plugin-no-expired-todo-comments --dev
# or
pnpm add eslint-plugin-no-expired-todo-comments --save-dev

Usage

Once you've installed the plugin, it's time to start using it! Simply add the no-expired-todo-comments rule to your ESLint configuration:

// .eslintrc.js
module.exports = {
  plugins: ["no-expired-todo-comments"],
  rules: {
    "no-expired-todo-comments/no-expired-todo-comments": "error",
  },
};

Now, whenever you have a TODO comment with an expired date in your codebase, ESLint will raise an error, prompting you to address it before moving forward:

// This will raise an error:
// TODO: 2020-01-01: This is an expired TODO comment.

As simple as that!

Benefits

By using eslint-plugin-no-expired-todo-comments, you can:

  1. Keep your codebase clean and organized by removing unnecessary and outdated TODO comments.
  2. Ensure that your team stays on top of tasks, as expired TODO comments will now trigger errors.
  3. Improve code quality by addressing TODO comments in a timely manner.

Contributing

The project welcomes contributions from the community! If you encounter any bugs or issues, please open an issue on the project's GitHub page. If you'd like to contribute code, please fork the project and submit a pull request with your changes.

Conclusion

In summary, the plugin above is a useful tool for maintaining a clean and organized codebase by preventing outdated TODO comments. With this plugin, you'll never have to worry about forgetting or neglecting important tasks buried in your code.

And finally, a little programming joke to wrap things up:

Why do programmers always mix up Christmas and Halloween? 🎃 🎄

Because Oct 31 == Dec 25! 😂

Denzel laughing with a delay

Happy coding, and may your TODO comments never get forgotten again! 😉

P.S.: If you liked this stuff - you might like another cool thing I've built recently:

I've open-sourced my AI-powered GitHub Action that posts change logs directly into Slack every Monday morning

Also, let's connect on Twitter @maxprilutskiy. 👈 😉


This content originally appeared on DEV Community and was authored by Max Prilutskiy


Print Share Comment Cite Upload Translate Updates
APA

Max Prilutskiy | Sciencx (2023-05-14T11:34:09+00:00) You’ll never have to deal with outdated TODO comments again. Retrieved from https://www.scien.cx/2023/05/14/youll-never-have-to-deal-with-outdated-todo-comments-again/

MLA
" » You’ll never have to deal with outdated TODO comments again." Max Prilutskiy | Sciencx - Sunday May 14, 2023, https://www.scien.cx/2023/05/14/youll-never-have-to-deal-with-outdated-todo-comments-again/
HARVARD
Max Prilutskiy | Sciencx Sunday May 14, 2023 » You’ll never have to deal with outdated TODO comments again., viewed ,<https://www.scien.cx/2023/05/14/youll-never-have-to-deal-with-outdated-todo-comments-again/>
VANCOUVER
Max Prilutskiy | Sciencx - » You’ll never have to deal with outdated TODO comments again. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/05/14/youll-never-have-to-deal-with-outdated-todo-comments-again/
CHICAGO
" » You’ll never have to deal with outdated TODO comments again." Max Prilutskiy | Sciencx - Accessed . https://www.scien.cx/2023/05/14/youll-never-have-to-deal-with-outdated-todo-comments-again/
IEEE
" » You’ll never have to deal with outdated TODO comments again." Max Prilutskiy | Sciencx [Online]. Available: https://www.scien.cx/2023/05/14/youll-never-have-to-deal-with-outdated-todo-comments-again/. [Accessed: ]
rf:citation
» You’ll never have to deal with outdated TODO comments again | Max Prilutskiy | Sciencx | https://www.scien.cx/2023/05/14/youll-never-have-to-deal-with-outdated-todo-comments-again/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.