# no-confusing-void-expression

Rule `typescript/no-confusing-void-expression`. Require expressions of type void to appear in statement position

- Source: typescript
- Technologies: TypeScript
- Kind: suspicious
- Needs type information: yes
- Autofix: yes, in at least one linter
- Reach: 46.2M weekly downloads of presets that enable it
- Trend: +32.4% last quarter
- Rank: #295 by reach, #1077 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `@typescript-eslint/no-confusing-void-expression` | no | safe | package `@typescript-eslint/eslint-plugin` | [docs](https://typescript-eslint.io/rules/no-confusing-void-expression) |
| Oxlint | `typescript/no-confusing-void-expression` | no | safe | plugin `typescript`, category pedantic | [docs](https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-confusing-void-expression.html) |

## Code examples

### Incorrect: the rule reports this

```ts
// somebody forgot that `alert` doesn't return anything
const response = alert('Are you sure?');
console.log(alert('Are you sure?'));

// it's not obvious whether the chained promise will contain the response (fixable)
promise.then(value => window.postMessage(value));

// it looks like we are returning the result of `console.error` (fixable)
function doSomething() {
  if (!somethingToDo) {
    return console.error('Nothing to do!');
  }

  console.log('Doing a thing...');
}
```

### Correct: the rule accepts this

```ts
// just a regular void function in a statement position
alert('Hello, world!');

// this function returns a boolean value so it's ok
const response = confirm('Are you sure?');
console.log(confirm('Are you sure?'));

// now it's obvious that `postMessage` doesn't return any response
promise.then(value => {
  window.postMessage(value);
});

// now it's explicit that we want to log the error and return early
function doSomething() {
  if (!somethingToDo) {
    console.error('Nothing to do!');
    return;
  }

  console.log('Doing a thing...');
}

// using logical expressions for their side effects is fine
cond && console.log('true');
cond || console.error('false');
cond ? console.log('true') : console.error('false');
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import tseslint from "typescript-eslint";

export default [
  {
    plugins: { "@typescript-eslint": tseslint.plugin },
    rules: {
      "@typescript-eslint/no-confusing-void-expression": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "typescript/no-confusing-void-expression": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [typescript-eslint strict type-checked](https://lintradar.dev/presets/typescript-eslint-strict-type-checked.md) | ESLint | `@typescript-eslint/eslint-plugin` | 75 | 175.9M | +29.5% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |

## Related rules

- [typescript/no-unnecessary-condition](https://lintradar.dev/rules/typescript/no-unnecessary-condition.md): Disallow conditionals where the type is always truthy or always falsy
- [typescript/no-generated-empty-object-type](https://lintradar.dev/rules/typescript/no-generated-empty-object-type.md): Disallow type operations that resolve to the "empty object" type
- [typescript/no-unsafe-call](https://lintradar.dev/rules/typescript/no-unsafe-call.md): Disallow calling a value with type `any`
- [typescript/no-unnecessary-boolean-literal-compare](https://lintradar.dev/rules/typescript/no-unnecessary-boolean-literal-compare.md): Disallow unnecessary equality comparisons against boolean literals
- [typescript/no-unsafe-argument](https://lintradar.dev/rules/typescript/no-unsafe-argument.md): Disallow calling a function with a value with type `any`
- [typescript/no-unnecessary-type-arguments](https://lintradar.dev/rules/typescript/no-unnecessary-type-arguments.md): Disallow type arguments that are equal to the default

---

Web page: https://lintradar.dev/rules/typescript/no-confusing-void-expression. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
