Skip to content

eslint/no-unused-expressions Restriction ​

What it does ​

This rule disallows unused expressions.

Why is this bad? ​

Unused expressions are usually a mistake. They can be a symptom of a bug or a misunderstanding of the code.

Examples ​

Examples of incorrect code for this rule:

ts
Set<number>;
1 as number;
window!;

Examples of correct code for this rule:

ts
const foo = new Set<number>();

How to use ​

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny no-unused-expressions
json
{
  "rules": {
    "no-unused-expressions": "error"
  }
}

References ​

Released under the MIT License.