no-warning-comments

Disallow comments that start with TODO, FIXME, or another term you choose

A TODO or FIXME comment marks work that isn't finished. This rule lists them, so you can deal with them before the code ships and they don't pile up.

By default a term only counts at the start of a comment. Case doesn't matter, and a term only matches as a whole word.

Configure#

Off by default. To turn it on:

bunfig.toml
[lint.rules]
"no-warning-comments" = "error" # or "warn"

Every option, set to its default. The ones that are commented out are unset by default.

bunfig.toml
[lint.rules]
"no-warning-comments" = ["error", {
  terms = ["todo", "fixme", "xxx"],
  location = "start", # "start" or "anywhere"
  # decoration = <list of strings>,
}]

Examples#

example.js2 problems
// TODO: handle an empty list
function total(items) {
  /* fixme: rounding */
  return items.length * 1.1;
}
example.jsNo problems
// An empty list gives 0.
function total(items) {
  // Todos are counted like any other item.
  return items.length * 1.1;
}

Options#

OptionDefaultWhat it does
terms["todo", "fixme", "xxx"]The terms to look for. Your list replaces the default one.
location"start""start" only looks at the start of a comment. "anywhere" looks at all of it.
decorationnoneSingle characters to skip at the start of a comment, when location is "start".
example.jswith { "terms": ["hack"] }1 problem
// HACK: the server sends the date as a string
const date = new Date(response.date);

This comment is only reported with location: "anywhere":

example.jsNo problems
// This is slow, todo: cache the result
const result = compute();
example.jswith { "location": "anywhere" }1 problem
// This is slow, todo: cache the result
const result = compute();

In a JSDoc comment, the * characters come before the term, so it isn't at the start:

example.jsNo problems
/**
 * TODO: document the arguments
 */
function connect(host, port) {}

With decoration: ["*"] they're skipped:

example.jswith { "decoration": ["*"] }1 problem
/**
 * TODO: document the arguments
 */
function connect(host, port) {}

When not to use it#

If your team keeps TODO comments in the code on purpose, leave this rule off, or set it to "warn".