# no-void

> Disallow the `void` operator

`void expression` runs the expression and returns `undefined`. Few people know the operator, and `undefined` says the same thing in a word everybody can read.

{/* 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-void" = "error" # or "warn"
```

Every option, set to its default:

```toml bunfig.toml
[lint.rules]
"no-void" = ["error", {
  allowAsStatement = false,
}]
```

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

## Examples

Reported:

{/* bad {"count": 2} */}
```js
let selected = void 0;

button.onclick = () => void save();
```

Not reported:

{/* good */}
```js
let selected = undefined;

button.onclick = () => {
  save();
};
```

## Options

| Option | Default | What it does |
| --- | --- | --- |
| `allowAsStatement` | `false` | Allow `void` when it's the whole statement. |

`void` at the start of a statement is how you tell `@typescript-eslint/no-floating-promises` that you're ignoring a promise on purpose. Turn this option on if you use both rules.

{/* good {"options": [{"allowAsStatement": true}]} */}
```js
void save();
```

Anywhere else, `void` is still reported:

{/* bad {"options": [{"allowAsStatement": true}]} */}
```js
const result = void save();
```
