Skip to content

Instantly share code, notes, and snippets.

@KelWill
Created August 29, 2025 16:30
Show Gist options
  • Select an option

  • Save KelWill/7396a63e7405b527ffd7413059aa951b to your computer and use it in GitHub Desktop.

Select an option

Save KelWill/7396a63e7405b527ffd7413059aa951b to your computer and use it in GitHub Desktop.
const todoRegex = /^\s*todo /i;
const taggedTodoRegex = /^\s*todo [-a-z0-9_]+ \d{4}-\d{2}-\d{2} /i;
module.exports = {
meta: {
type: "problem",
docs: {
description:
"Disallow TODO comments unless they follow the format '// TODO github_username YYYY-MM-DD'",
category: "Best Practices",
recommended: false,
},
schema: [],
messages: {
invalidTodo:
"TODO comments must be in the format '// TODO github_username YYYY-MM-DD'.",
},
},
create(context) {
return {
Program() {
const sourceCode = context.getSourceCode();
const comments = sourceCode.getAllComments();
for (const comment of comments) {
const commentValue = comment.value;
if (!todoRegex.test(commentValue)) continue;
if (taggedTodoRegex.test(commentValue)) continue;
context.report({
loc: comment.loc,
messageId: "invalidTodo",
});
}
},
};
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment