Linter · Rules
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:
[lint.rules]
"no-warning-comments" = "error" # or "warn"
Every option, set to its default. The ones that are commented out are unset by default.
[lint.rules]
"no-warning-comments" = ["error", {
terms = ["todo", "fixme", "xxx"],
location = "start", # "start" or "anywhere"
# decoration = <list of strings>,
}]
Examples
Reported:
// TODO: handle an empty list
function total(items) {
/* fixme: rounding */
return items.length * 1.1;
}
Not reported:
// An empty list gives 0.
function total(items) {
// Todos are counted like any other item.
return items.length * 1.1;
}
Options
| Option | Default | What 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. |
decoration | none | Single characters to skip at the start of a comment, when location is "start". |
// HACK: the server sends the date as a string
const date = new Date(response.date);
This comment is only reported with location: "anywhere":
// This is slow, todo: cache the result
const result = compute();
// 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:
/**
* TODO: document the arguments
*/
function connect(host, port) {}
With decoration: ["*"] they're skipped:
/**
* 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".