# 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.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml 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.

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

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 2} */}
```js
// TODO: handle an empty list
function total(items) {
  /* fixme: rounding */
  return items.length * 1.1;
}
```

Not reported:

{/* good */}
```js
// 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"`. |

{/* bad {"options": [{"terms": ["hack"]}]} */}
```js
// HACK: the server sends the date as a string
const date = new Date(response.date);
```

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

{/* good */}
```js
// This is slow, todo: cache the result
const result = compute();
```

{/* bad {"options": [{"location": "anywhere"}]} */}
```js
// 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:

{/* good */}
```js
/**
 * TODO: document the arguments
 */
function connect(host, port) {}
```

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

{/* bad {"options": [{"decoration": ["*"]}]} */}
```js
/**
 * 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"`.
