# no-unused-expressions

Rule `eslint/no-unused-expressions`. Disallow unused expressions

- Source: eslint
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 65.9M weekly downloads of presets that enable it
- Trend: +111.2% last quarter
- Rank: #235 by reach, #103 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `no-unused-expressions` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/no-unused-expressions) |
| Oxlint | `no-unused-expressions` | yes | no | plugin `eslint`, category correctness | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-expressions.html) |
| Biome | `suspicious/noUnusedExpressions` | no | no | group suspicious, since 2.2.5 | [docs](https://biomejs.dev/linter/rules/no-unused-expressions/) |

## Code examples

### Incorrect: the rule reports this

```js
0

if(0) 0

{0}

f(0), {}

a && b()

a, b()

c = a, b;

a() && function namedFunctionInExpressionContext () {f();}

(function anIncompleteIIFE () {});

injectGlobal`body{ color: red; }`
```

```js
doSomething();
"use strict"; // this isn't in a directive prologue, because there is a non-directive statement before it

function foo() {
    "bar" + 1;
}

class Foo {
    static {
        "use strict"; // class static blocks do not have directive prologues
    }
}
```

```js
a || b
```

### Correct: the rule accepts this

```js
{} // In this context, this is a block statement, not an object literal

{ myLabel: foo() } // In this context, this is a block statement with a label and expression, not an object literal

function namedFunctionDeclaration () {}

(function aGenuineIIFE () {}());

f()

a = 0

new C

delete a.b

void a
```

```js
"use strict";
"use asm"
"use stricter";
"use babel"
"any other strings like this in the directive prologue";
"this is still the directive prologue";

function foo() {
    "bar";
}

class Foo {
    someMethod() {
        "use strict";
    }
}
```

```js
a && b()
a() || (b = c)
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "no-unused-expressions": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "no-unused-expressions": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "suspicious": {
        "noUnusedExpressions": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Oxlint default](https://lintradar.dev/presets/oxlint-default.md) | Oxlint | `oxlint` | 111 | 50.8M | +183.6% |
| [Airbnb base](https://lintradar.dev/presets/airbnb-base.md) | ESLint | `eslint-config-airbnb-base` | 241 | 6.5M | +2.1% |
| [Airbnb](https://lintradar.dev/presets/airbnb.md) | ESLint | `eslint-config-airbnb` | 346 | 3.4M | +2.3% |
| [JavaScript Standard Style](https://lintradar.dev/presets/standard.md) | ESLint | `eslint-config-standard` | 161 | 3.1M | +12.9% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |

## Related rules

- [typescript/no-unused-expressions](https://lintradar.dev/rules/typescript/no-unused-expressions.md): Disallow unused expressions
- [eslint/no-iterator](https://lintradar.dev/rules/eslint/no-iterator.md): Disallow the use of the `__iterator__` property
- [eslint/eqeqeq](https://lintradar.dev/rules/eslint/eqeqeq.md): Require the use of `===` and `!==`
- [eslint/no-self-compare](https://lintradar.dev/rules/eslint/no-self-compare.md): Disallow comparisons where both sides are exactly the same
- [eslint/no-sequences](https://lintradar.dev/rules/eslint/no-sequences.md): Disallow comma operators
- [eslint/no-octal-escape](https://lintradar.dev/rules/eslint/no-octal-escape.md): Disallow octal escape sequences in string literals

---

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